void (@NotNull GrReferenceExpression referenceExpression) { super.visitReferenceExpression(referenceExpression); if (PsiUtil.isThisReference(referenceExpression) || PsiUtil.isSuperReference(referenceExpression)) { replaceWithReference(referenceExpression, "delegate"); return; } PsiElement resolved = referenceExpression.resolve(); if (resolved instanceof PsiMember && (resolved instanceof PsiClass || ((PsiMember)resolved).hasModifierProperty(PsiModifier.STATIC))) { String qName = com.intellij.psi.util.PsiUtil.getMemberQualifiedName((PsiMember)resolved); if (qName != null && qName.contains(".") && !referenceExpression.isQualified()) { replaceWithReference(referenceExpression, qName); return; } } if (shouldDelegate(referenceExpression, resolved)) { replaceWithReference(referenceExpression, "delegate." + referenceExpression.getReferenceName()); return; } if (resolved instanceof GrVariable && !(resolved instanceof GrField) && !PsiTreeUtil.isAncestor(toEval, resolved, false)) { final String name = ((GrVariable)resolved).getName(); if (resolved instanceof ClosureSyntheticParameter && PsiTreeUtil.isAncestor(toEval, ((ClosureSyntheticParameter)resolved).getClosure(), false)) { return; } if (resolved instanceof GrBindingVariable && !PsiTreeUtil.isAncestor(resolved.getContainingFile(), toEval, false)) { return; } String value; if (functionalExpression != null && !PsiTreeUtil.isAncestor(functionalExpression, resolved, false) && !(resolved instanceof ClosureSyntheticParameter)) { // Evaluating inside functionalExpression for outer variable definitions // All non-local variables are accessed by references value = "this." + name; } else { value = name; } parameters.put(name, value); return; } if (resolved instanceof PsiLocalVariable || resolved instanceof PsiParameter && !(resolved instanceof GrParameter)) { String name = referenceExpression.getReferenceName(); parameters.put(name, name); } }