void (PsiElement element, PsiElement scope) { if (!(element instanceof GroovyPsiElement)) return; if (PsiUtil.isThisReference(element)) { GrReferenceExpression thisExpr = (GrReferenceExpression)element; final PsiClass containingClass = PsiTreeUtil.getParentOfType(thisExpr, PsiClass.class); element.putCopyableUserData(KEY_ENCODED, KEY_ENCODED); thisExpr.putCopyableUserData(QUALIFIER_CLASS_KEY, containingClass); } else if (element instanceof GrReferenceExpression refExpr) { final GrExpression qualifier = refExpr.getQualifierExpression(); if (qualifier == null) { PsiElement refElement = refExpr.resolve(); element.putCopyableUserData(KEY_ENCODED, KEY_ENCODED); if (refElement != null && !PsiTreeUtil.isContextAncestor(scope, refElement, false)) { if (refElement instanceof GrAccessorMethod) refElement = ((GrAccessorMethod)refElement).getProperty(); if (refElement instanceof PsiClass) { refExpr.putCopyableUserData(REF_TO_CLASS, (PsiClass)refElement); } else if (refElement instanceof PsiMember) { refExpr.putCopyableUserData(REF_TO_MEMBER, (PsiMember)refElement); } } } } else if (element instanceof GrCodeReferenceElement) { final PsiElement resolvedElement = ((GrCodeReferenceElement)element).resolve(); element.putCopyableUserData(KEY_ENCODED, KEY_ENCODED); if (resolvedElement instanceof PsiClass && !PsiTreeUtil.isContextAncestor(scope, resolvedElement, false)) { element.putCopyableUserData(REF_TO_CLASS, (PsiClass)resolvedElement); } } for (PsiElement child = element.getFirstChild(); child != null; child = child.getNextSibling()) { encodeContextInfo(child, scope); } }