HighlightInfo (@Nullable PsiClass aClass, @NotNull PsiElement elementToHighlight, @NotNull TextAttributesScheme colorsScheme) { TextRange range = elementToHighlight.getTextRange(); if (elementToHighlight instanceof PsiJavaCodeReferenceElement referenceElement) { PsiElement identifier = referenceElement.getReferenceNameElement(); if (identifier != null) { range = identifier.getTextRange(); } } // This will highlight @ sign in annotation as well. PsiElement parent = elementToHighlight.getParent(); if (parent instanceof PsiAnnotation psiAnnotation) { range = new TextRange(psiAnnotation.getTextRange().getStartOffset(), range.getEndOffset()); } HighlightInfoType type = getClassNameHighlightType(aClass, elementToHighlight); TextAttributes attributes = mergeWithScopeAttributes(aClass, type, colorsScheme); if (aClass != null && elementToHighlight instanceof PsiJavaCodeReferenceElement) { attributes = mergeWithVisibilityAttributes(aClass, attributes, colorsScheme); } HighlightInfo.Builder builder = nameBuilder(type).range(range); if (attributes != null) { builder.textAttributes(attributes); } return builder.createUnconditionally(); }