mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
[codeInsight] Add inspection profile choice in cleanupElements
#IJPL-60378 GitOrigin-RevId: 2cb258f986e9af02d13b8788a169f1b448990a52
This commit is contained in:
committed by
intellij-monorepo-bot
parent
9a8ea2afa5
commit
ddf360b575
@@ -2621,6 +2621,7 @@ c:com.intellij.codeInspection.ex.GlobalInspectionContextBase
|
||||
- p:canceled():V
|
||||
- p:classifyTool(java.util.List,java.util.List,java.util.List,com.intellij.codeInspection.ex.Tools,com.intellij.codeInspection.ex.InspectionToolWrapper):V
|
||||
- cleanup():V
|
||||
- s:cleanupElements(com.intellij.openapi.project.Project,java.lang.Runnable,java.util.function.Predicate,com.intellij.codeInspection.InspectionProfile,com.intellij.psi.PsiElement[]):V
|
||||
- s:cleanupElements(com.intellij.openapi.project.Project,java.lang.Runnable,java.util.function.Predicate,com.intellij.psi.PsiElement[]):V
|
||||
- s:cleanupElements(com.intellij.openapi.project.Project,java.lang.Runnable,com.intellij.psi.PsiElement[]):V
|
||||
- close(Z):V
|
||||
|
||||
@@ -465,6 +465,28 @@ public class GlobalInspectionContextBase extends UserDataHolderBase implements G
|
||||
cleanupElements(project, runnable, Predicates.alwaysTrue(), scope);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs code cleanup on the specified scope with the specified profile
|
||||
*
|
||||
* @param project project from which to use the inspection profile
|
||||
* @param runnable will be run after completion of the cleanup
|
||||
* @param shouldApplyFix predicate to filter out fixes
|
||||
* @param profile inspection profile to use
|
||||
* @param scope the elements to clean up
|
||||
*/
|
||||
public static void cleanupElements(@NotNull Project project,
|
||||
@Nullable Runnable runnable,
|
||||
Predicate<? super ProblemDescriptor> shouldApplyFix,
|
||||
@NotNull InspectionProfile profile,
|
||||
PsiElement @NotNull ... scope) {
|
||||
List<PsiElement> psiElements = Stream.of(scope).filter(e -> e != null && e.isPhysical()).toList();
|
||||
if (psiElements.isEmpty()) return;
|
||||
GlobalInspectionContextBase globalContext =
|
||||
(GlobalInspectionContextBase)InspectionManager.getInstance(project).createNewGlobalContext();
|
||||
AnalysisScope analysisScope = new AnalysisScope(new LocalSearchScope(psiElements.toArray(PsiElement.EMPTY_ARRAY)), project);
|
||||
globalContext.codeCleanup(analysisScope, profile, null, runnable, false, shouldApplyFix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs code cleanup on the specified scope
|
||||
*
|
||||
@@ -477,13 +499,7 @@ public class GlobalInspectionContextBase extends UserDataHolderBase implements G
|
||||
@Nullable Runnable runnable,
|
||||
Predicate<? super ProblemDescriptor> shouldApplyFix,
|
||||
PsiElement @NotNull ... scope) {
|
||||
List<PsiElement> psiElements = Stream.of(scope).filter(e -> e != null && e.isPhysical()).toList();
|
||||
if (psiElements.isEmpty()) return;
|
||||
GlobalInspectionContextBase globalContext =
|
||||
(GlobalInspectionContextBase)InspectionManager.getInstance(project).createNewGlobalContext();
|
||||
InspectionProfile profile = InspectionProjectProfileManager.getInstance(project).getCurrentProfile();
|
||||
AnalysisScope analysisScope = new AnalysisScope(new LocalSearchScope(psiElements.toArray(PsiElement.EMPTY_ARRAY)), project);
|
||||
globalContext.codeCleanup(analysisScope, profile, null, runnable, false, shouldApplyFix);
|
||||
cleanupElements(project, runnable, shouldApplyFix, InspectionProjectProfileManager.getInstance(project).getCurrentProfile(), scope);
|
||||
}
|
||||
|
||||
public void close(boolean noSuspiciousCodeFound) {
|
||||
|
||||
Reference in New Issue
Block a user