Java Code Examples for com.intellij.codeInsight.daemon.HighlightDisplayKey#register()

The following examples show how to use com.intellij.codeInsight.daemon.HighlightDisplayKey#register() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LightPlatformTestCase.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static void enableInspectionTool(@Nonnull Map<String, InspectionToolWrapper> availableLocalTools, @Nonnull InspectionToolWrapper toolWrapper) {
  final String shortName = toolWrapper.getShortName();
  final HighlightDisplayKey key = HighlightDisplayKey.find(shortName);
  if (key == null) {
    String id = toolWrapper instanceof LocalInspectionToolWrapper ? ((LocalInspectionToolWrapper)toolWrapper).getTool().getID() : toolWrapper.getShortName();
    HighlightDisplayKey.register(shortName, toolWrapper.getDisplayName(), id);
  }
  availableLocalTools.put(shortName, toolWrapper);
}
 
Example 2
Source File: CodeInsightTestFixtureImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void enableInspectionTool(@Nonnull InspectionProfileEntry tool) {
  InspectionToolWrapper toolWrapper = InspectionToolRegistrar.wrapTool(tool);
  final String shortName = tool.getShortName();
  final HighlightDisplayKey key = HighlightDisplayKey.find(shortName);

  if (key == null) {
    String id = tool instanceof LocalInspectionTool ? ((LocalInspectionTool)tool).getID() : shortName;
    HighlightDisplayKey.register(shortName, toolWrapper.getDisplayName(), id);
  }
  myAvailableTools.put(shortName, toolWrapper);
}
 
Example 3
Source File: InspectionTestUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static void runTool(@Nonnull InspectionToolWrapper toolWrapper,
                           @Nonnull final AnalysisScope scope,
                           @Nonnull final GlobalInspectionContextImpl globalContext,
                           @Nonnull final InspectionManagerEx inspectionManager) {
  final String shortName = toolWrapper.getShortName();
  final HighlightDisplayKey key = HighlightDisplayKey.find(shortName);
  if (key == null){
    HighlightDisplayKey.register(shortName);
  }

  globalContext.doInspections(scope);
}
 
Example 4
Source File: InspectionProfileImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
private boolean initialize(@Nullable Project project) {
  if (myBaseProfile != null) {
    myBaseProfile.initInspectionTools(project);
  }

  final List<InspectionToolWrapper> tools;
  try {
    tools = createTools(project);
  }
  catch (ProcessCanceledException ignored) {
    return false;
  }
  final Map<String, List<String>> dependencies = new HashMap<String, List<String>>();
  for (InspectionToolWrapper toolWrapper : tools) {
    final String shortName = toolWrapper.getShortName();
    HighlightDisplayKey key = HighlightDisplayKey.find(shortName);
    if (key == null) {
      final InspectionEP extension = toolWrapper.getExtension();
      Computable<String> computable = extension == null ? new Computable.PredefinedValueComputable<String>(toolWrapper.getDisplayName()) : new Computable<String>() {
        @Override
        public String compute() {
          return extension.getDisplayName();
        }
      };
      if (toolWrapper instanceof LocalInspectionToolWrapper) {
        key = HighlightDisplayKey.register(shortName, computable, ((LocalInspectionToolWrapper)toolWrapper).getID(),
                                           ((LocalInspectionToolWrapper)toolWrapper).getAlternativeID());
      }
      else {
        key = HighlightDisplayKey.register(shortName, computable);
      }
    }

    LOG.assertTrue(key != null, shortName + " ; number of initialized tools: " + myTools.size());
    HighlightDisplayLevel level = myBaseProfile != null ? myBaseProfile.getErrorLevel(key, project) : toolWrapper.getDefaultLevel();
    boolean enabled = myBaseProfile != null ? myBaseProfile.isToolEnabled(key) : toolWrapper.isEnabledByDefault();
    final ToolsImpl toolsList = new ToolsImpl(toolWrapper, level, !myLockedProfile && enabled, enabled);
    final Element element = myUninstalledInspectionsSettings.remove(shortName);
    try {
      if (element != null) {
        toolsList.readExternal(element, this, dependencies);
      }
      else if (!myUninstalledInspectionsSettings.containsKey(InspectionElementsMerger.getMergedMarkerName(shortName))) {
        final InspectionElementsMerger merger = getMergers().get(shortName);
        if (merger != null) {
          final Element merged = merger.merge(myUninstalledInspectionsSettings);
          if (merged != null) {
            toolsList.readExternal(merged, this, dependencies);
          }
        }
      }
    }
    catch (InvalidDataException e) {
      LOG.error("Can't read settings for " + toolWrapper, e);
    }
    myTools.put(toolWrapper.getShortName(), toolsList);
  }
  final GraphGenerator<String> graphGenerator = GraphGenerator.create(CachingSemiGraph.create(new GraphGenerator.SemiGraph<String>() {
    @Override
    public Collection<String> getNodes() {
      return dependencies.keySet();
    }

    @Override
    public Iterator<String> getIn(String n) {
      return dependencies.get(n).iterator();
    }
  }));

  DFSTBuilder<String> builder = new DFSTBuilder<String>(graphGenerator);
  if (builder.isAcyclic()) {
    final List<String> scopes = builder.getSortedNodes();
    myScopesOrder = ArrayUtil.toStringArray(scopes);
  }

  if (mySource != null) {
    copyToolsConfigurations(mySource, project);
  }
  return true;
}