mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 11:50:54 +07:00
instantiate UnusedDeclarationInspection properly in tests; got rid of setters
This commit is contained in:
@@ -24,6 +24,7 @@ import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspectionBase;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.ui.components.JBTabbedPane;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -31,6 +32,14 @@ import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class UnusedDeclarationInspection extends UnusedDeclarationInspectionBase {
|
||||
@TestOnly
|
||||
public UnusedDeclarationInspection(boolean enabledInEditor) {
|
||||
super(enabledInEditor);
|
||||
}
|
||||
|
||||
public UnusedDeclarationInspection() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected UnusedSymbolLocalInspectionBase createUnusedSymbolLocalInspection() {
|
||||
return new UnusedSymbolLocalInspection();
|
||||
|
||||
@@ -77,11 +77,15 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
myUnusedDeclarationInspection = new UnusedDeclarationInspection();
|
||||
myUnusedDeclarationInspection = new UnusedDeclarationInspection(isUnusedInspectionRequired());
|
||||
enableInspectionTool(myUnusedDeclarationInspection);
|
||||
setLanguageLevel(LanguageLevel.JDK_1_4);
|
||||
}
|
||||
|
||||
private boolean isUnusedInspectionRequired() {
|
||||
return getTestName(false).contains("UnusedInspection");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected LocalInspectionTool[] configureLocalInspectionTools() {
|
||||
@@ -226,14 +230,8 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testUnusedNonPrivateMembers() {
|
||||
try {
|
||||
myUnusedDeclarationInspection.setEnabledInEditor(true);
|
||||
doTest(true, false);
|
||||
}
|
||||
finally {
|
||||
myUnusedDeclarationInspection.setEnabledInEditor(false);
|
||||
}
|
||||
public void testUnusedInspectionNonPrivateMembers() {
|
||||
doTest(true, false);
|
||||
}
|
||||
|
||||
public void testUnusedNonPrivateMembers2() {
|
||||
@@ -281,33 +279,27 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
myUnusedDeclarationInspection = new UnusedDeclarationInspectionBase();
|
||||
}
|
||||
}
|
||||
public void testUnusedNonPrivateMembersReferencedFromText() {
|
||||
try {
|
||||
myUnusedDeclarationInspection.setEnabledInEditor(true);
|
||||
doTest(true, false);
|
||||
WriteCommandAction.runWriteCommandAction(null, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PsiDirectory directory = myFile.getParent();
|
||||
assertNotNull(myFile.toString(), directory);
|
||||
PsiFile txt = directory.createFile("x.txt");
|
||||
VirtualFile vFile = txt.getVirtualFile();
|
||||
assertNotNull(txt.toString(), vFile);
|
||||
try {
|
||||
VfsUtil.saveText(vFile, "XXX");
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
public void testUnusedInspectionNonPrivateMembersReferencedFromText() {
|
||||
doTest(true, false);
|
||||
WriteCommandAction.runWriteCommandAction(null, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PsiDirectory directory = myFile.getParent();
|
||||
assertNotNull(myFile.toString(), directory);
|
||||
PsiFile txt = directory.createFile("x.txt");
|
||||
VirtualFile vFile = txt.getVirtualFile();
|
||||
assertNotNull(txt.toString(), vFile);
|
||||
try {
|
||||
VfsUtil.saveText(vFile, "XXX");
|
||||
}
|
||||
});
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
List<HighlightInfo> infos = doHighlighting(HighlightSeverity.WARNING);
|
||||
assertEmpty(infos);
|
||||
}
|
||||
finally {
|
||||
myUnusedDeclarationInspection.setEnabledInEditor(false);
|
||||
}
|
||||
List<HighlightInfo> infos = doHighlighting(HighlightSeverity.WARNING);
|
||||
assertEmpty(infos);
|
||||
}
|
||||
|
||||
public void testNamesHighlighting() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -34,6 +34,10 @@ public class GlobalInspectionToolWrapper extends InspectionToolWrapper<GlobalIns
|
||||
super(globalInspectionTool);
|
||||
}
|
||||
|
||||
public GlobalInspectionToolWrapper(@NotNull GlobalInspectionTool tool, @NotNull InspectionEP ep) {
|
||||
super(tool, ep);
|
||||
}
|
||||
|
||||
public GlobalInspectionToolWrapper(@NotNull InspectionEP ep) {
|
||||
super(ep);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user