use of com.intellij.lang.annotation.Annotation in project intellij-community by JetBrains.
the class WebReferencesAnnotatorBase method apply.
@Override
public void apply(@NotNull PsiFile file, MyInfo[] infos, @NotNull AnnotationHolder holder) {
if (infos == null || infos.length == 0) {
return;
}
final HighlightDisplayLevel displayLevel = getHighlightDisplayLevel(file);
for (MyInfo info : infos) {
if (!info.myResult) {
final PsiElement element = info.myAnchor.retrieve();
if (element != null) {
final int start = element.getTextRange().getStartOffset();
final TextRange range = new TextRange(start + info.myRangeInElement.getStartOffset(), 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);
}
for (IntentionAction action : getQuickFixes()) {
annotation.registerFix(action);
}
}
}
}
}
use of com.intellij.lang.annotation.Annotation in project intellij-community by JetBrains.
the class ClassReferenceParser method annotate.
@Override
public boolean annotate(@NotNull Header header, @NotNull AnnotationHolder holder) {
HeaderValue value = header.getHeaderValue();
if (!(value instanceof HeaderValuePart))
return false;
HeaderValuePart valuePart = (HeaderValuePart) value;
String className = valuePart.getUnwrappedText();
if (StringUtil.isEmptyOrSpaces(className)) {
holder.createErrorAnnotation(valuePart.getHighlightingRange(), ManifestBundle.message("header.reference.invalid"));
return true;
}
Project project = header.getProject();
Module module = ModuleUtilCore.findModuleForPsiElement(header);
GlobalSearchScope scope = module != null ? module.getModuleWithDependenciesAndLibrariesScope(false) : ProjectScope.getAllScope(project);
PsiClass aClass = JavaPsiFacade.getInstance(project).findClass(className, scope);
if (aClass == null) {
String message = JavaErrorMessages.message("error.cannot.resolve.class", className);
Annotation anno = holder.createErrorAnnotation(valuePart.getHighlightingRange(), message);
anno.setHighlightType(ProblemHighlightType.LIKE_UNKNOWN_SYMBOL);
return true;
}
return checkClass(valuePart, aClass, holder);
}
use of com.intellij.lang.annotation.Annotation in project intellij-community by JetBrains.
the class AnnotationHolderImpl method createAnnotation.
@Override
public Annotation createAnnotation(@NotNull HighlightSeverity severity, @NotNull TextRange range, @Nullable String message, @Nullable String tooltip) {
Annotation annotation = new Annotation(range.getStartOffset(), range.getEndOffset(), severity, message, tooltip);
add(annotation);
return annotation;
}
use of com.intellij.lang.annotation.Annotation in project intellij-community by JetBrains.
the class GroovyAnnotator method checkGrDocReferenceElement.
private static void checkGrDocReferenceElement(AnnotationHolder holder, PsiElement element) {
ASTNode node = element.getNode();
if (node != null && TokenSets.BUILT_IN_TYPES.contains(node.getElementType())) {
Annotation annotation = holder.createInfoAnnotation(element, null);
annotation.setTextAttributes(GroovySyntaxHighlighter.KEYWORD);
}
}
use of com.intellij.lang.annotation.Annotation in project intellij-community by JetBrains.
the class GroovyAnnotator method checkForAbstractAndFinalCombination.
private static void checkForAbstractAndFinalCombination(AnnotationHolder holder, GrMember member, GrModifierList modifiersList) {
if (member.hasModifierProperty(PsiModifier.FINAL) && member.hasModifierProperty(PsiModifier.ABSTRACT)) {
final Annotation annotation = holder.createErrorAnnotation(modifiersList, GroovyBundle.message("illegal.combination.of.modifiers.abstract.and.final"));
registerFix(annotation, new GrModifierFix(member, PsiModifier.FINAL, false, false, GrModifierFix.MODIFIER_LIST), modifiersList);
registerFix(annotation, new GrModifierFix(member, PsiModifier.ABSTRACT, false, false, GrModifierFix.MODIFIER_LIST), modifiersList);
}
}
Aggregations