mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
remove ModifiableModel, migrate to use setToolEnabled
This commit is contained in:
+3
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,20 +23,17 @@ import com.intellij.codeInspection.ex.*;
|
||||
import com.intellij.codeInspection.ui.InspectionToolPresentation;
|
||||
import com.intellij.codeInspection.visibility.VisibilityInspection;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.testFramework.InspectionsKt;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
* Date: 5/24/12
|
||||
*/
|
||||
public class GlobalInspectionContextTest extends CodeInsightTestCase {
|
||||
public void testProblemDuplication() throws Exception {
|
||||
String shortName = new VisibilityInspection().getShortName();
|
||||
InspectionProfileImpl profile = new InspectionProfileImpl("Foo");
|
||||
ProjectInspectionManagerTestKt.disableAllTools(profile, getProject());
|
||||
InspectionsKt.disableAllTools(profile);
|
||||
profile.enableTool(shortName, getProject());
|
||||
|
||||
GlobalInspectionContextImpl context = ((InspectionManagerEx)InspectionManager.getInstance(getProject())).createNewGlobalContext(false);
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.intellij.profile.codeInspection.InspectionProfileManager;
|
||||
import com.intellij.profile.codeInspection.ProjectInspectionProfileManager;
|
||||
import com.intellij.profile.codeInspection.ui.header.InspectionProfileSchemesPanel;
|
||||
import com.intellij.psi.PsiModifier;
|
||||
import com.intellij.testFramework.InspectionsKt;
|
||||
import com.intellij.testFramework.LightIdeaTestCase;
|
||||
import com.intellij.util.JdomKt;
|
||||
import com.intellij.util.SmartList;
|
||||
@@ -43,10 +44,6 @@ import java.util.function.Supplier;
|
||||
|
||||
import static com.intellij.testFramework.assertions.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Anna.Kozlova
|
||||
* Date: 18-Aug-2006
|
||||
*/
|
||||
public class InspectionProfileTest extends LightIdeaTestCase {
|
||||
private static final String PROFILE = "ToConvert";
|
||||
|
||||
@@ -549,7 +546,7 @@ public class InspectionProfileTest extends LightIdeaTestCase {
|
||||
|
||||
public void testGlobalInspectionContext() throws Exception {
|
||||
InspectionProfileImpl profile = new InspectionProfileImpl("Foo");
|
||||
ProjectInspectionManagerTestKt.disableAllTools(profile, getProject());
|
||||
InspectionsKt.disableAllTools(profile);
|
||||
profile.enableTool(new UnusedDeclarationInspectionBase(true).getShortName(), getProject());
|
||||
|
||||
GlobalInspectionContextImpl context = ((InspectionManagerEx)InspectionManager.getInstance(getProject())).createNewGlobalContext(false);
|
||||
@@ -590,13 +587,8 @@ public class InspectionProfileTest extends LightIdeaTestCase {
|
||||
assertNotNull(toolWrapper);
|
||||
String id = toolWrapper.getShortName();
|
||||
System.out.println(id);
|
||||
if (profile.isToolEnabled(HighlightDisplayKey.findById(id))) {
|
||||
profile.disableTool(id, getProject());
|
||||
}
|
||||
else {
|
||||
profile.enableTool(id, getProject());
|
||||
}
|
||||
assertEquals(0, countInitializedTools(profile));
|
||||
profile.setToolEnabled(id, !profile.isToolEnabled(HighlightDisplayKey.findById(id)));
|
||||
assertThat(countInitializedTools(profile)).isEqualTo(0);
|
||||
profile.writeScheme();
|
||||
List<InspectionToolWrapper> initializedTools = getInitializedTools(profile);
|
||||
if (initializedTools.size() > 0) {
|
||||
@@ -653,6 +645,5 @@ public class InspectionProfileTest extends LightIdeaTestCase {
|
||||
|
||||
@SuppressWarnings("InspectionDescriptionNotFoundInspection")
|
||||
public static class TestTool extends LocalInspectionTool {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+3
-10
@@ -19,7 +19,6 @@ import com.intellij.codeHighlighting.HighlightDisplayLevel
|
||||
import com.intellij.configurationStore.PROJECT_CONFIG_DIR
|
||||
import com.intellij.configurationStore.StoreAwareProjectManager
|
||||
import com.intellij.ide.highlighter.ProjectFileType
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.project.ProjectManager
|
||||
import com.intellij.profile.codeInspection.ProjectInspectionProfileManager
|
||||
import com.intellij.project.stateStore
|
||||
@@ -129,7 +128,7 @@ class ProjectInspectionManagerTest {
|
||||
// cause to use app profile
|
||||
val currentProfile = projectInspectionProfileManager.currentProfile
|
||||
assertThat(currentProfile.isProjectLevel).isTrue()
|
||||
currentProfile.disableTool("Convert2Diamond", project)
|
||||
currentProfile.setToolEnabled("Convert2Diamond", false)
|
||||
|
||||
project.saveStore()
|
||||
|
||||
@@ -175,7 +174,7 @@ class ProjectInspectionManagerTest {
|
||||
|
||||
val currentProfile = projectInspectionProfileManager.currentProfile
|
||||
assertThat(currentProfile.isProjectLevel).isTrue()
|
||||
currentProfile.disableTool("Convert2Diamond", project)
|
||||
currentProfile.setToolEnabled("Convert2Diamond", false)
|
||||
currentProfile.profileChanged()
|
||||
|
||||
project.saveStore()
|
||||
@@ -196,17 +195,11 @@ class ProjectInspectionManagerTest {
|
||||
</project>""".trimIndent()
|
||||
assertThat(projectFile.readText()).isEqualTo(expected)
|
||||
|
||||
currentProfile.disableAllTools(project)
|
||||
currentProfile.disableAllTools()
|
||||
currentProfile.profileChanged()
|
||||
project.saveStore()
|
||||
assertThat(projectFile.readText()).isNotEqualTo(expected)
|
||||
assertThat(projectFile.parent.resolve(".inspectionProfiles")).doesNotExist()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun InspectionProfileImpl.disableAllTools(project: Project?) {
|
||||
for (entry in getInspectionTools(null)) {
|
||||
disableTool(entry.shortName, project)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user