void (@NotNull GrReferenceExpression ref) { final GroovyResolveResult oldResult = ref.getCopyableUserData(REF_RESOLVE_RESULT_KEY); if (oldResult != null) { assert ref.getQualifierExpression() == null; final GroovyResolveResult newResult = ref.advancedResolve(); final PsiElement oldElement = oldResult.getElement(); final PsiElement newElement = newResult.getElement(); if (!ref.getManager().areElementsEquivalent(oldElement, newElement) || oldResult.getCurrentFileResolveContext() != newResult.getCurrentFileResolveContext()) { final GrReferenceExpression qualifier = GroovyPsiElementFactory.getInstance(ref.getProject()).createReferenceExpressionFromText("owner"); ref.setQualifier(qualifier); } } super.visitReferenceExpression(ref); }