本文整理了Java中com.intellij.lang.annotation.Annotation.setHighlightType()
方法的一些代码示例,展示了Annotation.setHighlightType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Annotation.setHighlightType()
方法的具体详情如下:
包路径:com.intellij.lang.annotation.Annotation
类名称:Annotation
方法名:setHighlightType
暂无
代码示例来源:origin: zalando/intellij-swagger
private void warn(
final PsiElement psiElement,
final AnnotationHolder annotationHolder,
final PsiElement searchableCurrentElement,
final String warning) {
final PsiReference first = ReferencesSearch.search(searchableCurrentElement).findFirst();
if (first == null) {
Annotation annotation = annotationHolder.createWeakWarningAnnotation(psiElement, warning);
annotation.setHighlightType(ProblemHighlightType.LIKE_UNUSED_SYMBOL);
}
}
}
代码示例来源:origin: zalando/intellij-swagger
private void warn(
final PsiElement psiElement,
final AnnotationHolder annotationHolder,
final PsiElement searchableCurrentElement,
final String warning) {
final PsiReference first = ReferencesSearch.search(searchableCurrentElement).findFirst();
if (first == null) {
Annotation annotation = annotationHolder.createWeakWarningAnnotation(psiElement, warning);
annotation.setHighlightType(ProblemHighlightType.LIKE_UNUSED_SYMBOL);
}
}
}
代码示例来源:origin: protostuff/protobuf-jetbrains-plugin
private void markError(ASTNode parent, @Nullable ASTNode node, String message) {
Annotation annotation;
if (node == null) {
annotation = holder.createErrorAnnotation(parent, message);
} else {
annotation = holder.createErrorAnnotation(node, message);
}
annotation.setHighlightType(ProblemHighlightType.GENERIC_ERROR);
}
代码示例来源:origin: SonarSource/sonarlint-intellij
private void addAnnotation(LiveIssue issue, AnnotationHolder annotationHolder) {
TextRange textRange;
if (issue.getRange() != null) {
textRange = createTextRange(issue.getRange());
} else {
textRange = issue.psiFile().getTextRange();
}
String htmlMsg = getHtmlMessage(issue);
Annotation annotation = annotationHolder
.createAnnotation(getSeverity(issue.getSeverity()), textRange, issue.getMessage(), htmlMsg);
annotation.registerFix(new DisableRuleQuickFix(issue.getRuleKey()));
if (!issue.flows().isEmpty()) {
annotation.registerFix(new ShowLocationsIntention(issue.getRange(), issue.getMessage(), issue.flows()));
}
if (issue.getRange() == null) {
annotation.setFileLevelAnnotation(true);
} else {
annotation.setTextAttributes(getTextAttrsKey(issue.getSeverity()));
}
/*
* 3 possible ways to set text attributes and error stripe color:
* - enforce text attributes ({@link Annotation#setEnforcedTextAttributes}) and we need to set everything
* manually (including error stripe color). This won't be configurable in a standard way and won't change based on used color scheme
* - rely on one of the default attributes by giving a key {@link com.intellij.openapi.editor.colors.CodeInsightColors} or your own
* key (SonarLintTextAttributes) to Annotation#setTextAttributes
* - let Annotation#getTextAttributes decide it based on highlight type and severity.
*/
annotation.setHighlightType(getType(issue.getSeverity()));
}
内容来源于网络,如有侵权,请联系作者删除!