mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
port web to the new Annotator API
GitOrigin-RevId: e95a2a2c0e60a39ad7ccfbc5a2c4c857bd7514c5
This commit is contained in:
committed by
intellij-monorepo-bot
parent
8d2551ebf9
commit
096ede200d
@@ -9,6 +9,7 @@ import com.intellij.json.psi.JsonReferenceExpression;
|
||||
import com.intellij.json.psi.JsonStringLiteral;
|
||||
import com.intellij.lang.annotation.AnnotationHolder;
|
||||
import com.intellij.lang.annotation.Annotator;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
@@ -41,7 +42,7 @@ public class JsonLiteralAnnotator implements Annotator {
|
||||
|
||||
// Check that string literal is closed properly
|
||||
if (length <= 1 || text.charAt(0) != text.charAt(length - 1) || JsonPsiUtil.isEscapedChar(text, length - 1)) {
|
||||
holder.createErrorAnnotation(element, JsonBundle.message("syntax.error.missing.closing.quote"));
|
||||
holder.newAnnotation(HighlightSeverity.ERROR, JsonBundle.message("syntax.error.missing.closing.quote")).create();
|
||||
}
|
||||
|
||||
// Check escapes
|
||||
@@ -51,7 +52,7 @@ public class JsonLiteralAnnotator implements Annotator {
|
||||
if (!checker.isApplicable(element)) continue;
|
||||
Pair<TextRange, String> error = checker.getErrorForStringFragment(fragment, stringLiteral);
|
||||
if (error != null) {
|
||||
holder.createErrorAnnotation(error.getFirst().shiftRight(elementOffset), error.second);
|
||||
holder.newAnnotation(HighlightSeverity.ERROR, error.second).range(error.getFirst().shiftRight(elementOffset)).create();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -65,7 +66,7 @@ public class JsonLiteralAnnotator implements Annotator {
|
||||
}
|
||||
String error = checker.getErrorForNumericLiteral(text);
|
||||
if (error != null) {
|
||||
holder.createErrorAnnotation(element, error);
|
||||
holder.newAnnotation(HighlightSeverity.ERROR, error).create();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -73,7 +74,12 @@ public class JsonLiteralAnnotator implements Annotator {
|
||||
|
||||
private static void highlightPropertyKey(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
|
||||
if (JsonPsiUtil.isPropertyKey(element)) {
|
||||
holder.createInfoAnnotation(element, Holder.DEBUG ? "property key" : null).setTextAttributes(JsonSyntaxHighlighterFactory.JSON_PROPERTY_KEY);
|
||||
if (Holder.DEBUG) {
|
||||
holder.newAnnotation(HighlightSeverity.INFORMATION, "property key").textAttributes(JsonSyntaxHighlighterFactory.JSON_PROPERTY_KEY).create();
|
||||
}
|
||||
else {
|
||||
holder.newSilentAnnotation(HighlightSeverity.INFORMATION).textAttributes(JsonSyntaxHighlighterFactory.JSON_PROPERTY_KEY).create();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -2,9 +2,9 @@
|
||||
package com.intellij.codeInsight.highlighting;
|
||||
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.lang.annotation.Annotation;
|
||||
import com.intellij.lang.annotation.AnnotationHolder;
|
||||
import com.intellij.lang.annotation.Annotator;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.actionSystem.IdeActions;
|
||||
import com.intellij.openapi.actionSystem.Shortcut;
|
||||
import com.intellij.openapi.editor.colors.CodeInsightColors;
|
||||
@@ -33,8 +33,8 @@ public class HyperlinkAnnotator implements Annotator {
|
||||
holder.getCurrentAnnotationSession().putUserData(messageKey, message);
|
||||
}
|
||||
TextRange range = reference.getRangeInElement().shiftRight(element.getTextRange().getStartOffset());
|
||||
Annotation annotation = holder.createInfoAnnotation(range, message);
|
||||
annotation.setTextAttributes(CodeInsightColors.INACTIVE_HYPERLINK_ATTRIBUTES);
|
||||
holder.newAnnotation(HighlightSeverity.INFORMATION, message).range(range)
|
||||
.textAttributes(CodeInsightColors.INACTIVE_HYPERLINK_ATTRIBUTES).create();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.intellij.openapi.paths;
|
||||
|
||||
import com.intellij.codeHighlighting.HighlightDisplayLevel;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.lang.annotation.Annotation;
|
||||
import com.intellij.lang.annotation.AnnotationBuilder;
|
||||
import com.intellij.lang.annotation.AnnotationHolder;
|
||||
import com.intellij.lang.annotation.ExternalAnnotator;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -117,24 +117,12 @@ public abstract class WebReferencesAnnotatorBase extends ExternalAnnotator<WebRe
|
||||
start + info.myRangeInElement.getEndOffset());
|
||||
final String message = getErrorMessage(info.myUrl);
|
||||
|
||||
final Annotation annotation;
|
||||
|
||||
if (displayLevel == HighlightDisplayLevel.ERROR) {
|
||||
annotation = holder.createErrorAnnotation(range, message);
|
||||
}
|
||||
else if (displayLevel == HighlightDisplayLevel.WARNING) {
|
||||
annotation = holder.createWarningAnnotation(range, message);
|
||||
}
|
||||
else if (displayLevel == HighlightDisplayLevel.WEAK_WARNING) {
|
||||
annotation = holder.createInfoAnnotation(range, message);
|
||||
}
|
||||
else {
|
||||
annotation = holder.createWarningAnnotation(range, message);
|
||||
}
|
||||
AnnotationBuilder builder = holder.newAnnotation(displayLevel.getSeverity(), message).range(range);
|
||||
|
||||
for (IntentionAction action : getQuickFixes()) {
|
||||
annotation.registerFix(action);
|
||||
builder = builder.withFix(action);
|
||||
}
|
||||
builder.create();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -3,6 +3,7 @@ package org.jetbrains.yaml.annotator;
|
||||
|
||||
import com.intellij.lang.annotation.AnnotationHolder;
|
||||
import com.intellij.lang.annotation.Annotator;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
@@ -70,7 +71,7 @@ public class YAMLSameLineCompositeValueErrorAnnotator implements Annotator {
|
||||
}
|
||||
|
||||
private static void reportAboutSameLine(@NotNull final AnnotationHolder holder, @NotNull YAMLValue value) {
|
||||
holder.createErrorAnnotation(value, YAMLBundle.message("annotator.same.line.composed.value.message"));
|
||||
holder.newAnnotation(HighlightSeverity.ERROR, YAMLBundle.message("annotator.same.line.composed.value.message")).range(value).create();
|
||||
}
|
||||
|
||||
private static boolean psiAreAtTheSameLine(@NotNull PsiElement psi1, @NotNull PsiElement psi2, @NotNull CharSequence documentContent) {
|
||||
|
||||
Reference in New Issue
Block a user