Skip to content

Commit c3b501d

Browse files
committed
simplify: use syntax traverser
1 parent 7cf9efa commit c3b501d

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

src/com/goide/codeInsight/GoExpressionTypeProvider.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
import com.goide.psi.GoType;
2121
import com.goide.psi.GoTypeOwner;
2222
import com.intellij.lang.ExpressionTypeProvider;
23+
import com.intellij.openapi.util.Conditions;
2324
import com.intellij.openapi.util.text.StringUtil;
2425
import com.intellij.psi.PsiElement;
25-
import com.intellij.psi.util.PsiTreeUtil;
26-
import com.intellij.util.containers.ContainerUtil;
26+
import com.intellij.psi.SyntaxTraverser;
2727
import org.jetbrains.annotations.NotNull;
2828

2929
import java.util.List;
@@ -45,16 +45,6 @@ public String getErrorHint() {
4545
@NotNull
4646
@Override
4747
public List<GoTypeOwner> getExpressionsAt(@NotNull PsiElement elementAt) {
48-
if (PsiTreeUtil.getParentOfType(elementAt, GoStatement.class) == null) {
49-
return ContainerUtil.emptyList();
50-
}
51-
List<GoTypeOwner> expressions = ContainerUtil.newArrayList();
52-
while (elementAt != null && !(elementAt instanceof GoStatement)) {
53-
if (elementAt instanceof GoTypeOwner) {
54-
expressions.add((GoTypeOwner)elementAt);
55-
}
56-
elementAt = elementAt.getParent();
57-
}
58-
return expressions;
48+
return SyntaxTraverser.psiApi().parents(elementAt).takeWhile(Conditions.notInstanceOf(GoStatement.class)).filter(GoTypeOwner.class).toList();
5949
}
6050
}

0 commit comments

Comments
 (0)