use of com.intellij.codeInsight.daemon.impl.HighlightInfoType in project intellij-community by JetBrains.
the class GrInspectionUtil method createAnnotationForRef.
public static HighlightInfo createAnnotationForRef(@NotNull GrReferenceElement ref, @NotNull HighlightDisplayLevel displayLevel, @NotNull String message) {
PsiElement refNameElement = ref.getReferenceNameElement();
assert refNameElement != null;
if (displayLevel == HighlightDisplayLevel.ERROR) {
return HighlightInfo.newHighlightInfo(HighlightInfoType.WRONG_REF).range(refNameElement).descriptionAndTooltip(message).create();
}
if (displayLevel == HighlightDisplayLevel.WEAK_WARNING) {
boolean isTestMode = ApplicationManager.getApplication().isUnitTestMode();
HighlightInfoType infotype = isTestMode ? HighlightInfoType.WARNING : HighlightInfoType.INFORMATION;
HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(infotype).range(refNameElement);
builder.descriptionAndTooltip(message);
return builder.needsUpdateOnTyping(false).textAttributes(GroovySyntaxHighlighter.UNRESOLVED_ACCESS).create();
}
HighlightInfoType highlightInfoType = HighlightInfo.convertSeverity(displayLevel.getSeverity());
return HighlightInfo.newHighlightInfo(highlightInfoType).range(refNameElement).descriptionAndTooltip(message).create();
}
use of com.intellij.codeInsight.daemon.impl.HighlightInfoType in project intellij-community by JetBrains.
the class XmlHighlightVisitor method addMessageWithFixes.
@Override
public void addMessageWithFixes(final PsiElement context, final String message, @NotNull final ErrorType type, @NotNull final IntentionAction... fixes) {
if (message != null && !message.isEmpty()) {
final PsiFile containingFile = context.getContainingFile();
final HighlightInfoType defaultInfoType = type == ErrorType.ERROR ? HighlightInfoType.ERROR : type == ErrorType.WARNING ? HighlightInfoType.WARNING : HighlightInfoType.WEAK_WARNING;
if (context instanceof XmlTag && XmlExtension.getExtension(containingFile).shouldBeHighlightedAsTag((XmlTag) context)) {
addElementsForTagWithManyQuickFixes((XmlTag) context, message, defaultInfoType, fixes);
} else {
final PsiElement contextOfFile = InjectedLanguageManager.getInstance(containingFile.getProject()).getInjectionHost(containingFile);
final HighlightInfo highlightInfo;
if (contextOfFile != null) {
TextRange range = InjectedLanguageManager.getInstance(context.getProject()).injectedToHost(context, context.getTextRange());
highlightInfo = HighlightInfo.newHighlightInfo(defaultInfoType).range(range).descriptionAndTooltip(message).create();
} else {
highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.WRONG_REF).range(context).descriptionAndTooltip(message).create();
}
for (final IntentionAction quickFixAction : fixes) {
if (quickFixAction == null)
continue;
QuickFixAction.registerQuickFixAction(highlightInfo, quickFixAction);
}
addToResults(highlightInfo);
}
}
}
Aggregations