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);
}
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());
}
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);
}
Aggregations