boolean (InitialInfo info) { //new ConflictsDialog() final MultiMap<PsiElement, String> conflicts = new MultiMap<>(); final PsiElement declarationOwner = info.getContext().getParent(); GroovyRecursiveElementVisitor visitor = new GroovyRecursiveElementVisitor() { @Override public void visitReferenceExpression(@NotNull GrReferenceExpression referenceExpression) { super.visitReferenceExpression(referenceExpression); GroovyResolveResult resolveResult = referenceExpression.advancedResolve(); PsiElement resolveContext = resolveResult.getCurrentFileResolveContext(); if (resolveContext != null && !(resolveContext instanceof GrImportStatement) && !PsiTreeUtil.isAncestor(declarationOwner, resolveContext, true) && !skipResult(resolveResult)) { conflicts.putValue(referenceExpression, GroovyRefactoringBundle .message("ref.0.will.not.be.resolved.outside.of.current.context", referenceExpression.getText())); } } //skip 'print' and 'println' private static boolean skipResult(GroovyResolveResult result) { PsiElement element = result.getElement(); if (element instanceof PsiMethod) { String name = ((PsiMethod)element).getName(); if (!name.startsWith("print")) return false; if (element instanceof GrGdkMethod) element = ((GrGdkMethod)element).getStaticMethod(); PsiClass aClass = ((PsiMethod)element).getContainingClass(); if (aClass != null) { String qname = aClass.getQualifiedName(); return GroovyCommonClassNames.DEFAULT_GROOVY_METHODS.equals(qname); } } return false; } }; GrStatement[] statements = info.getStatements(); for (GrStatement statement : statements) { statement.accept(visitor); } return !BaseRefactoringProcessor.processConflicts(info.getProject(), conflicts); }