Search in sources :

Example 6 with InspectionManager

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

the class CodeCleanupAction method runInspections.

@Override
protected void runInspections(Project project, AnalysisScope scope) {
    final InspectionProfile profile = myExternalProfile != null ? myExternalProfile : InspectionProjectProfileManager.getInstance(project).getCurrentProfile();
    final InspectionManager managerEx = InspectionManager.getInstance(project);
    final GlobalInspectionContextBase globalContext = (GlobalInspectionContextBase) managerEx.createNewGlobalContext(false);
    globalContext.codeCleanup(scope, profile, getTemplatePresentation().getText(), null, false);
}
Also used : InspectionManager(com.intellij.codeInspection.InspectionManager) InspectionProfile(com.intellij.codeInspection.InspectionProfile) GlobalInspectionContextBase(com.intellij.codeInspection.ex.GlobalInspectionContextBase)

Example 7 with InspectionManager

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

the class GlobalJavaInspectionContextImpl method performPostRunActivities.

@Override
public void performPostRunActivities(@NotNull List<InspectionToolWrapper> needRepeatSearchRequest, @NotNull final GlobalInspectionContext context) {
    JobDescriptor progress = context.getStdJobDescriptors().FIND_EXTERNAL_USAGES;
    progress.setTotalAmount(getRequestCount());
    do {
        processSearchRequests(context);
        InspectionToolWrapper[] requestors = needRepeatSearchRequest.toArray(new InspectionToolWrapper[needRepeatSearchRequest.size()]);
        InspectionManager inspectionManager = InspectionManager.getInstance(context.getProject());
        for (InspectionToolWrapper toolWrapper : requestors) {
            boolean result = false;
            if (toolWrapper instanceof GlobalInspectionToolWrapper) {
                InspectionToolPresentation presentation = ((GlobalInspectionContextImpl) context).getPresentation(toolWrapper);
                result = ((GlobalInspectionToolWrapper) toolWrapper).getTool().queryExternalUsagesRequests(inspectionManager, context, presentation);
            }
            if (!result) {
                needRepeatSearchRequest.remove(toolWrapper);
            }
        }
        int oldSearchRequestCount = progress.getTotalAmount();
        int oldDoneAmount = progress.getDoneAmount();
        int totalAmount = oldSearchRequestCount + getRequestCount();
        progress.setTotalAmount(totalAmount);
        progress.setDoneAmount(oldDoneAmount);
    } while (!needRepeatSearchRequest.isEmpty());
}
Also used : InspectionToolPresentation(com.intellij.codeInspection.ui.InspectionToolPresentation) InspectionManager(com.intellij.codeInspection.InspectionManager)

Example 8 with InspectionManager

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

the class GroovyStaticTypeCheckVisitor method registerError.

@Override
protected void registerError(@NotNull final PsiElement location, @NotNull final String description, @Nullable final LocalQuickFix[] fixes, final ProblemHighlightType highlightType) {
    if (highlightType != ProblemHighlightType.GENERIC_ERROR)
        return;
    final List<IntentionAction> intentions = ContainerUtil.newArrayList();
    if (fixes != null) {
        for (final LocalQuickFix fix : fixes) {
            intentions.add(new IntentionAction() {

                @NotNull
                @Override
                public String getText() {
                    return fix.getName();
                }

                @NotNull
                @Override
                public String getFamilyName() {
                    return fix.getFamilyName();
                }

                @Override
                public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
                    return true;
                }

                @Override
                public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
                    final InspectionManager manager = InspectionManager.getInstance(project);
                    final ProblemDescriptor descriptor = manager.createProblemDescriptor(location, description, fixes, highlightType, fixes.length == 1, false);
                    fix.applyFix(project, descriptor);
                }

                @Override
                public boolean startInWriteAction() {
                    return true;
                }
            });
        }
    }
    registerError(location, description, intentions.toArray(new IntentionAction[intentions.size()]), highlightType);
}
Also used : Project(com.intellij.openapi.project.Project) InspectionManager(com.intellij.codeInspection.InspectionManager) ProblemDescriptor(com.intellij.codeInspection.ProblemDescriptor) IntentionAction(com.intellij.codeInsight.intention.IntentionAction) LocalQuickFix(com.intellij.codeInspection.LocalQuickFix) PsiFile(com.intellij.psi.PsiFile) IncorrectOperationException(com.intellij.util.IncorrectOperationException) Editor(com.intellij.openapi.editor.Editor) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

InspectionManager (com.intellij.codeInspection.InspectionManager)8 ProblemDescriptor (com.intellij.codeInspection.ProblemDescriptor)4 NotNull (org.jetbrains.annotations.NotNull)4 LocalInspectionToolWrapper (com.intellij.codeInspection.ex.LocalInspectionToolWrapper)3 PsiFile (com.intellij.psi.PsiFile)3 GlobalInspectionContextBase (com.intellij.codeInspection.ex.GlobalInspectionContextBase)2 AnalysisScope (com.intellij.analysis.AnalysisScope)1 IntentionAction (com.intellij.codeInsight.intention.IntentionAction)1 InspectionProfile (com.intellij.codeInspection.InspectionProfile)1 LocalQuickFix (com.intellij.codeInspection.LocalQuickFix)1 InspectionProfileWrapper (com.intellij.codeInspection.ex.InspectionProfileWrapper)1 JavaDocLocalInspection (com.intellij.codeInspection.javaDoc.JavaDocLocalInspection)1 JavaDocReferenceInspection (com.intellij.codeInspection.javaDoc.JavaDocReferenceInspection)1 InspectionToolPresentation (com.intellij.codeInspection.ui.InspectionToolPresentation)1 Editor (com.intellij.openapi.editor.Editor)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 Project (com.intellij.openapi.project.Project)1 ProperTextRange (com.intellij.openapi.util.ProperTextRange)1 PsiDocComment (com.intellij.psi.javadoc.PsiDocComment)1 IncorrectOperationException (com.intellij.util.IncorrectOperationException)1