Java Code Examples for com.intellij.codeInsight.daemon.HighlightDisplayKey#find()
The following examples show how to use
com.intellij.codeInsight.daemon.HighlightDisplayKey#find() .
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: HighlightInfo.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull static HighlightInfo fromAnnotation(@Nonnull Annotation annotation, boolean batchMode) { TextAttributes forcedAttributes = annotation.getEnforcedTextAttributes(); TextAttributesKey key = annotation.getTextAttributes(); TextAttributesKey forcedAttributesKey = forcedAttributes == null && key != HighlighterColors.NO_HIGHLIGHTING ? key : null; HighlightInfo info = new HighlightInfo(forcedAttributes, forcedAttributesKey, convertType(annotation), annotation.getStartOffset(), annotation.getEndOffset(), annotation.getMessage(), annotation.getTooltip(), annotation.getSeverity(), annotation.isAfterEndOfLine(), annotation.needsUpdateOnTyping(), annotation.isFileLevelAnnotation(), 0, annotation.getProblemGroup(), null, annotation.getGutterIconRenderer()); List<? extends Annotation.QuickFixInfo> fixes = batchMode ? annotation.getBatchFixes() : annotation.getQuickFixes(); if (fixes != null) { for (Annotation.QuickFixInfo quickFixInfo : fixes) { TextRange range = quickFixInfo.textRange; HighlightDisplayKey k = quickFixInfo.key != null ? quickFixInfo.key : HighlightDisplayKey.find(ANNOTATOR_INSPECTION_SHORT_NAME); info.registerFix(quickFixInfo.quickFix, null, HighlightDisplayKey.getDisplayNameByKey(k), range, k); } } return info; }
Example 2
Source File: InspectionResultsView.java From consulo with Apache License 2.0 | 6 votes |
private boolean buildTree() { InspectionProfile profile = myInspectionProfile; boolean isGroupedBySeverity = myGlobalInspectionContext.getUIOptions().GROUP_BY_SEVERITY; myGroups = new HashMap<HighlightDisplayLevel, Map<String, InspectionGroupNode>>(); final Map<String, Tools> tools = myGlobalInspectionContext.getTools(); boolean resultsFound = false; for (Tools currentTools : tools.values()) { InspectionToolWrapper defaultToolWrapper = currentTools.getDefaultState().getTool(); final HighlightDisplayKey key = HighlightDisplayKey.find(defaultToolWrapper.getShortName()); for (ScopeToolState state : currentTools.getTools()) { InspectionToolWrapper toolWrapper = state.getTool(); if (myProvider.checkReportedProblems(myGlobalInspectionContext, toolWrapper)) { addTool(toolWrapper, ((InspectionProfileImpl)profile).getErrorLevel(key, state.getScope(myProject), myProject), isGroupedBySeverity); resultsFound = true; } } } return resultsFound; }
Example 3
Source File: LightPlatformTestCase.java From consulo with Apache License 2.0 | 5 votes |
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 4
Source File: CodeInsightTestFixtureImpl.java From consulo with Apache License 2.0 | 5 votes |
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 5
Source File: InspectionTestUtil.java From consulo with Apache License 2.0 | 5 votes |
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 6
Source File: InspectionProfileImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override public void convert(@Nonnull Element element, @Nonnull Project project) { initInspectionTools(project); final Element scopes = element.getChild(DefaultProjectProfileManager.SCOPES); if (scopes == null) { return; } final List children = scopes.getChildren(SCOPE); for (Object s : children) { Element scopeElement = (Element)s; final String profile = scopeElement.getAttributeValue(DefaultProjectProfileManager.PROFILE); if (profile != null) { final InspectionProfileImpl inspectionProfile = (InspectionProfileImpl)getProfileManager().getProfile(profile); if (inspectionProfile != null) { final NamedScope scope = getProfileManager().getScopesManager().getScope(scopeElement.getAttributeValue(NAME)); if (scope != null) { for (InspectionToolWrapper toolWrapper : inspectionProfile.getInspectionTools(null)) { final HighlightDisplayKey key = HighlightDisplayKey.find(toolWrapper.getShortName()); try { InspectionToolWrapper toolWrapperCopy = copyToolSettings(toolWrapper); HighlightDisplayLevel errorLevel = inspectionProfile.getErrorLevel(key, null, project); getTools(toolWrapper.getShortName(), project).addTool(scope, toolWrapperCopy, inspectionProfile.isToolEnabled(key), errorLevel); } catch (Exception e) { LOG.error(e); } } } } } } reduceConvertedScopes(); }
Example 7
Source File: InspectionProjectProfileManager.java From consulo with Apache License 2.0 | 5 votes |
public static boolean isInformationLevel(String shortName, @Nonnull PsiElement element) { final HighlightDisplayKey key = HighlightDisplayKey.find(shortName); if (key != null) { final HighlightDisplayLevel errorLevel = getInstance(element.getProject()).getInspectionProfile().getErrorLevel(key, element); return HighlightDisplayLevel.DO_NOT_SHOW.equals(errorLevel); } return false; }
Example 8
Source File: Descriptor.java From consulo with Apache License 2.0 | 5 votes |
public Descriptor(@Nonnull ScopeToolState state, @Nonnull InspectionProfileImpl inspectionProfile, @Nonnull Project project) { myState = state; myInspectionProfile = inspectionProfile; InspectionToolWrapper tool = state.getTool(); myText = tool.getDisplayName(); final String[] groupPath = tool.getGroupPath(); myGroup = groupPath.length == 0 ? new String[]{InspectionProfileEntry.GENERAL_GROUP_NAME} : groupPath; myKey = HighlightDisplayKey.find(tool.getShortName()); myScopeName = state.getScopeName(); myScope = state.getScope(project); myLevel = inspectionProfile.getErrorLevel(myKey, myScope, project); myEnabled = inspectionProfile.isToolEnabled(myKey, myScope, project); myToolWrapper = tool; }
Example 9
Source File: InspectionResultsView.java From consulo with Apache License 2.0 | 5 votes |
@Override public void actionPerformed(AnActionEvent e) { final InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(myProject); final InspectionToolWrapper toolWrapper = myTree.getSelectedToolWrapper(); InspectionProfile inspectionProfile = myInspectionProfile; final boolean profileIsDefined = isProfileDefined(); if (!profileIsDefined) { inspectionProfile = guessProfileToSelect(profileManager); } if (toolWrapper != null) { final HighlightDisplayKey key = HighlightDisplayKey.find(toolWrapper.getShortName()); //do not search for dead code entry point tool if (key != null) { new EditInspectionToolsSettingsAction(key).editToolSettings(myProject, (InspectionProfileImpl)inspectionProfile, profileIsDefined).doWhenDone(() -> { if(profileIsDefined) { updateCurrentProfile(); } }); } } else { EditInspectionToolsSettingsAction.editToolSettings(myProject, inspectionProfile, profileIsDefined, null).doWhenDone(() -> { if (profileIsDefined) { updateCurrentProfile(); } }); } }
Example 10
Source File: LocalInspectionsPass.java From consulo with Apache License 2.0 | 5 votes |
@Nullable private HighlightInfo createHighlightInfo(@Nonnull ProblemDescriptor descriptor, @Nonnull LocalInspectionToolWrapper tool, @Nonnull HighlightInfoType level, @Nonnull Set<Pair<TextRange, String>> emptyActionRegistered, @Nonnull PsiElement element) { @NonNls String message = ProblemDescriptorUtil.renderDescriptionMessage(descriptor, element); final HighlightDisplayKey key = HighlightDisplayKey.find(tool.getShortName()); final InspectionProfile inspectionProfile = myProfileWrapper.getInspectionProfile(); if (!inspectionProfile.isToolEnabled(key, getFile())) return null; HighlightInfoType type = new HighlightInfoType.HighlightInfoTypeImpl(level.getSeverity(element), level.getAttributesKey()); final String plainMessage = message.startsWith("<html>") ? StringUtil.unescapeXml(XmlStringUtil.stripHtml(message).replaceAll("<[^>]*>", "")) : message; @NonNls final String link = " <a " + "href=\"#inspection/" + tool.getShortName() + "\"" + (UIUtil.isUnderDarcula() ? " color=\"7AB4C9\" " : "") + ">" + DaemonBundle.message("inspection.extended.description") + "</a> " + myShortcutText; @NonNls String tooltip = null; if (descriptor.showTooltip()) { tooltip = XmlStringUtil.wrapInHtml((message.startsWith("<html>") ? XmlStringUtil.stripHtml(message) : XmlStringUtil.escapeString(message)) + link); } HighlightInfo highlightInfo = highlightInfoFromDescriptor(descriptor, type, plainMessage, tooltip, element); if (highlightInfo != null) { registerQuickFixes(tool, descriptor, highlightInfo, emptyActionRegistered); } return highlightInfo; }
Example 11
Source File: LocalInspectionsPass.java From consulo with Apache License 2.0 | 5 votes |
private static void registerQuickFixes(@Nonnull LocalInspectionToolWrapper tool, @Nonnull ProblemDescriptor descriptor, @Nonnull HighlightInfo highlightInfo, @Nonnull Set<Pair<TextRange, String>> emptyActionRegistered) { final HighlightDisplayKey key = HighlightDisplayKey.find(tool.getShortName()); boolean needEmptyAction = true; final QuickFix[] fixes = descriptor.getFixes(); if (fixes != null && fixes.length > 0) { for (int k = 0; k < fixes.length; k++) { if (fixes[k] != null) { // prevent null fixes from var args QuickFixAction.registerQuickFixAction(highlightInfo, QuickFixWrapper.wrap(descriptor, k), key); needEmptyAction = false; } } } HintAction hintAction = descriptor instanceof ProblemDescriptorImpl ? ((ProblemDescriptorImpl)descriptor).getHintAction() : null; if (hintAction != null) { QuickFixAction.registerQuickFixAction(highlightInfo, hintAction, key); needEmptyAction = false; } if (((ProblemDescriptorBase)descriptor).getEnforcedTextAttributes() != null) { needEmptyAction = false; } if (needEmptyAction && emptyActionRegistered.add(Pair.create(highlightInfo.getFixTextRange(), tool.getShortName()))) { IntentionAction emptyIntentionAction = new EmptyIntentionAction(tool.getDisplayName()); QuickFixAction.registerQuickFixAction(highlightInfo, emptyIntentionAction, key); } }
Example 12
Source File: PropertySuppressableInspectionBase.java From eslint-plugin with MIT License | 4 votes |
@NotNull public SuppressQuickFix[] getBatchSuppressActions(@Nullable PsiElement element) { return new SuppressQuickFix[]{new ESLintSuppressByCommentFix(HighlightDisplayKey.find(this.getShortName()), JSInspectionSuppressor.getHolderClass(element))}; }
Example 13
Source File: InspectionProfileImpl.java From consulo with Apache License 2.0 | 4 votes |
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; }
Example 14
Source File: InspectionResultsView.java From consulo with Apache License 2.0 | 4 votes |
private void popupInvoked(Component component, int x, int y) { final TreePath path = myTree.getLeadSelectionPath(); if (path == null) return; final DefaultActionGroup actions = new DefaultActionGroup(); final ActionManager actionManager = ActionManager.getInstance(); actions.add(actionManager.getAction(IdeActions.ACTION_EDIT_SOURCE)); actions.add(actionManager.getAction(IdeActions.ACTION_FIND_USAGES)); actions.add(myIncludeAction); actions.add(myExcludeAction); actions.addSeparator(); final InspectionToolWrapper toolWrapper = myTree.getSelectedToolWrapper(); if (toolWrapper != null) { final QuickFixAction[] quickFixes = myProvider.getQuickFixes(toolWrapper, myTree); if (quickFixes != null) { for (QuickFixAction quickFixe : quickFixes) { actions.add(quickFixe); } } final HighlightDisplayKey key = HighlightDisplayKey.find(toolWrapper.getShortName()); if (key == null) return; //e.g. DummyEntryPointsTool //options actions.addSeparator(); actions.add(new EditSettingsAction()); final List<AnAction> options = new InspectionsOptionsToolbarAction(this).createActions(); for (AnAction action : options) { actions.add(action); } } actions.addSeparator(); actions.add(actionManager.getAction(IdeActions.GROUP_VERSION_CONTROLS)); final ActionPopupMenu menu = actionManager.createActionPopupMenu(ActionPlaces.CODE_INSPECTION, actions); menu.getComponent().show(component, x, y); }