narrow scope

This commit is contained in:
peter
2012-03-14 11:39:39 +04:00
parent 7a5b85fdb3
commit 764a9fb6df
@@ -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)) {