GrReferenceExpression (@NotNull GrVariable field, @NotNull PsiElement place, @NotNull PsiClass containingClass) { final String qname = containingClass instanceof GroovyScriptClass ? null : containingClass.getQualifiedName(); final String prefix = qname != null ? qname + "." : ""; final String refText; if (field.hasModifierProperty(PsiModifier.STATIC)) { refText = prefix + field.getName(); } else { refText = prefix + "this." + field.getName(); } return GroovyPsiElementFactory.getInstance(place.getProject()).createReferenceExpressionFromText(refText, place); }