Search in sources :

Example 1 with InspectionProjectProfileManager

use of com.intellij.profile.codeInspection.InspectionProjectProfileManager in project intellij-community by JetBrains.

the class EditInspectionToolsSettingsAction method invoke.

@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
    final InspectionProjectProfileManager projectProfileManager = InspectionProjectProfileManager.getInstance(file.getProject());
    InspectionProfileImpl inspectionProfile = projectProfileManager.getCurrentProfile();
    editToolSettings(project, inspectionProfile, myShortName);
}
Also used : InspectionProjectProfileManager(com.intellij.profile.codeInspection.InspectionProjectProfileManager)

Example 2 with InspectionProjectProfileManager

use of com.intellij.profile.codeInspection.InspectionProjectProfileManager in project intellij-community by JetBrains.

the class EditInspectionToolsSettingsInSuppressedPlaceIntention method getTool.

@Nullable
private InspectionToolWrapper getTool(final Project project, final PsiFile file) {
    final InspectionProjectProfileManager projectProfileManager = InspectionProjectProfileManager.getInstance(project);
    final InspectionProfileImpl inspectionProfile = projectProfileManager.getCurrentProfile();
    return inspectionProfile.getToolById(myId, file);
}
Also used : InspectionProjectProfileManager(com.intellij.profile.codeInspection.InspectionProjectProfileManager) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with InspectionProjectProfileManager

use of com.intellij.profile.codeInspection.InspectionProjectProfileManager in project scss-lint-plugin by idok.

the class ScssLintAnnotationResult method apply.

@Override
public void apply(@NotNull PsiFile file, ScssLintAnnotationResult 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;
    }
    if (annotationResult.fileLevel != null) {
        Annotation annotation = holder.createWarningAnnotation(file, annotationResult.fileLevel);
        annotation.registerFix(new EditSettingsAction(new ScssLintSettingsPage(file.getProject())));
        annotation.setFileLevelAnnotation(true);
        return;
    }
    // TODO consider adding a fix to edit configuration file
    if (annotationResult.result == null || annotationResult.result.lint == null || annotationResult.result.lint.isEmpty()) {
        return;
    }
    // String relativeFile = FileUtils.makeRelative(file.getProject(), file.getVirtualFile());
    List<Lint.Issue> issues = annotationResult.result.lint.values().iterator().next();
    if (issues == null) {
        return;
    }
    ScssLintProjectComponent component = annotationResult.input.project.getComponent(ScssLintProjectComponent.class);
    int tabSize = 4;
    for (Lint.Issue issue : issues) {
        HighlightSeverity severity = getHighlightSeverity(issue, component.treatAsWarnings);
        TextAttributes forcedTextAttributes = AnnotatorUtils.getTextAttributes(colorsScheme, severityRegistrar, severity);
        Annotation annotation = createAnnotation(holder, file, document, issue, "SCSS Lint: ", tabSize, severity, forcedTextAttributes, inspectionKey, false);
        if (annotation != null) {
            int offset = StringUtil.lineColToOffset(document.getText(), issue.line - 1, issue.column);
            PsiElement lit = PsiUtil.getElementAtOffset(file, offset);
            BaseActionFix actionFix = Fixes.getFixForRule(issue.linter, lit);
            if (actionFix != null) {
                annotation.registerFix(actionFix, null, inspectionKey);
            }
        //                annotation.registerFix(new SuppressActionFix(issue.rule, lit), null, inspectionKey);
        }
    }
}
Also used : HighlightSeverity(com.intellij.lang.annotation.HighlightSeverity) HighlightDisplayKey(com.intellij.codeInsight.daemon.HighlightDisplayKey) Lint(com.scss.utils.scssLint.Lint) ScssLintSettingsPage(com.scss.settings.ScssLintSettingsPage) Document(com.intellij.openapi.editor.Document) Annotation(com.intellij.lang.annotation.Annotation) Lint(com.scss.utils.scssLint.Lint) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) InspectionProjectProfileManager(com.intellij.profile.codeInspection.InspectionProjectProfileManager) SeverityRegistrar(com.intellij.codeInsight.daemon.impl.SeverityRegistrar) PsiElement(com.intellij.psi.PsiElement) BaseActionFix(com.scss.annotator.BaseActionFix)

Example 4 with InspectionProjectProfileManager

use of com.intellij.profile.codeInspection.InspectionProjectProfileManager in project intellij-community by JetBrains.

the class DisableInspectionToolAction method isAvailable.

@Override
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
    final InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(project);
    InspectionProfile inspectionProfile = profileManager.getCurrentProfile();
    InspectionToolWrapper toolWrapper = inspectionProfile.getInspectionTool(myToolId, project);
    return toolWrapper == null || toolWrapper.getDefaultLevel() != HighlightDisplayLevel.NON_SWITCHABLE_ERROR;
}
Also used : InspectionProfile(com.intellij.codeInspection.InspectionProfile) InspectionProjectProfileManager(com.intellij.profile.codeInspection.InspectionProjectProfileManager)

Example 5 with InspectionProjectProfileManager

use of com.intellij.profile.codeInspection.InspectionProjectProfileManager in project intellij-community by JetBrains.

the class EditInspectionToolsSettingsInSuppressedPlaceIntention method invoke.

@Override
public void invoke(@NotNull 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 = projectProfileManager.getCurrentProfile();
    EditInspectionToolsSettingsAction.editToolSettings(project, inspectionProfile, toolWrapper.getShortName());
}
Also used : InspectionProjectProfileManager(com.intellij.profile.codeInspection.InspectionProjectProfileManager)

Aggregations

InspectionProjectProfileManager (com.intellij.profile.codeInspection.InspectionProjectProfileManager)7 InspectionProfile (com.intellij.codeInspection.InspectionProfile)2 HighlightDisplayKey (com.intellij.codeInsight.daemon.HighlightDisplayKey)1 SeverityRegistrar (com.intellij.codeInsight.daemon.impl.SeverityRegistrar)1 InspectionProfileImpl (com.intellij.codeInspection.ex.InspectionProfileImpl)1 Annotation (com.intellij.lang.annotation.Annotation)1 HighlightSeverity (com.intellij.lang.annotation.HighlightSeverity)1 Document (com.intellij.openapi.editor.Document)1 EditorColorsScheme (com.intellij.openapi.editor.colors.EditorColorsScheme)1 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)1 PsiElement (com.intellij.psi.PsiElement)1 BaseActionFix (com.scss.annotator.BaseActionFix)1 ScssLintSettingsPage (com.scss.settings.ScssLintSettingsPage)1 Lint (com.scss.utils.scssLint.Lint)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1