IDEA-130071 (SSR incorrectly says pattern does not match anything in selected scope)

This commit is contained in:
Bas Leijdekkers
2014-12-18 20:27:09 +01:00
parent 2562fcf408
commit cabfec01e9
3 changed files with 38 additions and 10 deletions
@@ -436,7 +436,31 @@ public class JavaCompilingVisitor extends JavaRecursiveElementWalkingVisitor {
private void handleReference(PsiJavaCodeReferenceElement reference) {
handleReferenceText(reference.getReferenceName(), myCompilingVisitor.getContext());
if (shouldOccur(reference)) {
handleReferenceText(reference.getReferenceName(), myCompilingVisitor.getContext());
}
}
private boolean shouldOccur(PsiJavaCodeReferenceElement reference) {
final CompileContext compileContext = myCompilingVisitor.getContext();
final PsiElement parent = reference.getParent();
if (!(parent instanceof PsiReferenceList)) {
return true;
}
final PsiElement grandParent = parent.getParent();
if (!(grandParent instanceof PsiMethod)) {
return true;
}
final PsiMethod method = (PsiMethod)grandParent;
if (method.getThrowsList() != parent) {
return true;
}
final String name = method.getName();
if (!compileContext.getPattern().isTypedVar(name)) {
return true;
}
final SubstitutionHandler handler = (SubstitutionHandler)compileContext.getPattern().getHandler(name);
return !(handler != null && handler.getMinOccurs() == 0);
}
private static void handleReferenceText(String refname, CompileContext compileContext) {