void (TreeElement ref, ASTNode original) { IElementType originalType = original.getElementType(); if (originalType == JavaElementType.REFERENCE_EXPRESSION) { PsiJavaCodeReferenceElement javaRefElement = SourceTreeToPsiMap.treeToPsiNotNull(original); JavaResolveResult resolveResult = javaRefElement.advancedResolve(false); PsiElement target = resolveResult.getElement(); if (target instanceof PsiClass && (original.getTreeParent().getElementType() == JavaElementType.REFERENCE_EXPRESSION || original.getTreeParent().getElementType() == JavaElementType.METHOD_REF_EXPRESSION)) { ref.putCopyableUserData(JavaTreeGenerator.REFERENCED_CLASS_KEY, (PsiClass)target); } else if ((target instanceof PsiMethod || target instanceof PsiField) && ((PsiMember)target).hasModifierProperty(PsiModifier.STATIC) && resolveResult.getCurrentFileResolveScope() instanceof PsiImportStaticStatement) { ref.putCopyableUserData(JavaTreeGenerator.REFERENCED_MEMBER_KEY, (PsiMember)target); } } else if (originalType == JavaElementType.JAVA_CODE_REFERENCE) { PsiJavaCodeReferenceElementImpl.Kind kind = ((PsiJavaCodeReferenceElementImpl)original).getKindEnum(((PsiJavaCodeReferenceElementImpl)original).getContainingFile()); switch (kind) { case CLASS_NAME_KIND, CLASS_OR_PACKAGE_NAME_KIND, CLASS_IN_QUALIFIED_NEW_KIND -> { PsiElement target = SourceTreeToPsiMap.<PsiJavaCodeReferenceElement>treeToPsiNotNull(original).resolve(); if (target instanceof PsiClass) { ref.putCopyableUserData(JavaTreeGenerator.REFERENCED_CLASS_KEY, (PsiClass)target); } } case PACKAGE_NAME_KIND, CLASS_FQ_NAME_KIND, CLASS_FQ_OR_PACKAGE_NAME_KIND -> { } default -> LOG.error("Unknown kind: " + kind); } } else { LOG.error("Wrong element type: " + originalType); } }