本文整理汇总了Java中com.intellij.lang.annotation.HighlightSeverity类的典型用法代码示例。如果您正苦于以下问题:Java HighlightSeverity类的具体用法?Java HighlightSeverity怎么用?Java HighlightSeverity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HighlightSeverity类属于com.intellij.lang.annotation包,在下文中一共展示了HighlightSeverity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: annotate
import com.intellij.lang.annotation.HighlightSeverity; //导入依赖的package包/类
@Override
public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder holder) {
if (psiElement instanceof Header) {
Header header = (Header)psiElement;
String name = header.getName();
if (!isValidName(name)) {
holder.createAnnotation(HighlightSeverity.ERROR, header.getNameElement().getTextRange(), ManifestBundle.message("header.name.invalid"));
}
else {
HeaderParser headerParser = myRepository.getHeaderParser(name);
if (headerParser != null) {
headerParser.annotate(header, holder);
}
}
}
}
示例2: waitForCodeAnalysisHighlightCount
import com.intellij.lang.annotation.HighlightSeverity; //导入依赖的package包/类
@NotNull
public FileFixture waitForCodeAnalysisHighlightCount(@NotNull final HighlightSeverity severity, final int expected) {
final Document document = getNotNullDocument();
pause(new Condition("Waiting for code analysis " + severity + " count to reach " + expected) {
@Override
public boolean test() {
Collection<HighlightInfo> highlightInfos = execute(new GuiQuery<Collection<HighlightInfo>>() {
@Override
protected Collection<HighlightInfo> executeInEDT() throws Throwable {
CommonProcessors.CollectProcessor<HighlightInfo> processor = new CommonProcessors.CollectProcessor<HighlightInfo>();
DaemonCodeAnalyzerEx.processHighlights(document, myProject, severity, 0, document.getTextLength(), processor);
return processor.getResults();
}
});
assertNotNull(highlightInfos);
return highlightInfos.size() == expected;
}
}, SHORT_TIMEOUT);
return this;
}
示例3: getAvailableActions
import com.intellij.lang.annotation.HighlightSeverity; //导入依赖的package包/类
@NotNull
public static List<HighlightInfo.IntentionActionDescriptor> getAvailableActions(@NotNull final Editor editor,
@NotNull final PsiFile file,
final int passId) {
final int offset = ((EditorEx)editor).getExpectedCaretOffset();
final Project project = file.getProject();
final List<HighlightInfo.IntentionActionDescriptor> result = new ArrayList<HighlightInfo.IntentionActionDescriptor>();
DaemonCodeAnalyzerImpl.processHighlightsNearOffset(editor.getDocument(), project, HighlightSeverity.INFORMATION, offset, true, new Processor<HighlightInfo>() {
@Override
public boolean process(HighlightInfo info) {
addAvailableActionsForGroups(info, editor, file, result, passId, offset);
return true;
}
});
return result;
}
示例4: getSeverity
import com.intellij.lang.annotation.HighlightSeverity; //导入依赖的package包/类
protected HighlightSeverity getSeverity(@NotNull RefElement element) {
final PsiElement psiElement = element.getPointer().getContainingFile();
if (psiElement != null) {
final GlobalInspectionContextImpl context = getContext();
final String shortName = getSeverityDelegateName();
final Tools tools = context.getTools().get(shortName);
if (tools != null) {
for (ScopeToolState state : tools.getTools()) {
InspectionToolWrapper toolWrapper = state.getTool();
if (toolWrapper == getToolWrapper()) {
return context.getCurrentProfile().getErrorLevel(HighlightDisplayKey.find(shortName), psiElement).getSeverity();
}
}
}
final InspectionProfile profile = InspectionProjectProfileManager.getInstance(context.getProject()).getInspectionProfile();
final HighlightDisplayLevel level = profile.getErrorLevel(HighlightDisplayKey.find(shortName), psiElement);
return level.getSeverity();
}
return null;
}
示例5: processHighlightsOverlappingOutside
import com.intellij.lang.annotation.HighlightSeverity; //导入依赖的package包/类
static boolean processHighlightsOverlappingOutside(@NotNull Document document,
@NotNull Project project,
@Nullable("null means all") final HighlightSeverity minSeverity,
final int startOffset,
final int endOffset,
@NotNull final Processor<HighlightInfo> processor) {
LOG.assertTrue(ApplicationManager.getApplication().isReadAccessAllowed());
final SeverityRegistrar severityRegistrar = SeverityRegistrar.getSeverityRegistrar(project);
MarkupModelEx model = (MarkupModelEx)DocumentMarkupModel.forDocument(document, project, true);
return model.processRangeHighlightersOutside(startOffset, endOffset, new Processor<RangeHighlighterEx>() {
@Override
public boolean process(@NotNull RangeHighlighterEx marker) {
Object tt = marker.getErrorStripeTooltip();
if (!(tt instanceof HighlightInfo)) return true;
HighlightInfo info = (HighlightInfo)tt;
return minSeverity != null && severityRegistrar.compare(info.getSeverity(), minSeverity) < 0
|| info.highlighter == null
|| processor.process(info);
}
});
}
示例6: process
import com.intellij.lang.annotation.HighlightSeverity; //导入依赖的package包/类
@Override
public boolean process(Trinity<ProblemDescriptor, LocalInspectionToolWrapper,ProgressIndicator> trinity) {
ProgressIndicator indicator = trinity.getThird();
if (indicator.isCanceled()) {
return false;
}
ProblemDescriptor descriptor = trinity.first;
LocalInspectionToolWrapper tool = trinity.second;
PsiElement psiElement = descriptor.getPsiElement();
if (psiElement == null) return true;
PsiFile file = psiElement.getContainingFile();
Document thisDocument = documentManager.getDocument(file);
HighlightSeverity severity = inspectionProfile.getErrorLevel(HighlightDisplayKey.find(tool.getShortName()), file).getSeverity();
infos.clear();
createHighlightsForDescriptor(infos, emptyActionRegistered, ilManager, file, thisDocument, tool, severity, descriptor, psiElement);
for (HighlightInfo info : infos) {
final EditorColorsScheme colorsScheme = getColorsScheme();
UpdateHighlightersUtil.addHighlighterToEditorIncrementally(myProject, myDocument, getFile(), myRestrictRange.getStartOffset(), myRestrictRange.getEndOffset(),
info, colorsScheme, getId(), ranges2markersCache);
}
return true;
}
示例7: createAnnotation
import com.intellij.lang.annotation.HighlightSeverity; //导入依赖的package包/类
@Nullable
public static Annotation createAnnotation(final DomElementProblemDescriptor problemDescriptor) {
return createProblemDescriptors(problemDescriptor, new Function<Pair<TextRange, PsiElement>, Annotation>() {
@Override
public Annotation fun(final Pair<TextRange, PsiElement> s) {
String text = problemDescriptor.getDescriptionTemplate();
if (StringUtil.isEmpty(text)) text = null;
final HighlightSeverity severity = problemDescriptor.getHighlightSeverity();
TextRange range = s.first;
if (text == null) range = TextRange.from(range.getStartOffset(), 0);
range = range.shiftRight(s.second.getTextRange().getStartOffset());
final Annotation annotation = createAnnotation(severity, range, text);
if (problemDescriptor instanceof DomElementResolveProblemDescriptor) {
annotation.setTextAttributes(CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES);
}
for(LocalQuickFix fix:problemDescriptor.getFixes()) {
if (fix instanceof IntentionAction) annotation.registerFix((IntentionAction)fix);
}
return annotation;
}
});
}
示例8: toProblemType
import com.intellij.lang.annotation.HighlightSeverity; //导入依赖的package包/类
private static String toProblemType(int severityValue) {
if (severityValue < HighlightSeverity.WARNING.myVal) {
return Problem.INFO;
} else if (severityValue < HighlightSeverity.ERROR.myVal) {
return Problem.WARNING;
} else {
return Problem.ERROR;
}
}
示例9: MerlinErrorAnnotator
import com.intellij.lang.annotation.HighlightSeverity; //导入依赖的package包/类
public MerlinErrorAnnotator() {
severities.put(MerlinErrorType.error, HighlightSeverity.ERROR);
severities.put(MerlinErrorType.type, HighlightSeverity.ERROR);
severities.put(MerlinErrorType.parser, HighlightSeverity.ERROR);
severities.put(MerlinErrorType.env, HighlightSeverity.ERROR);
severities.put(MerlinErrorType.warning, HighlightSeverity.WARNING);
severities.put(MerlinErrorType.unknown, HighlightSeverity.INFORMATION);
}
示例10: testHighlights
import com.intellij.lang.annotation.HighlightSeverity; //导入依赖的package包/类
public void testHighlights() throws Exception
{
myFixture.configureByFile( "json/highlight/MyError.json" );
List<HighlightInfo> highlightInfos = myFixture.doHighlighting( HighlightSeverity.WARNING );
assertEquals( 1, highlightInfos.size() );
assertEquals( "Invalid URI fragment: /definitions/crawlStepTyp", highlightInfos.get( 0 ).getDescription() );
assertEquals( "\"#/definitions/crawlStepTyp\"", highlightInfos.get( 0 ).getText() );
}
示例11: apply
import com.intellij.lang.annotation.HighlightSeverity; //导入依赖的package包/类
@Override
public void apply(@NotNull PsiFile file, RamlValidationResult annotationResult, @NotNull AnnotationHolder holder)
{
final List<ErrorNode> errorNodes = annotationResult.getErrorNodes();
for (ErrorNode errorNode : errorNodes)
{
if (file.getVirtualFile().getPath().endsWith(errorNode.getStartPosition().getPath()))
{
holder.createAnnotation(HighlightSeverity.ERROR, new TextRange(errorNode.getStartPosition().getIndex(), errorNode.getEndPosition().getIndex()), errorNode.getErrorMessage());
}
}
}
示例12: annotateDocumentationWithArmaPluginTags
import com.intellij.lang.annotation.HighlightSeverity; //导入依赖的package包/类
/**
* Annotates the given comment so that tags like @command, @bis, and @fnc (Arma Intellij Plugin specific tags) are properly annotated
*
* @param annotator the annotator
* @param comment the comment
*/
public static void annotateDocumentationWithArmaPluginTags(@NotNull AnnotationHolder annotator, @NotNull PsiComment comment) {
List<String> allowedTags = new ArrayList<>(3);
allowedTags.add("command");
allowedTags.add("bis");
allowedTags.add("fnc");
Pattern patternTag = Pattern.compile("@([a-zA-Z]+) ([a-zA-Z_0-9]+)");
Matcher matcher = patternTag.matcher(comment.getText());
String tag;
Annotation annotation;
int startTag, endTag, startArg, endArg;
while (matcher.find()) {
if (matcher.groupCount() < 2) {
continue;
}
tag = matcher.group(1);
if (!allowedTags.contains(tag)) {
continue;
}
startTag = matcher.start(1);
endTag = matcher.end(1);
startArg = matcher.start(2);
endArg = matcher.end(2);
annotation = annotator.createAnnotation(HighlightSeverity.INFORMATION, TextRange.create(comment.getTextOffset() + startTag - 1, comment.getTextOffset() + endTag), null);
annotation.setTextAttributes(DefaultLanguageHighlighterColors.DOC_COMMENT_TAG);
annotation = annotator.createAnnotation(HighlightSeverity.INFORMATION, TextRange.create(comment.getTextOffset() + startArg, comment.getTextOffset() + endArg), null);
annotation.setTextAttributes(DefaultLanguageHighlighterColors.DOC_COMMENT_TAG_VALUE);
}
}
示例13: testWarningForDeprecatedFormat
import com.intellij.lang.annotation.HighlightSeverity; //导入依赖的package包/类
@Test
public void testWarningForDeprecatedFormat() {
BuildFile file =
createBuildFile(
new WorkspacePath("java/com/google/BUILD"),
"load('/tools/ide/build_test.bzl', 'build_test')");
assertHasAnnotation(
file,
"Deprecated load syntax; loaded Skylark module should by in label format.",
HighlightSeverity.WARNING);
}
示例14: doHighlighting
import com.intellij.lang.annotation.HighlightSeverity; //导入依赖的package包/类
@NotNull
@Override
public List<HighlightInfo> doHighlighting(@NotNull final HighlightSeverity minimalSeverity) {
return ContainerUtil.filter(doHighlighting(), new Condition<HighlightInfo>() {
@Override
public boolean value(HighlightInfo info) {
return info.getSeverity().compareTo(minimalSeverity) >= 0;
}
});
}
示例15: getTextAttributes
import com.intellij.lang.annotation.HighlightSeverity; //导入依赖的package包/类
@NotNull
public static TextAttributes getTextAttributes(@Nullable EditorColorsScheme editorColorsScheme, @NotNull SeverityRegistrar severityRegistrar, @NotNull HighlightSeverity severity) {
TextAttributes textAttributes = severityRegistrar.getTextAttributesBySeverity(severity);
if (textAttributes != null) {
return textAttributes;
}
EditorColorsScheme colorsScheme = getColorsScheme(editorColorsScheme);
HighlightInfoType.HighlightInfoTypeImpl infoType = severityRegistrar.getHighlightInfoTypeBySeverity(severity);
TextAttributesKey key = infoType.getAttributesKey();
return colorsScheme.getAttributes(key);
}