Java Code Examples for com.intellij.profile.codeInspection.InspectionProjectProfileManager#getInstance()
The following examples show how to use
com.intellij.profile.codeInspection.InspectionProjectProfileManager#getInstance() .
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: GlobalInspectionContextBase.java From consulo with Apache License 2.0 | 6 votes |
public InspectionProfile getCurrentProfile() { if (myExternalProfile != null) return myExternalProfile; InspectionManagerBase managerEx = (InspectionManagerBase)InspectionManager.getInstance(myProject); String currentProfile = managerEx.getCurrentProfile(); final InspectionProjectProfileManager inspectionProfileManager = InspectionProjectProfileManager.getInstance(myProject); Profile profile = inspectionProfileManager.getProfile(currentProfile, false); if (profile == null) { profile = InspectionProfileManager.getInstance().getProfile(currentProfile); if (profile != null) return (InspectionProfile)profile; final String[] availableProfileNames = inspectionProfileManager.getAvailableProfileNames(); if (availableProfileNames.length == 0) { //can't be return null; } profile = inspectionProfileManager.getProfile(availableProfileNames[0]); } return (InspectionProfile)profile; }
Example 2
Source File: EditInspectionToolsSettingsAction.java From consulo with Apache License 2.0 | 6 votes |
public static AsyncResult<Void> editToolSettings(final Project project, final InspectionProfile inspectionProfile, final boolean canChooseDifferentProfile, final String selectedToolShortName) { final ShowSettingsUtil settingsUtil = ShowSettingsUtil.getInstance(); final ErrorsConfigurable errorsConfigurable; if (!canChooseDifferentProfile) { errorsConfigurable = new IDEInspectionToolsConfigurable(InspectionProjectProfileManager.getInstance(project), InspectionProfileManager.getInstance()); } else { errorsConfigurable = ErrorsConfigurable.SERVICE.createConfigurable(project); } return settingsUtil.editConfigurable(project, errorsConfigurable, new Runnable() { @Override public void run() { errorsConfigurable.selectProfile(inspectionProfile); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { errorsConfigurable.selectInspectionTool(selectedToolShortName); } }); } }); }
Example 3
Source File: SassLintExternalAnnotator.java From sass-lint-plugin with MIT License | 5 votes |
@Override public void apply(@NotNull PsiFile file, ExternalLintAnnotationResult<LintResult> annotationResult, @NotNull AnnotationHolder holder) { if (annotationResult == null) { return; } InspectionProjectProfileManager inspectionProjectProfileManager = InspectionProjectProfileManager.getInstance(file.getProject()); SeverityRegistrar severityRegistrar = inspectionProjectProfileManager.getSeverityRegistrar(); // HighlightDisplayKey inspectionKey = getHighlightDisplayKeyByClass(); // HighlightSeverity severity = InspectionUtil.getSeverity(inspectionProjectProfileManager, inspectionKey, file); EditorColorsScheme colorsScheme = annotationResult.input.colorsScheme; Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file); if (document == null) { return; } SassLintProjectComponent component = annotationResult.input.project.getComponent(SassLintProjectComponent.class); for (SassLint.Issue warn : annotationResult.result.sassLint.file.errors) { HighlightSeverity severity = getHighlightSeverity(warn, component.treatAsWarnings); TextAttributes forcedTextAttributes = InspectionUtil.getTextAttributes(colorsScheme, severityRegistrar, severity); Annotation annotation = createAnnotation(holder, file, document, warn, severity, forcedTextAttributes, false); // if (annotation != null) { // int offset = StringUtil.lineColToOffset(document.getText(), warn.line - 1, warn.column); // PsiElement lit = PsiUtil.getElementAtOffset(file, offset); // BaseActionFix actionFix = Fixes.getFixForRule(warn.rule, lit); // if (actionFix != null) { // annotation.registerFix(actionFix, null, inspectionKey); // } // annotation.registerFix(new SuppressActionFix(warn.rule, lit), null, inspectionKey); // } } }
Example 4
Source File: ESLintExternalAnnotator.java From eslint-plugin with MIT License | 5 votes |
@Override public void apply(@NotNull PsiFile file, ExternalLintAnnotationResult<Result> annotationResult, @NotNull AnnotationHolder holder) { if (annotationResult == null) { return; } InspectionProjectProfileManager inspectionProjectProfileManager = InspectionProjectProfileManager.getInstance(file.getProject()); SeverityRegistrar severityRegistrar = inspectionProjectProfileManager.getSeverityRegistrar(); HighlightDisplayKey inspectionKey = getHighlightDisplayKeyByClass(); EditorColorsScheme colorsScheme = annotationResult.input.colorsScheme; Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file); if (document == null) { return; } ESLintProjectComponent component = annotationResult.input.project.getComponent(ESLintProjectComponent.class); for (VerifyMessage warn : annotationResult.result.warns) { HighlightSeverity severity = getHighlightSeverity(warn, component.treatAsWarnings); TextAttributes forcedTextAttributes = JSLinterUtil.getTextAttributes(colorsScheme, severityRegistrar, severity); Annotation annotation = createAnnotation(holder, file, document, warn, severity, forcedTextAttributes, false); if (annotation != null) { int offset = StringUtil.lineColToOffset(document.getText(), warn.line - 1, warn.column); PsiElement lit = PsiUtil.getElementAtOffset(file, offset); BaseActionFix actionFix = Fixes.getFixForRule(warn.ruleId, lit); if (actionFix != null) { annotation.registerFix(actionFix, null, inspectionKey); } annotation.registerFix(new SuppressActionFix(warn.ruleId, lit), null, inspectionKey); annotation.registerFix(new SuppressLineActionFix(warn.ruleId, lit), null, inspectionKey); } } }
Example 5
Source File: InspectionManagerBase.java From consulo with Apache License 2.0 | 5 votes |
public String getCurrentProfile() { if (myCurrentProfileName == null) { final InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(getProject()); myCurrentProfileName = profileManager.getProjectProfile(); if (myCurrentProfileName == null) { myCurrentProfileName = InspectionProfileManager.getInstance().getRootProfile().getName(); } } return myCurrentProfileName; }
Example 6
Source File: EditInspectionToolsSettingsInSuppressedPlaceIntention.java From consulo with Apache License 2.0 | 5 votes |
@Override public void invoke(@Nonnull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { InspectionToolWrapper toolWrapper = getTool(project, file); if (toolWrapper == null) return; final InspectionProjectProfileManager projectProfileManager = InspectionProjectProfileManager.getInstance(project); final InspectionProfileImpl inspectionProfile = (InspectionProfileImpl)projectProfileManager.getInspectionProfile(); EditInspectionToolsSettingsAction.editToolSettings(project, inspectionProfile, false, toolWrapper.getShortName()); }
Example 7
Source File: DisableInspectionToolAction.java From consulo with Apache License 2.0 | 5 votes |
@Override public void invoke(@Nonnull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { final InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(file.getProject()); InspectionProfile inspectionProfile = profileManager.getInspectionProfile(); ModifiableModel model = inspectionProfile.getModifiableModel(); model.disableTool(myToolId, file); try { model.commit(); } catch (IOException e) { Messages.showErrorDialog(project, e.getMessage(), CommonBundle.getErrorTitle()); } DaemonCodeAnalyzer.getInstance(project).restart(); }
Example 8
Source File: EditInspectionToolsSettingsAction.java From consulo with Apache License 2.0 | 5 votes |
@Override public void invoke(@Nonnull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { final InspectionProjectProfileManager projectProfileManager = InspectionProjectProfileManager.getInstance(file.getProject()); InspectionProfile inspectionProfile = projectProfileManager.getInspectionProfile(); editToolSettings(project, inspectionProfile, true, myShortName); }
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: EditCleanupProfileIntentionAction.java From consulo with Apache License 2.0 | 5 votes |
@Override public void invoke(@Nonnull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { final InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(project); final ProjectInspectionToolsConfigurable configurable = new ProjectInspectionToolsConfigurable(InspectionProfileManager.getInstance(), profileManager) { @Override protected boolean acceptTool(InspectionToolWrapper entry) { return super.acceptTool(entry) && entry.isCleanupTool(); } }; ShowSettingsUtil.getInstance().editConfigurable(CodeCleanupAction.CODE_CLEANUP_INSPECTIONS_DISPLAY_NAME, project, configurable); }
Example 11
Source File: EditInspectionToolsSettingsInSuppressedPlaceIntention.java From consulo with Apache License 2.0 | 4 votes |
@Nullable private InspectionToolWrapper getTool(final Project project, final PsiFile file) { final InspectionProjectProfileManager projectProfileManager = InspectionProjectProfileManager.getInstance(project); final InspectionProfileImpl inspectionProfile = (InspectionProfileImpl)projectProfileManager.getInspectionProfile(); return inspectionProfile.getToolById(myId, file); }