SSR: match multiple fields declared in single declaration correctly in incomplete code (IDEA-CR-4531)

This commit is contained in:
Bas Leijdekkers
2015-09-29 12:03:07 +02:00
parent ff6559e242
commit f5c8a63044
2 changed files with 10 additions and 1 deletions
@@ -22,6 +22,7 @@ import java.util.List;
public class DeclarationStatementHandler extends MatchingHandler {
private MatchingHandler myCommentHandler;
@Override
public boolean match(PsiElement patternNode, PsiElement matchedNode, MatchContext context) {
if (patternNode instanceof PsiComment) {
return myCommentHandler.match(patternNode, matchedNode, context);
@@ -59,7 +60,7 @@ public class DeclarationStatementHandler extends MatchingHandler {
node = PsiTreeUtil.skipSiblingsForward(node, PsiWhiteSpace.class);
while (PsiUtil.isJavaToken(node, JavaTokenType.COMMA)) {
node = PsiTreeUtil.skipSiblingsForward(node, PsiWhiteSpace.class);
if (node != null) {
if (node instanceof PsiField) {
matchNodes.add(node);
}
node = PsiTreeUtil.skipSiblingsForward(node, PsiWhiteSpace.class);
@@ -89,6 +90,7 @@ public class DeclarationStatementHandler extends MatchingHandler {
return false;
}
@Override
public boolean shouldAdvanceTheMatchFor(PsiElement patternElement, PsiElement matchedElement) {
if (patternElement instanceof PsiComment &&
( matchedElement instanceof PsiField ||