code cleanup action should take toplevel file instead of injected one (IDEA-202177)

This commit is contained in:
Dmitry Batkovich
2018-11-20 15:44:38 +03:00
parent 0b2d4947b7
commit de65a4d761
@@ -23,6 +23,7 @@ import com.intellij.codeInsight.intention.LowPriorityAction;
import com.intellij.codeInspection.InspectionManager;
import com.intellij.codeInspection.InspectionsBundle;
import com.intellij.codeInspection.ex.GlobalInspectionContextBase;
import com.intellij.lang.injection.InjectedLanguageManager;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
@@ -52,7 +53,7 @@ public abstract class CleanupIntention implements IntentionAction, LowPriorityAc
if (!FileModificationService.getInstance().preparePsiElementForWrite(file)) return;
final InspectionManager managerEx = InspectionManager.getInstance(project);
final GlobalInspectionContextBase globalContext = (GlobalInspectionContextBase)managerEx.createNewGlobalContext(false);
final AnalysisScope scope = getScope(project, file);
final AnalysisScope scope = getScope(project, InjectedLanguageManager.getInstance(project).getTopLevelFile(file));
if (scope != null) {
globalContext.codeCleanup(scope, InspectionProjectProfileManager.getInstance(project).getCurrentProfile(), getText(), null, false);
}