From 764a9fb6dfb2a5746fb8e966c4fd7874fe4853e9 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 14 Mar 2012 11:36:37 +0400 Subject: [PATCH] narrow scope --- .../plugins/groovy/annotator/GroovyAnnotator.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java index aa1ddf78a5b9..2938cd69a92d 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java @@ -284,9 +284,12 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator { private static boolean isReassigned(GrVariable var) { PsiMethod method = PsiTreeUtil.getParentOfType(var, PsiMethod.class); + PsiNamedElement scope = method == null ? var.getContainingFile() : method; + if (scope == null) { + return false; + } boolean hasAssignment = var.getInitializerGroovy() != null || var instanceof GrParameter; - SearchScope scope = method == null ? GlobalSearchScope.projectScope(var.getProject()) : new LocalSearchScope(method); - for (PsiReference reference : ReferencesSearch.search(var, scope).findAll()) { + for (PsiReference reference : ReferencesSearch.search(var, new LocalSearchScope(scope)).findAll()) { if (reference instanceof GrReferenceExpression && (PsiUtil.isLValue((GrReferenceExpression)reference) || ((GrReferenceExpression)reference).getParent() instanceof GrPostfixExpression)) {