mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
highlight static imports according to the color scheme selected (IDEA-133887)
This commit is contained in:
+1
-4
@@ -159,10 +159,7 @@ public class HighlightNamesUtil {
|
||||
@Nullable
|
||||
public static HighlightInfo highlightClassNameInQualifier(final PsiJavaCodeReferenceElement element,
|
||||
@NotNull TextAttributesScheme colorsScheme) {
|
||||
PsiExpression qualifierExpression = null;
|
||||
if (element instanceof PsiReferenceExpression) {
|
||||
qualifierExpression = ((PsiReferenceExpression)element).getQualifierExpression();
|
||||
}
|
||||
PsiElement qualifierExpression = element.getQualifier();
|
||||
if (qualifierExpression instanceof PsiJavaCodeReferenceElement) {
|
||||
PsiElement resolved = ((PsiJavaCodeReferenceElement)qualifierExpression).resolve();
|
||||
if (resolved instanceof PsiClass) {
|
||||
|
||||
+19
-3
@@ -647,12 +647,12 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
final String refName = ref.getReferenceName();
|
||||
final JavaResolveResult[] results = ref.multiResolve(false);
|
||||
|
||||
final PsiElement referenceNameElement = ref.getReferenceNameElement();
|
||||
if (results.length == 0) {
|
||||
final String description = JavaErrorMessages.message("cannot.resolve.symbol", refName);
|
||||
final PsiElement nameElement = ref.getReferenceNameElement();
|
||||
assert nameElement != null : ref;
|
||||
assert referenceNameElement != null : ref;
|
||||
final HighlightInfo info =
|
||||
HighlightInfo.newHighlightInfo(HighlightInfoType.WRONG_REF).range(nameElement).descriptionAndTooltip(description).create();
|
||||
HighlightInfo.newHighlightInfo(HighlightInfoType.WRONG_REF).range(referenceNameElement).descriptionAndTooltip(description).create();
|
||||
QuickFixAction.registerQuickFixAction(info, QuickFixFactory.getInstance().createSetupJDKFix());
|
||||
myHolder.add(info);
|
||||
}
|
||||
@@ -690,6 +690,22 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!myHolder.hasErrorResults()) {
|
||||
final PsiElement resolved = results.length == 1 ? results[0].getElement() : null;
|
||||
final TextAttributesScheme colorsScheme = myHolder.getColorsScheme();
|
||||
if (resolved instanceof PsiClass) {
|
||||
myHolder.add(HighlightNamesUtil.highlightClassName((PsiClass)resolved, ref, colorsScheme));
|
||||
}
|
||||
else{
|
||||
myHolder.add(HighlightNamesUtil.highlightClassNameInQualifier(ref, colorsScheme));
|
||||
if (resolved instanceof PsiVariable) {
|
||||
myHolder.add(HighlightNamesUtil.highlightVariableName((PsiVariable)resolved, referenceNameElement, colorsScheme));
|
||||
}
|
||||
else if (resolved instanceof PsiMethod) {
|
||||
myHolder.add(HighlightNamesUtil.highlightMethodName((PsiMethod)resolved, referenceNameElement, false, colorsScheme));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
@@ -1,4 +1,6 @@
|
||||
import <symbolName descr="null" type="CLASS_NAME">java.io</symbolName>.*; // highlight on demand import as class name
|
||||
import static <symbolName descr="null" type="CLASS_NAME">java.io.File</symbolName>.<symbolName descr="null" type="STATIC_FINAL_FIELD">pathSeparator</symbolName>;
|
||||
import static <symbolName descr="null" type="CLASS_NAME">java.io.File</symbolName>.*;
|
||||
|
||||
class <symbolName descr="null" type="CLASS_NAME">a</symbolName> {
|
||||
void <symbolName descr="null" type="METHOD_DECLARATION">method</symbolName>() {
|
||||
|
||||
Reference in New Issue
Block a user