}
}
- public void codeCleanup(@NotNull Project project,
- @NotNull AnalysisScope scope,
+ public void codeCleanup(@NotNull AnalysisScope scope,
@NotNull InspectionProfile profile,
@Nullable String commandName,
@Nullable Runnable postRunnable,
public static void codeCleanup(@NotNull Project project, @NotNull 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);
+ globalContext.codeCleanup(scope, profile, null, runnable, false);
}
public static void cleanupElements(@NotNull final Project project, @Nullable final Runnable runnable, @NotNull PsiElement... scope) {
GlobalInspectionContextBase globalContext = (GlobalInspectionContextBase)InspectionManager.getInstance(project).createNewGlobalContext(false);
final InspectionProfile profile = InspectionProjectProfileManager.getInstance(project).getInspectionProfile();
AnalysisScope analysisScope = new AnalysisScope(new LocalSearchScope(psiElements.toArray(new PsiElement[psiElements.size()])), project);
- globalContext.codeCleanup(project, analysisScope, profile, null, runnable, true);
+ globalContext.codeCleanup(analysisScope, profile, null, runnable, true);
};
Application application = ApplicationManager.getApplication();
public static void rerunInspection(@NotNull InspectionToolWrapper toolWrapper,
@NotNull InspectionManagerEx managerEx,
@NotNull AnalysisScope scope,
- PsiElement psiElement) {
+ @Nullable PsiElement psiElement) {
GlobalInspectionContextImpl inspectionContext = createContext(toolWrapper, managerEx, psiElement);
inspectionContext.doInspections(scope);
}
public static GlobalInspectionContextImpl createContext(@NotNull InspectionToolWrapper toolWrapper,
@NotNull InspectionManagerEx managerEx,
- PsiElement psiElement) {
+ @Nullable PsiElement psiElement) {
final InspectionProfileImpl rootProfile = (InspectionProfileImpl)InspectionProfileManager.getInstance().getRootProfile();
LinkedHashSet<InspectionToolWrapper> allWrappers = new LinkedHashSet<InspectionToolWrapper>();
allWrappers.add(toolWrapper);
}
@Override
- public void codeCleanup(@NotNull final Project project,
- @NotNull final AnalysisScope scope,
+ public void codeCleanup(@NotNull final AnalysisScope scope,
@NotNull final InspectionProfile profile,
@Nullable final String commandName,
@Nullable final Runnable postRunnable,
final boolean modal) {
- Task task = modal ? new Task.Modal(project, "Inspect code...", true) {
+ Task task = modal ? new Task.Modal(getProject(), "Inspect code...", true) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
- cleanup(scope, profile, project, postRunnable, commandName);
+ cleanup(scope, profile, postRunnable, commandName);
}
- } : new Task.Backgroundable(project, "Inspect code...", true) {
+ } : new Task.Backgroundable(getProject(), "Inspect code...", true) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
- cleanup(scope, profile, project, postRunnable, commandName);
+ cleanup(scope, profile, postRunnable, commandName);
}
};
ProgressManager.getInstance().run(task);
private void cleanup(@NotNull final AnalysisScope scope,
@NotNull InspectionProfile profile,
- @NotNull final Project project,
@Nullable final Runnable postRunnable,
@Nullable final String commandName) {
setCurrentScope(scope);
else {
range = null;
}
- final Iterable<Tools> inspectionTools = ContainerUtil.filter(profile.getAllEnabledInspectionTools(project), tools -> {
+ final Iterable<Tools> inspectionTools = ContainerUtil.filter(profile.getAllEnabledInspectionTools(getProject()), tools -> {
assert tools != null;
return tools.getTool().getTool() instanceof CleanupLocalInspectionTool;
});
}
if (!lTools.isEmpty()) {
- final LocalInspectionsPass pass = new LocalInspectionsPass(file, PsiDocumentManager.getInstance(project).getDocument(file), range != null ? range.getStartOffset() : 0,
+ final LocalInspectionsPass pass = new LocalInspectionsPass(file, PsiDocumentManager.getInstance(getProject()).getDocument(file), range != null ? range.getStartOffset() : 0,
range != null ? range.getEndOffset() : file.getTextLength(), LocalInspectionsPass.EMPTY_PRIORITY_RANGE, true,
HighlightInfoProcessor.getEmpty());
- Runnable runnable = () -> pass.doInspectInBatch(GlobalInspectionContextImpl.this, InspectionManager.getInstance(project), lTools);
+ Runnable runnable = () -> pass.doInspectInBatch(GlobalInspectionContextImpl.this, InspectionManager.getInstance(getProject()), lTools);
ApplicationManager.getApplication().runReadAction(runnable);
final List<HighlightInfo> infos = pass.getInfos();
if (searchScope instanceof LocalSearchScope) {
if (!FileModificationService.getInstance().preparePsiElementsForWrite(results.keySet())) return;
final String title = "Code Cleanup";
- final SequentialModalProgressTask progressTask = new SequentialModalProgressTask(project, title, true);
+ final SequentialModalProgressTask progressTask = new SequentialModalProgressTask(getProject(), title, true);
progressTask.setMinIterationTime(200);
- progressTask.setTask(new SequentialCleanupTask(project, results, progressTask));
- CommandProcessor.getInstance().executeCommand(project, () -> {
+ progressTask.setTask(new SequentialCleanupTask(getProject(), results, progressTask));
+ CommandProcessor.getInstance().executeCommand(getProject(), () -> {
if (commandName != null) {
- CommandProcessor.getInstance().markCurrentCommandAsGlobal(project);
+ CommandProcessor.getInstance().markCurrentCommandAsGlobal(getProject());
}
ProgressManager.getInstance().run(progressTask);
if (postRunnable != null) {
}
}, title, null);
};
- TransactionGuard.submitTransaction(project, runnable);
+ TransactionGuard.submitTransaction(getProject(), runnable);
}
private static boolean isBinary(@NotNull PsiFile file) {