mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
real GlobalInspectionContext for tests
This commit is contained in:
@@ -1,2 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems />
|
||||
@@ -1,6 +0,0 @@
|
||||
public class Foo {
|
||||
|
||||
public void emptyMethod() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection;
|
||||
import com.intellij.codeInspection.ex.InspectionProfileImpl;
|
||||
import com.intellij.codeInspection.ex.InspectionTool;
|
||||
import com.intellij.profile.codeInspection.InspectionProfileManager;
|
||||
import com.intellij.testFramework.IdeaTestCase;
|
||||
import com.intellij.testFramework.fixtures.CodeInsightFixtureTestCase;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
* Date: 2/15/12
|
||||
*/
|
||||
public class GlobalInspectionsTest extends CodeInsightFixtureTestCase {
|
||||
|
||||
public void testUnusedDeclarationInspection() throws Exception {
|
||||
InspectionProfileImpl profile = (InspectionProfileImpl)InspectionProfileManager.getInstance().createProfile();
|
||||
try {
|
||||
InspectionProfileImpl.INIT_INSPECTIONS = true;
|
||||
profile.initInspectionTools(getProject());
|
||||
}
|
||||
finally {
|
||||
InspectionProfileImpl.INIT_INSPECTIONS = false;
|
||||
}
|
||||
InspectionProfileEntry tool = profile.getInspectionTool(new UnusedDeclarationInspection().getShortName());
|
||||
myFixture.testInspection("unusedDeclaration", (InspectionTool)tool);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return JavaTestUtil.getRelativeJavaTestDataPath() + "/inspection/global/";
|
||||
}
|
||||
|
||||
@SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors")
|
||||
public GlobalInspectionsTest() {
|
||||
IdeaTestCase.initPlatformPrefix();
|
||||
}
|
||||
}
|
||||
@@ -1,35 +1,41 @@
|
||||
package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.codeInspection.ex.GlobalInspectionToolWrapper;
|
||||
import com.intellij.codeInspection.ex.InspectionProfileImpl;
|
||||
import com.intellij.codeInspection.ex.InspectionToolRegistrar;
|
||||
import com.intellij.codeInspection.emptyMethod.EmptyMethodInspection;
|
||||
import com.intellij.codeInspection.ex.*;
|
||||
import com.intellij.codeInspection.i18n.I18nInspection;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.testFramework.InspectionTestCase;
|
||||
|
||||
public class RedundantSuppressTest extends InspectionTestCase {
|
||||
private GlobalInspectionToolWrapper myWrapper;
|
||||
private InspectionTool[] myInspectionTools;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
InspectionToolRegistrar.getInstance().ensureInitialized();
|
||||
myWrapper = new GlobalInspectionToolWrapper(new RedundantSuppressInspection());
|
||||
myInspectionTools = new InspectionTool[]{new LocalInspectionToolWrapper(new I18nInspection()),
|
||||
new GlobalInspectionToolWrapper(new EmptyMethodInspection())};
|
||||
|
||||
myWrapper = new GlobalInspectionToolWrapper(new RedundantSuppressInspection() {
|
||||
@Override
|
||||
protected InspectionTool[] getInspectionTools(PsiElement psiElement, InspectionManager manager) {
|
||||
return myInspectionTools;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testDefaultFile() throws Exception {
|
||||
InspectionProfileImpl.INIT_INSPECTIONS = true;
|
||||
doTest();
|
||||
InspectionProfileImpl.INIT_INSPECTIONS = false;
|
||||
}
|
||||
|
||||
public void testSuppressAll() throws Exception {
|
||||
InspectionProfileImpl.INIT_INSPECTIONS = true;
|
||||
try {
|
||||
((RedundantSuppressInspection)myWrapper.getTool()).IGNORE_ALL = true;
|
||||
doTest();
|
||||
}
|
||||
finally {
|
||||
((RedundantSuppressInspection)myWrapper.getTool()).IGNORE_ALL = false;
|
||||
InspectionProfileImpl.INIT_INSPECTIONS = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user