SSR: use PsiTreeUtil.lastChild() instead of own implementation

This commit is contained in:
Bas Leijdekkers
2016-06-04 20:45:48 +02:00
parent 396ee209b5
commit 9aa6a55984
@@ -318,13 +318,13 @@ public class JavaStructuralSearchProfile extends StructuralSearchProfile {
final PsiElement firstElement = elements[0];
final PsiElement secondElement = elements[1];
if (firstElement instanceof PsiDeclarationStatement && getLastLeaf(firstElement) instanceof PsiErrorElement) {
if (firstElement instanceof PsiDeclarationStatement && PsiTreeUtil.lastChild(firstElement) instanceof PsiErrorElement) {
// might be method
return true;
}
else if (firstElement instanceof PsiErrorElement &&
secondElement instanceof PsiExpressionStatement &&
getLastLeaf(secondElement) instanceof PsiErrorElement) {
PsiTreeUtil.lastChild(secondElement) instanceof PsiErrorElement) {
// might be generic method
return true;
}
@@ -336,15 +336,6 @@ public class JavaStructuralSearchProfile extends StructuralSearchProfile {
return false;
}
private static PsiElement getLastLeaf(PsiElement element) {
PsiElement lastChild = element.getLastChild();
while (lastChild != null) {
element = lastChild;
lastChild = lastChild.getLastChild();
}
return element;
}
@NotNull
@Override
public Editor createEditor(@NotNull SearchContext searchContext,