com.intellij.profile.codeInspection.InspectionProjectProfileManager Java Examples

The following examples show how to use com.intellij.profile.codeInspection.InspectionProjectProfileManager. 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: LocalInspectionToolWrapper.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static InspectionToolWrapper findTool2RunInBatch(@Nonnull Project project, @Nullable PsiElement element, @Nonnull String name) {
  final InspectionProfile inspectionProfile = InspectionProjectProfileManager.getInstance(project).getInspectionProfile();
  final InspectionToolWrapper toolWrapper = element == null
                                            ? inspectionProfile.getInspectionTool(name, project)
                                            : inspectionProfile.getInspectionTool(name, element);
  if (toolWrapper instanceof LocalInspectionToolWrapper && ((LocalInspectionToolWrapper)toolWrapper).isUnfair()) {
    final LocalInspectionTool inspectionTool = ((LocalInspectionToolWrapper)toolWrapper).getTool();
    if (inspectionTool instanceof PairedUnfairLocalInspectionTool) {
      final String oppositeShortName = ((PairedUnfairLocalInspectionTool)inspectionTool).getInspectionForBatchShortName();
      return element == null
             ? inspectionProfile.getInspectionTool(oppositeShortName, project)
             : inspectionProfile.getInspectionTool(oppositeShortName, element);
    }
    return null;
  }
  return toolWrapper;
}
 
Example #2
Source File: GlobalInspectionContextBase.java    From consulo with Apache License 2.0 6 votes vote down vote up
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 #3
Source File: InspectionResultsView.java    From consulo with Apache License 2.0 6 votes vote down vote up
private InspectionProfile guessProfileToSelect(final InspectionProjectProfileManager profileManager) {
  final Set<InspectionProfile> profiles = new HashSet<InspectionProfile>();
  final RefEntity[] selectedElements = myTree.getSelectedElements();
  for (RefEntity selectedElement : selectedElements) {
    if (selectedElement instanceof RefElement) {
      final RefElement refElement = (RefElement)selectedElement;
      final PsiElement element = refElement.getElement();
      if (element != null) {
        profiles.add(profileManager.getInspectionProfile());
      }
    }
  }
  if (profiles.isEmpty()) {
    return (InspectionProfile)profileManager.getProjectProfileImpl();
  }
  return profiles.iterator().next();
}
 
Example #4
Source File: DefaultInspectionToolPresentation.java    From consulo with Apache License 2.0 6 votes vote down vote up
protected HighlightSeverity getSeverity(@Nonnull 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;
}
 
Example #5
Source File: EditInspectionToolsSettingsAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
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 #6
Source File: ESLintExternalAnnotator.java    From eslint-plugin with MIT License 5 votes vote down vote up
@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 #7
Source File: SingleInspectionProfilePanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
public SingleInspectionProfilePanel(@Nonnull InspectionProjectProfileManager projectProfileManager,
                                    @Nonnull String inspectionProfileName,
                                    @Nonnull ModifiableModel profile) {
  super(new BorderLayout());
  myProjectProfileManager = projectProfileManager;
  mySelectedProfile = (InspectionProfileImpl)profile;
  myCurrentProfileName = inspectionProfileName;
  myShareProfile = profile.getProfileManager() == projectProfileManager;
}
 
Example #8
Source File: TogglePopupHintsPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void updateStatus(PsiFile file) {
  if (isDisposed()) return;
  if (isStateChangeable(file)) {
    if (PowerSaveMode.isEnabled()) {
      myCurrentIcon = ImageEffects.grayed(AllIcons.Ide.HectorOff);
      myToolTipText = "Code analysis is disabled in power save mode.\n";
    }
    else if (HighlightingLevelManager.getInstance(getProject()).shouldInspect(file)) {
      myCurrentIcon = AllIcons.Ide.HectorOn;
      InspectionProfileImpl profile = InspectionProjectProfileManager.getInstance(file.getProject()).getCurrentProfile();
      if (profile.wasInitialized()) myToolTipText = "Current inspection profile: " + profile.getName() + ".\n";
    }
    else if (HighlightingLevelManager.getInstance(getProject()).shouldHighlight(file)) {
      myCurrentIcon = AllIcons.Ide.HectorSyntax;
      myToolTipText = "Highlighting level is: Syntax.\n";
    }
    else {
      myCurrentIcon = AllIcons.Ide.HectorOff;
      myToolTipText = "Inspections are off.\n";
    }
    myToolTipText += UIBundle.message("popup.hints.panel.click.to.configure.highlighting.tooltip.text");
  }
  else {
    myCurrentIcon = file != null ? ImageEffects.grayed(AllIcons.Ide.HectorOff) : null;
    myToolTipText = null;
  }

  if (!ApplicationManager.getApplication().isUnitTestMode() && myStatusBar != null) {
    myStatusBar.updateWidget(ID());
  }
}
 
Example #9
Source File: LocalInspectionsPass.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void addHighlightsFromResults(@Nonnull List<HighlightInfo> outInfos, @Nonnull ProgressIndicator indicator) {
  InspectionProfile inspectionProfile = InspectionProjectProfileManager.getInstance(myProject).getInspectionProfile();
  PsiDocumentManager documentManager = PsiDocumentManager.getInstance(myProject);
  InjectedLanguageManager ilManager = InjectedLanguageManager.getInstance(myProject);
  Set<Pair<TextRange, String>> emptyActionRegistered = new THashSet<>();

  for (Map.Entry<PsiFile, List<InspectionResult>> entry : result.entrySet()) {
    indicator.checkCanceled();
    PsiFile file = entry.getKey();
    Document documentRange = documentManager.getDocument(file);
    if (documentRange == null) continue;
    List<InspectionResult> resultList = entry.getValue();
    synchronized (resultList) {
      for (InspectionResult inspectionResult : resultList) {
        indicator.checkCanceled();
        LocalInspectionToolWrapper tool = inspectionResult.tool;
        HighlightSeverity severity = inspectionProfile.getErrorLevel(HighlightDisplayKey.find(tool.getShortName()), file).getSeverity();
        for (ProblemDescriptor descriptor : inspectionResult.foundProblems) {
          indicator.checkCanceled();
          PsiElement element = descriptor.getPsiElement();
          if (element != null) {
            createHighlightsForDescriptor(outInfos, emptyActionRegistered, ilManager, file, documentRange, tool, severity, descriptor, element);
          }
        }
      }
    }
  }
}
 
Example #10
Source File: EditCleanupProfileIntentionAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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: LocalInspectionsPassFactory.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nullable
public TextEditorHighlightingPass createHighlightingPass(@Nonnull PsiFile file, @Nonnull final Editor editor) {
  TextRange textRange = calculateRangeToProcess(editor);
  if (textRange == null || !InspectionProjectProfileManager.getInstance(file.getProject()).isProfileLoaded()){
    return new ProgressableTextEditorHighlightingPass.EmptyPass(file.getProject(), editor.getDocument());
  }
  TextRange visibleRange = VisibleHighlightingPassFactory.calculateVisibleRange(editor);
  return new MyLocalInspectionsPass(file, editor.getDocument(), textRange, visibleRange, new DefaultHighlightInfoProcessor());
}
 
Example #12
Source File: InspectionResultsView.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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 #13
Source File: CodeInspectionOnEditorAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected static void analyze(Project project, PsiFile psiFile) {
  FileDocumentManager.getInstance().saveAllDocuments();
  final InspectionManagerEx inspectionManagerEx = (InspectionManagerEx)InspectionManager.getInstance(project);
  final AnalysisScope scope = new AnalysisScope(psiFile);
  final GlobalInspectionContextImpl inspectionContext = inspectionManagerEx.createNewGlobalContext(false);
  inspectionContext.setCurrentScope(scope);
  final InspectionProfile inspectionProfile =
    InspectionProjectProfileManager.getInstance(project).getInspectionProfile();
  inspectionContext.setExternalProfile(inspectionProfile);
  inspectionContext.doInspections(scope);
}
 
Example #14
Source File: CodeCleanupAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected IDEInspectionToolsConfigurable createConfigurable(InspectionProjectProfileManager projectProfileManager,
                                                            InspectionProfileManager profileManager) {
  return new IDEInspectionToolsConfigurable(projectProfileManager, profileManager) {
    @Override
    protected boolean acceptTool(InspectionToolWrapper entry) {
      return super.acceptTool(entry) && entry.isCleanupTool();
    }

    @Override
    public String getDisplayName() {
      return CODE_CLEANUP_INSPECTIONS_DISPLAY_NAME;
    }
  };
}
 
Example #15
Source File: CodeCleanupAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void runInspections(Project project, AnalysisScope scope) {
  final InspectionProfile profile = myExternalProfile != null ? myExternalProfile : InspectionProjectProfileManager.getInstance(project).getInspectionProfile();
  final InspectionManager managerEx = InspectionManager.getInstance(project);
  final GlobalInspectionContextBase globalContext = (GlobalInspectionContextBase)managerEx.createNewGlobalContext(false);
  globalContext.codeCleanup(project, scope, profile, getTemplatePresentation().getText(), null, false);
}
 
Example #16
Source File: CodeInspectionAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void reloadProfiles(JComboBox profiles,
                            InspectionProfileManager inspectionProfileManager,
                            InspectionProjectProfileManager inspectionProjectProfileManager,
                            InspectionManagerEx inspectionManager) {
  final InspectionProfile selectedProfile = getGlobalInspectionContext(inspectionManager.getProject()).getCurrentProfile();
  final DefaultComboBoxModel model = (DefaultComboBoxModel)profiles.getModel();
  model.removeAllElements();
  fillModel(inspectionProfileManager, model);
  fillModel(inspectionProjectProfileManager, model);
  profiles.setSelectedItem(selectedProfile);
}
 
Example #17
Source File: EditInspectionToolsSettingsAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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 #18
Source File: SassLintExternalAnnotator.java    From sass-lint-plugin with MIT License 5 votes vote down vote up
@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 #19
Source File: InspectionManagerBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
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 #20
Source File: CleanupIntention.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void invoke(@Nonnull final Project project, final Editor editor, final PsiFile file) throws IncorrectOperationException {
  if (!FileModificationService.getInstance().preparePsiElementForWrite(file)) return;
  final InspectionManager managerEx = InspectionManager.getInstance(project);
  final GlobalInspectionContextBase globalContext = (GlobalInspectionContextBase)managerEx.createNewGlobalContext(false);
  final AnalysisScope scope = getScope(project, file);
  if (scope != null) {
    final InspectionProfile profile = InspectionProjectProfileManager.getInstance(project).getInspectionProfile();
    globalContext.codeCleanup(project, scope, profile, getText(), null, false);
  }
}
 
Example #21
Source File: HighlightInfo.java    From consulo with Apache License 2.0 5 votes vote down vote up
boolean canCleanup(@Nonnull PsiElement element) {
  if (myCanCleanup == null) {
    InspectionProfile profile = InspectionProjectProfileManager.getInstance(element.getProject()).getCurrentProfile();
    HighlightDisplayKey key = myKey;
    if (key == null) {
      myCanCleanup = false;
    }
    else {
      InspectionToolWrapper toolWrapper = profile.getInspectionTool(key.toString(), element);
      myCanCleanup = toolWrapper != null && toolWrapper.isCleanupTool();
    }
  }
  return myCanCleanup;
}
 
Example #22
Source File: HighlightInfoType.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nonnull
public HighlightSeverity getSeverity(final PsiElement psiElement) {
  InspectionProfile profile = psiElement == null
                              ? (InspectionProfile)InspectionProfileManager.getInstance().getRootProfile()
                              : InspectionProjectProfileManager.getInstance(psiElement.getProject()).getInspectionProfile();
  return profile.getErrorLevel(myToolKey, psiElement).getSeverity();
}
 
Example #23
Source File: EditInspectionToolsSettingsInSuppressedPlaceIntention.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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 #24
Source File: DisableInspectionToolAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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 #25
Source File: SeverityRegistrar.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public static SeverityRegistrar getSeverityRegistrar(@Nullable Project project) {
  return project == null
         ? InspectionProfileManager.getInstance().getSeverityRegistrar()
         : InspectionProjectProfileManager.getInstance(project).getSeverityRegistrar();
}
 
Example #26
Source File: EditInspectionToolsSettingsInSuppressedPlaceIntention.java    From consulo with Apache License 2.0 4 votes vote down vote up
@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);
}
 
Example #27
Source File: ViewOfflineResultsAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings({"WeakerAccess", "UnusedReturnValue"}) //used in TeamCity
public static InspectionResultsView showOfflineView(@Nonnull Project project,
                                                    @Nullable
                                                    final String profileName,
                                                    @Nonnull final Map<String, Map<String, Set<OfflineProblemDescriptor>>> resMap,
                                                    @Nonnull String title) {
  Profile profile;
  if (profileName != null) {
    profile = InspectionProjectProfileManager.getInstance(project).getProfile(profileName, false);
    if (profile == null) {
      profile = InspectionProfileManager.getInstance().getProfile(profileName, false);
    }
  }
  else {
    profile = null;
  }
  final InspectionProfile inspectionProfile;
  if (profile != null) {
    inspectionProfile = (InspectionProfile)profile;
  }
  else {
    inspectionProfile = new InspectionProfileImpl(profileName != null ? profileName : "Server Side") {
      @Override
      public boolean isToolEnabled(final HighlightDisplayKey key, PsiElement element) {
        return resMap.containsKey(key.toString());
      }

      @Override
      public HighlightDisplayLevel getErrorLevel(@Nonnull final HighlightDisplayKey key, PsiElement element) {
        return ((InspectionProfile)InspectionProfileManager.getInstance().getRootProfile()).getErrorLevel(key, element);
      }

      @Override
      public boolean isEditable() {
        return false;
      }

      @Nonnull
      @Override
      public String getDisplayName() {
        return getName();
      }
    };
  }
  return showOfflineView(project, resMap, inspectionProfile, title);
}
 
Example #28
Source File: GlobalInspectionContextBase.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static void codeCleanup(@Nonnull Project project, @Nonnull AnalysisScope scope, @Nullable Runnable runnable) {
  GlobalInspectionContextBase globalContext = (GlobalInspectionContextBase)InspectionManager.getInstance(project).createNewGlobalContext(false);
  final InspectionProfile profile = InspectionProjectProfileManager.getInstance(project).getInspectionProfile();
  globalContext.codeCleanup(project, scope, profile, null, runnable, false);
}
 
Example #29
Source File: CodeInspectionAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected IDEInspectionToolsConfigurable createConfigurable(InspectionProjectProfileManager projectProfileManager,
                                                            InspectionProfileManager profileManager) {
  return new IDEInspectionToolsConfigurable(projectProfileManager, profileManager);
}
 
Example #30
Source File: ProjectInspectionToolsConfigurableProvider.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Inject
public ProjectInspectionToolsConfigurableProvider(InspectionProfileManager profileManager,
                                                  InspectionProjectProfileManager projectProfileManager) {
  myProfileManager = profileManager;
  myProjectProfileManager = projectProfileManager;
}