Java 类com.intellij.lang.annotation.HighlightSeverity 实例源码

项目:intellij-ce-playground    文件:HeaderAnnotator.java   
@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);
      }
    }
  }
}
项目:intellij-ce-playground    文件:FileFixture.java   
@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;
}
项目:intellij-ce-playground    文件:ShowIntentionsPass.java   
@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;
}
项目:intellij-ce-playground    文件:DefaultInspectionToolPresentation.java   
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;
}
项目:intellij-ce-playground    文件:DaemonCodeAnalyzerEx.java   
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);
    }
  });
}
项目:intellij-ce-playground    文件:LocalInspectionsPass.java   
@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;
}
项目:intellij-ce-playground    文件:DomElementsHighlightingUtil.java   
@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;
    }
  });
}
项目:ijaas    文件:JavaSrcUpdateHandler.java   
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;
  }
}
项目:reasonml-idea-plugin    文件:MerlinErrorAnnotator.java   
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);
}
项目:manifold-ij    文件:JsonAnnotatorTest.java   
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() );
}
项目:mule-intellij-plugins    文件:RamlAnnotator.java   
@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());
        }
    }

}
项目:arma-intellij-plugin    文件:DocumentationUtil.java   
/**
 * 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);
    }
}
项目:intellij    文件:LoadStatementAnnotatorTest.java   
@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);
}
项目:intellij-ce-playground    文件:CodeInsightTestFixtureImpl.java   
@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;
    }
  });
}
项目:stylint-plugin    文件:AnnotatorUtils.java   
@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);
}
项目:camel-idea-plugin    文件:CamelEndpointAnnotatorTestIT.java   
public void testAnnotatorProducerOnly() {
    myFixture.configureByText("AnnotatorTestData.java", getJavaProducerOnlyTestData());
    myFixture.checkHighlighting(false, false, true, true);

    List<HighlightInfo> list = myFixture.doHighlighting();

    // find the warning from the highlights as checkWarning cannot do that for us for warnings
    boolean found = list.stream().anyMatch(i -> i.getText().equals("delete")
        && i.getDescription().equals("Option not applicable in producer only mode")
        && i.getSeverity().equals(HighlightSeverity.WARNING));
    assertTrue("Should find the warning", found);
}
项目:intellij    文件:LoadStatementAnnotatorTest.java   
private void assertHasAnnotation(BuildFile file, String message, HighlightSeverity type) {
  assertThat(
          validateFile(file)
              .stream()
              .filter(ann -> ann.getSeverity().equals(type))
              .map(Annotation::getMessage)
              .collect(Collectors.toList()))
      .contains(message);
}
项目:sass-lint-plugin    文件:SassLintExternalAnnotator.java   
@Nullable
    private static Annotation createAnnotation(@NotNull AnnotationHolder holder, @NotNull PsiFile file, @NotNull Document document, @NotNull SassLint.Issue warn,
                                               @NotNull HighlightSeverity severity, @Nullable TextAttributes forcedTextAttributes,
                                               boolean showErrorOnWholeLine) {
        int line = warn.line - 1;
//        int column = warn.column /*- 1*/;

        if (line < 0 || line >= document.getLineCount()) {
            return null;
        }
        int lineEndOffset = document.getLineEndOffset(line);
        int lineStartOffset = document.getLineStartOffset(line);

//        int errorLineStartOffset = StringUtil.lineColToOffset(document.getCharsSequence(),  line, column);
//        int errorLineStartOffset = PsiUtil.calcErrorStartOffsetInDocument(document, lineStartOffset, lineEndOffset, column, tab);

//        if (errorLineStartOffset == -1) {
//            return null;
//        }
//        PsiElement element = file.findElementAt(errorLineStartOffset);
        TextRange range;
//        if (showErrorOnWholeLine) {
            range = new TextRange(lineStartOffset, lineEndOffset);
//        } else {
////            int offset = StringUtil.lineColToOffset(document.getText(), warn.line - 1, warn.column);
//            PsiElement lit = PsiUtil.getElementAtOffset(file, errorLineStartOffset);
//            range = lit.getTextRange();
//            range = new TextRange(errorLineStartOffset, errorLineStartOffset + 1);
//        }

        Annotation annotation = InspectionUtil.createAnnotation(holder, severity, forcedTextAttributes, range, MESSAGE_PREFIX + warn.message.trim() + " (" + warn.source + ')');
//        if (annotation != null) {
//            annotation.setAfterEndOfLine(errorLineStartOffset == lineEndOffset);
//        }
        return annotation;
    }
项目:intellij-ce-playground    文件:CodeSmellDetectorImpl.java   
private void convertErrorsAndWarnings(@NotNull Collection<HighlightInfo> highlights,
                                      @NotNull List<CodeSmellInfo> result,
                                      @NotNull Document document) {
  for (HighlightInfo highlightInfo : highlights) {
    final HighlightSeverity severity = highlightInfo.getSeverity();
    if (SeverityRegistrar.getSeverityRegistrar(myProject).compare(severity, HighlightSeverity.WARNING) >= 0) {
      result.add(new CodeSmellInfo(document, getDescription(highlightInfo),
                                   new TextRange(highlightInfo.startOffset, highlightInfo.endOffset), severity));
    }
  }
}
项目:intellij    文件:BlazeRenderErrorContributor.java   
/**
 * We can't find generated resources. If a layout uses them, the layout won't render correctly.
 */
private void reportGeneratedResources(
    AndroidResourceModule resourceModule, TargetMap targetMap, ArtifactLocationDecoder decoder) {
  Map<String, Throwable> brokenClasses = logger.getBrokenClasses();
  if (brokenClasses == null || brokenClasses.isEmpty()) {
    return;
  }

  // Sorted entries for deterministic error message.
  SortedMap<ArtifactLocation, TargetIdeInfo> generatedResources =
      Maps.newTreeMap(getGeneratedResources(targetMap.get(resourceModule.targetKey)));

  for (TargetKey dependency : resourceModule.transitiveResourceDependencies) {
    generatedResources.putAll(getGeneratedResources(targetMap.get(dependency)));
  }

  if (generatedResources.isEmpty()) {
    return;
  }

  HtmlBuilder builder = new HtmlBuilder();
  builder.add("Generated resources will not be discovered by the IDE:");
  builder.beginList();
  for (Map.Entry<ArtifactLocation, TargetIdeInfo> entry : generatedResources.entrySet()) {
    ArtifactLocation resource = entry.getKey();
    TargetIdeInfo target = entry.getValue();
    builder.listItem().add(resource.getRelativePath()).add(" from ");
    addTargetLink(builder, target, decoder);
  }
  builder
      .endList()
      .add("Please avoid using generated resources, ")
      .addLink("then ", "sync the project", " ", getLinkManager().createSyncProjectUrl())
      .addLink("and ", "refresh the layout", ".", getLinkManager().createRefreshRenderUrl());
  addIssue()
      .setSeverity(HighlightSeverity.ERROR, HIGH_PRIORITY + 1) // Reported above broken classes
      .setSummary("Generated resources")
      .setHtmlContent(builder)
      .build();
}
项目:intellij-ce-playground    文件:DefaultInspectionToolPresentation.java   
protected static String getTextAttributeKey(@NotNull Project project,
                                            @NotNull HighlightSeverity severity,
                                            @NotNull ProblemHighlightType highlightType) {
  if (highlightType == ProblemHighlightType.LIKE_DEPRECATED) {
    return HighlightInfoType.DEPRECATED.getAttributesKey().getExternalName();
  }
  if (highlightType == ProblemHighlightType.LIKE_UNKNOWN_SYMBOL && severity == HighlightSeverity.ERROR) {
    return HighlightInfoType.WRONG_REF.getAttributesKey().getExternalName();
  }
  if (highlightType == ProblemHighlightType.LIKE_UNUSED_SYMBOL) {
    return HighlightInfoType.UNUSED_SYMBOL.getAttributesKey().getExternalName();
  }
  SeverityRegistrar registrar = InspectionProjectProfileManagerImpl.getInstanceImpl(project).getSeverityRegistrar();
  return registrar.getHighlightInfoTypeBySeverity(severity).getAttributesKey().getExternalName();
}
项目:intellij-ce-playground    文件:DomElementAnnotationHolderImpl.java   
@Override
public DomElementProblemDescriptor createProblem(@NotNull final DomElement domElement,
                                                 final HighlightSeverity highlightType,
                                                 final String message,
                                                 final TextRange textRange,
                                                 final LocalQuickFix... fixes) {
  return addProblem(new DomElementProblemDescriptorImpl(domElement, message, highlightType, textRange, null, fixes));
}
项目:intellij-ce-playground    文件:MavenDuplicateDependenciesInspection.java   
private static void checkManagedDependencies(@NotNull MavenDomProjectModel projectModel,
                                             @NotNull DomElementAnnotationHolder holder) {
  MultiMap<DependencyConflictId, MavenDomDependency> duplicates = MultiMap.createSet();
  collect(duplicates, projectModel.getDependencyManagement().getDependencies());

  for (Map.Entry<DependencyConflictId, Collection<MavenDomDependency>> entry : duplicates.entrySet()) {
    Collection<MavenDomDependency> set = entry.getValue();
    if (set.size() <= 1) continue;

    for (MavenDomDependency dependency : set) {
      holder.createProblem(dependency, HighlightSeverity.WARNING, "Duplicated dependency");
    }
  }
}
项目:intellij-ce-playground    文件:HighlightDisplayLevel.java   
public static void registerSeverity(@NotNull HighlightSeverity severity, @NotNull TextAttributesKey key, @Nullable Icon icon) {
  Icon severityIcon = icon != null ? icon : createIconByKey(key);
  final HighlightDisplayLevel level = ourMap.get(severity);
  if (level == null) {
    new HighlightDisplayLevel(severity, severityIcon);
  }
  else {
    level.myIcon = severityIcon;
  }
}
项目:intellij-ce-playground    文件:InspectionProfileImpl.java   
@NotNull
public Set<HighlightSeverity> getUsedSeverities() {
  LOG.assertTrue(myInitialized);
  final Set<HighlightSeverity> result = new HashSet<HighlightSeverity>();
  for (Tools tools : myTools.values()) {
    for (ScopeToolState state : tools.getTools()) {
      result.add(state.getLevel().getSeverity());
    }
  }
  return result;
}
项目:intellij-ce-playground    文件:InspectionsConfigTreeTable.java   
public SeverityAndOccurrences incOccurrences(final String toolName, final HighlightSeverity severity) {
  if (myPrimarySeverity == null) {
    myPrimarySeverity = severity;
  } else if (!Comparing.equal(severity, myPrimarySeverity)) {
    myPrimarySeverity = ScopesAndSeveritiesTable.MIXED_FAKE_SEVERITY;
  }
  myOccurrences.put(toolName, severity);
  return this;
}
项目:intellij-ce-playground    文件:ExternalAnnotatorInspectionVisitor.java   
@NotNull
private static ProblemDescriptor[] convertToProblemDescriptors(@NotNull final List<Annotation> annotations,
                                                               @NotNull final InspectionManager manager,
                                                               @NotNull final PsiFile file) {
  if (annotations.isEmpty()) {
    return ProblemDescriptor.EMPTY_ARRAY;
  }

  List<ProblemDescriptor> problems = ContainerUtil.newArrayListWithCapacity(annotations.size());
  IdentityHashMap<IntentionAction, LocalQuickFix> quickFixMappingCache = ContainerUtil.newIdentityHashMap();
  for (Annotation annotation : annotations) {
    if (annotation.getSeverity() == HighlightSeverity.INFORMATION ||
        annotation.getStartOffset() == annotation.getEndOffset()) {
      continue;
    }

    final PsiElement startElement = file.findElementAt(annotation.getStartOffset());
    final PsiElement endElement = file.findElementAt(annotation.getEndOffset() - 1);
    if (startElement == null || endElement == null) {
      continue;
    }

    LocalQuickFix[] quickFixes = toLocalQuickFixes(annotation.getQuickFixes(), quickFixMappingCache);
    ProblemDescriptor descriptor = manager.createProblemDescriptor(startElement,
                                                                   endElement,
                                                                   annotation.getMessage(),
                                                                   ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
                                                                   false,
                                                                   quickFixes);
    problems.add(descriptor);
  }
  return problems.toArray(new ProblemDescriptor[problems.size()]);
}
项目:intellij-ce-playground    文件:EditorFixture.java   
/**
 * Waits until the editor has the given number of errors at the given severity.
 * Typically used when you want to invoke an intention action, but need to wait until
 * the code analyzer has found an error it needs to resolve first.
 *
 * @param severity the severity of the issues you want to count
 * @param expected the expected count
 * @return this
 */
@NotNull
public EditorFixture waitForCodeAnalysisHighlightCount(@NotNull final HighlightSeverity severity, int expected) {
  VirtualFile currentFile = getCurrentFile();
  assertNotNull("Expected a file to be open", currentFile);
  FileFixture file = new FileFixture(myFrame.getProject(), currentFile);
  file.waitForCodeAnalysisHighlightCount(severity, expected);

  return this;
}
项目:intellij-ce-playground    文件:SeverityRenderer.java   
public static SeverityRenderer create(final InspectionProfileImpl inspectionProfile, @Nullable final Runnable onClose) {
  final SortedSet<HighlightSeverity> severities =
    LevelChooserAction.getSeverities(((SeverityProvider)inspectionProfile.getProfileManager()).getOwnSeverityRegistrar());
  return new SeverityRenderer(ContainerUtil.map2Array(severities, new SeverityState[severities.size()], new Function<HighlightSeverity, SeverityState>() {
    @Override
    public SeverityState fun(HighlightSeverity severity) {
      return new SeverityState(severity, true, false);
    }
  }), onClose);
}
项目:intellij-ce-playground    文件:ScopesAndSeveritiesTable.java   
@NotNull
public static HighlightSeverity getSeverity(final List<ScopeToolState> scopeToolStates) {
  HighlightSeverity previousValue = null;
  for (final ScopeToolState scopeToolState : scopeToolStates) {
    final HighlightSeverity currentValue = scopeToolState.getLevel().getSeverity();
    if (previousValue == null) {
      previousValue = currentValue;
    } else if (!previousValue.equals(currentValue)){
      return MIXED_FAKE_SEVERITY;
    }
  }
  return previousValue;
}
项目:intellij-ce-playground    文件:HighlightInfo.java   
@Nullable
@Override
public HighlightInfo create() {
  HighlightInfo info = createUnconditionally();
  LOG.assertTrue(psiElement != null || severity == HighlightInfoType.SYMBOL_TYPE_SEVERITY || severity == HighlightInfoType.INJECTED_FRAGMENT_SEVERITY || ArrayUtilRt.find(HighlightSeverity.DEFAULT_SEVERITIES, severity) != -1,
                 "Custom type requires not-null element to detect its text attributes");

  if (!isAcceptedByFilters(info, psiElement)) return null;

  return info;
}
项目:intellij-ce-playground    文件:HighlightInfo.java   
@NotNull
public static HighlightInfoType convertSeverity(@NotNull HighlightSeverity severity) {
  return severity == HighlightSeverity.ERROR? HighlightInfoType.ERROR :
         severity == HighlightSeverity.WARNING ? HighlightInfoType.WARNING :
         severity == HighlightSeverity.INFO ? HighlightInfoType.INFO :
         severity == HighlightSeverity.WEAK_WARNING ? HighlightInfoType.WEAK_WARNING :
         severity ==HighlightSeverity.GENERIC_SERVER_ERROR_OR_WARNING ? HighlightInfoType.GENERIC_WARNINGS_OR_ERRORS_FROM_SERVER :
         HighlightInfoType.INFORMATION;
}
项目:intellij-ce-playground    文件:SingleInspectionProfilePanel.java   
private JPopupMenu compoundPopup() {
  final DefaultActionGroup group = new DefaultActionGroup();
  final SeverityRegistrar severityRegistrar = ((SeverityProvider)mySelectedProfile.getProfileManager()).getOwnSeverityRegistrar();
  TreeSet<HighlightSeverity> severities = new TreeSet<HighlightSeverity>(severityRegistrar);
  severities.add(HighlightSeverity.ERROR);
  severities.add(HighlightSeverity.WARNING);
  severities.add(HighlightSeverity.WEAK_WARNING);
  final Collection<SeverityRegistrar.SeverityBasedTextAttributes> infoTypes =
    SeverityUtil.getRegisteredHighlightingInfoTypes(severityRegistrar);
  for (SeverityRegistrar.SeverityBasedTextAttributes info : infoTypes) {
    severities.add(info.getSeverity());
  }
  for (HighlightSeverity severity : severities) {
    final HighlightDisplayLevel level = HighlightDisplayLevel.find(severity);
    group.add(new AnAction(renderSeverity(severity), renderSeverity(severity), level.getIcon()) {
      @Override
      public void actionPerformed(@NotNull AnActionEvent e) {
        setNewHighlightingLevel(level);
      }

      @Override
      public boolean isDumbAware() {
        return true;
      }
    });
  }
  group.add(Separator.getInstance());
  ActionPopupMenu menu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.UNKNOWN, group);
  return menu.getComponent();
}
项目:intellij-ce-playground    文件:TrafficLightRenderer.java   
private void incErrorCount(RangeHighlighter highlighter, int delta) {
  Object o = highlighter.getErrorStripeTooltip();
  if (!(o instanceof HighlightInfo)) return;
  HighlightInfo info = (HighlightInfo)o;
  HighlightSeverity infoSeverity = info.getSeverity();
  final int severityIdx = mySeverityRegistrar.getSeverityIdx(infoSeverity);
  if (severityIdx != -1) {
    errorCount[severityIdx] += delta;
  }
}
项目:intellij-ce-playground    文件:ToggleHighlightingMarkupAction.java   
private static void appendTag(StringBuilder sb, HighlightInfo cur, boolean opening, final boolean compact) {
  sb.append("<");
  if (!opening) sb.append("/");
  if (cur.isAfterEndOfLine()) {
    sb.append(cur.getSeverity() == HighlightSeverity.WARNING ? "EOLWarning" : "EOLError");
  }
  else {
    sb.append(cur.getSeverity() == HighlightSeverity.WARNING ? "warning" : "error");
  }
  if (opening && !compact) {
    sb.append(" descr=\"").append(cur.getDescription()).append("\"");

  }
  sb.append(">");
}
项目:intellij-ce-playground    文件:MavenDuplicatePluginInspection.java   
@Override
public void checkFileElement(DomFileElement<MavenDomProjectModel> domFileElement,
                             DomElementAnnotationHolder holder) {
  MavenDomProjectModel projectModel = domFileElement.getRootElement();

  MultiMap<Pair<String,String>, MavenDomPlugin> duplicates = MultiMap.createSet();

  for (MavenDomPlugin plugin : projectModel.getBuild().getPlugins().getPlugins()) {
    String groupId = plugin.getGroupId().getStringValue();
    String artifactId = plugin.getArtifactId().getStringValue();

    if (StringUtil.isEmptyOrSpaces(artifactId)) continue;

    if ("".equals(groupId) || "org.apache.maven.plugins".equals(groupId) || "org.codehaus.mojo".equals(groupId)) {
      groupId = null;
    }

    duplicates.putValue(Pair.create(groupId, artifactId), plugin);
  }

  for (Map.Entry<Pair<String,String>, Collection<MavenDomPlugin>> entry : duplicates.entrySet()) {
    Collection<MavenDomPlugin> set = entry.getValue();
    if (set.size() <= 1) continue;

    for (MavenDomPlugin dependency : set) {
      holder.createProblem(dependency, HighlightSeverity.WARNING, "Duplicated plugin declaration");
    }
  }
}
项目:intellij-ce-playground    文件:RenderProblem.java   
protected Deferred(@NotNull HighlightSeverity severity,
                   @Nullable String tag,
                   @NotNull String text,
                   @Nullable Throwable throwable) {
  //noinspection AssignmentToStaticFieldFromInstanceMethod
  super(severity, ourNextOrdinal++);
  myTag = tag;
  myText = text;
  throwable(throwable);
}
项目:intellij-ce-playground    文件:HighlightInfoType.java   
@Override
@NotNull
public HighlightSeverity getSeverity(final PsiElement psiElement) {
  InspectionProfile profile = psiElement == null
                              ? (InspectionProfile)InspectionProfileManager.getInstance().getRootProfile()
                              : InspectionProjectProfileManager.getInstance(psiElement.getProject()).getInspectionProfile();
  HighlightDisplayLevel level = profile.getErrorLevel(myToolKey, psiElement);
  LOG.assertTrue(level != HighlightDisplayLevel.DO_NOT_SHOW);
  return level.getSeverity();
}
项目:intellij-ce-playground    文件:CodeAnalysisBeforeCheckinHandler.java   
private static int collectErrors(final List<CodeSmellInfo> codeSmells) {
  int result = 0;
  for (CodeSmellInfo codeSmellInfo : codeSmells) {
    if (codeSmellInfo.getSeverity() == HighlightSeverity.ERROR) result++;
  }
  return result;
}
项目:intellij-ce-playground    文件:GotoNextErrorHandler.java   
private void gotoNextError(Project project, Editor editor, PsiFile file, int caretOffset) {
  final SeverityRegistrar severityRegistrar = SeverityRegistrar.getSeverityRegistrar(project);
  DaemonCodeAnalyzerSettings settings = DaemonCodeAnalyzerSettings.getInstance();
  int maxSeverity = settings.NEXT_ERROR_ACTION_GOES_TO_ERRORS_FIRST ? severityRegistrar.getSeveritiesCount() - 1 : 0;

  for (int idx = maxSeverity; idx >= 0; idx--) {
    final HighlightSeverity minSeverity = severityRegistrar.getSeverityByIndex(idx);
    HighlightInfo infoToGo = findInfo(project, editor, caretOffset, minSeverity);
    if (infoToGo != null) {
      navigateToError(project, editor, infoToGo);
      return;
    }
  }
  showMessageWhenNoHighlights(project, file, editor);
}