void () { final PsiClass containingClass = PsiTreeUtil.getParentOfType(myRefExpr, PsiClass.class); if (containingClass != null) return; final PsiFile file = FileContextUtil.getContextFile(myRefExpr); if (file instanceof GroovyFile) { ((GroovyFile)file).accept(new GroovyRecursiveElementVisitor() { @Override public void visitAssignmentExpression(@NotNull GrAssignmentExpression expression) { super.visitAssignmentExpression(expression); final GrExpression value = expression.getLValue(); if (value instanceof GrReferenceExpression && !((GrReferenceExpression)value).isQualified()) { final PsiElement resolved = ((GrReferenceExpression)value).resolve(); if (resolved instanceof GrBindingVariable) { myProcessor.execute(resolved, ResolveState.initial()); } else if (resolved == null) { myProcessor.execute(new GrBindingVariable((GroovyFile)file, ((GrReferenceExpression)value).getReferenceName()), ResolveState.initial()); } } } @Override public void visitTypeDefinition(@NotNull GrTypeDefinition typeDefinition) { //don't go into classes } }); } }