mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
convert InspectionTestCase to light
This commit is contained in:
@@ -1,9 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>Test.java</file>
|
||||
<line>4</line>
|
||||
<description>Interface is not implemented.</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>Test.java</file>
|
||||
<line>5</line>
|
||||
<description>Method is never used.</description>
|
||||
<description>Method owner class is never instantiated OR An instantiation is not reachable from entry points.</description>
|
||||
</problem>
|
||||
</problems>
|
||||
|
||||
|
||||
+7
-1
@@ -4,6 +4,12 @@
|
||||
<file>Test.java</file>
|
||||
<line>3</line>
|
||||
<entry_point TYPE="method" FQNAME="AbstractTest void testSmth()"/>
|
||||
<description>Method is never used.</description>
|
||||
<description>Method owner class is never instantiated OR An instantiation is not reachable from entry points.</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>Test.java</file>
|
||||
<line>1</line>
|
||||
<entry_point TYPE="method" FQNAME="AbstractTest void testSmth()"/>
|
||||
<description>Abstract class is not implemented.</description>
|
||||
</problem>
|
||||
</problems>
|
||||
|
||||
@@ -1,16 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>A.java</file>
|
||||
<line>1</line>
|
||||
<problem_class>unused declaration</problem_class>
|
||||
<description>Class is not instantiated.</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>A.java</file>
|
||||
<line>2</line>
|
||||
<problem_class>unused declaration</problem_class>
|
||||
<description>Method has usage(s) but they all belong to calls chain that has no members reachable from entry points.</description>
|
||||
<description>Method owner class is never instantiated OR An instantiation is not reachable from entry points.</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>A.java</file>
|
||||
<line>5</line>
|
||||
<problem_class>unused declaration</problem_class>
|
||||
<description>Method has usage(s) but they all belong to calls chain that has no members reachable from entry points.</description>
|
||||
<description>Method owner class is never instantiated OR An instantiation is not reachable from entry points.</description>
|
||||
</problem>
|
||||
</problems>
|
||||
|
||||
|
||||
@@ -6,6 +6,12 @@
|
||||
<problem_class>unused declaration</problem_class>
|
||||
<description>Class has one instantiation but it is not reachable from entry points.</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>A.java</file>
|
||||
<line>1</line>
|
||||
<problem_class>unused declaration</problem_class>
|
||||
<description>Class is not instantiated.</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>A.java</file>
|
||||
<line>4</line>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>testSimple.iml</file>
|
||||
<file>light_idea_test_case</file>
|
||||
<problem_class>Unused library</problem_class>
|
||||
<description>Unused library 'JUnit'</description>
|
||||
</problem>
|
||||
|
||||
+20
-12
@@ -4,16 +4,31 @@ package com.intellij.java.codeInspection;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInspection.deprecation.DeprecationInspection;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.roots.ContentEntry;
|
||||
import com.intellij.openapi.roots.JavaModuleExternalPaths;
|
||||
import com.intellij.openapi.roots.ModuleRootModificationUtil;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.testFramework.InspectionTestCase;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
public class DeprecationInspectionTest extends InspectionTestCase {
|
||||
|
||||
private final DefaultLightProjectDescriptor myProjectDescriptor = new DefaultLightProjectDescriptor() {
|
||||
@Override
|
||||
public void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model, @NotNull ContentEntry contentEntry) {
|
||||
super.configureModule(module, model, contentEntry);
|
||||
model.getModuleExtension(JavaModuleExternalPaths.class)
|
||||
.setExternalAnnotationUrls(new String[]{VfsUtilCore.pathToUrl(FileUtil.toSystemIndependentName(getTestDataPath() + "/deprecation/" + getTestName(true) + "/extAnnotations"))});
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return JavaTestUtil.getJavaTestDataPath() + "/inspection";
|
||||
@@ -69,20 +84,13 @@ public class DeprecationInspectionTest extends InspectionTestCase {
|
||||
doTest("deprecation/" + getTestName(true), tool);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up external deprecation annotations
|
||||
* for the current test module.
|
||||
*/
|
||||
private void configureExternalAnnotationsUrls(String... urls) {
|
||||
ModuleRootModificationUtil.updateModel(myModule, (root) -> {
|
||||
JavaModuleExternalPaths extension = root.getModuleExtension(JavaModuleExternalPaths.class);
|
||||
extension.setExternalAnnotationUrls(urls);
|
||||
});
|
||||
@NotNull
|
||||
@Override
|
||||
protected LightProjectDescriptor getProjectDescriptor() {
|
||||
return myProjectDescriptor;
|
||||
}
|
||||
|
||||
public void testExternallyDeprecatedDefaultConstructor() {
|
||||
String url = VfsUtilCore.pathToUrl(FileUtil.toSystemIndependentName(getTestDataPath()) + "/deprecation/externallyDeprecatedDefaultConstructor/extAnnotations");
|
||||
configureExternalAnnotationsUrls(url);
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
+9
-39
@@ -19,13 +19,8 @@ package com.intellij.java.codeInspection;
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
|
||||
import com.intellij.codeInspection.nullable.NullableStuffInspection;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.SdkModificator;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.testFramework.InspectionTestCase;
|
||||
import com.intellij.testFramework.PsiTestUtil;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class NullableStuffInspectionAncientTest extends InspectionTestCase {
|
||||
@@ -48,43 +43,18 @@ public class NullableStuffInspectionAncientTest extends InspectionTestCase {
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected LightProjectDescriptor getProjectDescriptor() {
|
||||
return JAVA_1_4_ANNOTATED;
|
||||
}
|
||||
|
||||
public void testJdk14() {
|
||||
doTest("nullableProblems/" + getTestName(true), new LocalInspectionToolWrapper(myInspection), "java 1.4");
|
||||
doTest("nullableProblems/" + getTestName(true), new LocalInspectionToolWrapper(myInspection));
|
||||
}
|
||||
|
||||
public void testJdkAnnotationsWithoutJetBrainsAnnotations() {
|
||||
doTest("nullableProblems/" + getTestName(true), new LocalInspectionToolWrapper(myInspection), "java 1.5");
|
||||
doTest("nullableProblems/" + getTestName(true), new LocalInspectionToolWrapper(myInspection));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getTestProjectSdk() {
|
||||
Sdk sdk = super.getTestProjectSdk();
|
||||
sdk = removeAnnotationsJar(sdk);
|
||||
if ("testJdkAnnotationsWithoutJetBrainsAnnotations".equals(getName())) {
|
||||
sdk = PsiTestUtil.addJdkAnnotations(sdk);
|
||||
}
|
||||
return sdk;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Sdk removeAnnotationsJar(@NotNull Sdk sdk) {
|
||||
return WriteAction.compute(() -> {
|
||||
Sdk clone;
|
||||
try {
|
||||
clone = (Sdk)sdk.clone();
|
||||
}
|
||||
catch (CloneNotSupportedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
final SdkModificator sdkMod = clone.getSdkModificator();
|
||||
for (VirtualFile file : sdkMod.getRoots(OrderRootType.CLASSES)) {
|
||||
if ("annotations.jar".equals(file.getName())) {
|
||||
sdkMod.removeRoot(file, OrderRootType.CLASSES);
|
||||
break;
|
||||
}
|
||||
}
|
||||
sdkMod.commitChanges();
|
||||
return clone;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -71,7 +71,7 @@ public class RedundantSuppressTest extends InspectionTestCase {
|
||||
}
|
||||
|
||||
public void testModuleInfo() {
|
||||
doTest("redundantSuppress/" + getTestName(true), myWrapper,"java 1.5",false);
|
||||
doTest("redundantSuppress/" + getTestName(true), myWrapper, false);
|
||||
}
|
||||
|
||||
public void testDefaultFile() {
|
||||
@@ -83,7 +83,7 @@ public class RedundantSuppressTest extends InspectionTestCase {
|
||||
}
|
||||
|
||||
public void testAnnotator() {
|
||||
doTest("redundantSuppress/" + getTestName(true), myWrapper,"java 1.5",false);
|
||||
doTest("redundantSuppress/" + getTestName(true), myWrapper, false);
|
||||
}
|
||||
|
||||
public void testIgnoreUnused() {
|
||||
@@ -112,6 +112,6 @@ public class RedundantSuppressTest extends InspectionTestCase {
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest("redundantSuppress/" + getTestName(true), myWrapper,"java 1.5",true);
|
||||
doTest("redundantSuppress/" + getTestName(true), myWrapper, true);
|
||||
}
|
||||
}
|
||||
|
||||
+18
-9
@@ -18,20 +18,29 @@ package com.intellij.java.codeInspection;
|
||||
import com.intellij.analysis.AnalysisScope;
|
||||
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
|
||||
import com.intellij.codeInspection.testOnly.TestOnlyInspection;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.roots.ContentEntry;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.testFramework.InspectionTestCase;
|
||||
import com.intellij.testFramework.PsiTestUtil;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class TestOnlyInspectionTest extends InspectionTestCase {
|
||||
|
||||
private final static DefaultLightProjectDescriptor ourProjectDescriptor = new DefaultLightProjectDescriptor() {
|
||||
@Override
|
||||
public void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model, @NotNull ContentEntry contentEntry) {
|
||||
super.configureModule(module, model, contentEntry);
|
||||
contentEntry.addSourceFolder(contentEntry.getUrl() + "/test", true);
|
||||
}
|
||||
};
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected void setupRootModel(@NotNull String testDir, @NotNull VirtualFile[] sourceDir, String jdkName) {
|
||||
super.setupRootModel(testDir, sourceDir, jdkName);
|
||||
VirtualFile projectDir = LocalFileSystem.getInstance().findFileByPath(testDir);
|
||||
assertNotNull(projectDir);
|
||||
VirtualFile test = projectDir.findChild("test");
|
||||
if (test != null) PsiTestUtil.addSourceRoot(myModule, test, true);
|
||||
protected LightProjectDescriptor getProjectDescriptor() {
|
||||
return ourProjectDescriptor;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -68,6 +77,6 @@ public class TestOnlyInspectionTest extends InspectionTestCase {
|
||||
|
||||
private void doTest() {
|
||||
TestOnlyInspection i = new TestOnlyInspection();
|
||||
doTest("testOnly/" + getTestName(true), new LocalInspectionToolWrapper(i), "java 1.5");
|
||||
doTest("testOnly/" + getTestName(true), new LocalInspectionToolWrapper(i));
|
||||
}
|
||||
}
|
||||
+3
-16
@@ -4,30 +4,17 @@
|
||||
package com.intellij.java.codeInspection;
|
||||
|
||||
import com.intellij.analysis.AnalysisScope;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.testFramework.PsiTestUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class UnusedDeclarationInSubScopeTest extends AbstractUnusedDeclarationTest {
|
||||
@Override
|
||||
protected void setupRootModel(@NotNull String testDir, @NotNull VirtualFile[] sourceDir, String jdkName) {
|
||||
super.setupRootModel(testDir, sourceDir, jdkName);
|
||||
VirtualFile projectDir = LocalFileSystem.getInstance().findFileByPath(testDir);
|
||||
assertNotNull(projectDir);
|
||||
VirtualFile test = projectDir.findChild("test_src");
|
||||
if (test != null) PsiTestUtil.addSourceRoot(myModule, test, true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected AnalysisScope createAnalysisScope(VirtualFile sourceDir) {
|
||||
VirtualFile[] roots = ModuleRootManager.getInstance(myModule).getSourceRoots(false);
|
||||
assertEquals(1, roots.length);
|
||||
PsiManager psiManager = PsiManager.getInstance(myProject);
|
||||
return new AnalysisScope(psiManager.findDirectory(roots[0]));
|
||||
AnalysisScope scope = super.createAnalysisScope(sourceDir);
|
||||
scope.setIncludeTestSource(false);
|
||||
return scope;
|
||||
}
|
||||
|
||||
public void testParameterUsedInOutOfScopeOverrider() {
|
||||
|
||||
+11
-14
@@ -16,8 +16,8 @@
|
||||
package com.intellij.java.codeInspection;
|
||||
|
||||
import com.intellij.codeInspection.ex.EntryPointsManagerBase;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
@@ -74,23 +74,19 @@ public class UnusedDeclarationTest extends AbstractUnusedDeclarationTest {
|
||||
}
|
||||
|
||||
public void testSuppress() {
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
doTest();
|
||||
doTest5();
|
||||
}
|
||||
|
||||
public void testSuppress1() {
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
doTest();
|
||||
doTest5();
|
||||
}
|
||||
|
||||
public void testSuppress2() {
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
doTest();
|
||||
doTest5();
|
||||
}
|
||||
|
||||
public void testChainOfSuppressions() {
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
doTest();
|
||||
doTest5();
|
||||
}
|
||||
|
||||
public void testSuppressByNoinspectionTag() {
|
||||
@@ -142,13 +138,11 @@ public class UnusedDeclarationTest extends AbstractUnusedDeclarationTest {
|
||||
}
|
||||
|
||||
public void testAnnotationInterface() {
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
doTest();
|
||||
doTest5();
|
||||
}
|
||||
|
||||
public void testUnusedEnum() {
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
doTest();
|
||||
doTest5();
|
||||
}
|
||||
|
||||
public void testJunitEntryPoint() {
|
||||
@@ -204,7 +198,6 @@ public class UnusedDeclarationTest extends AbstractUnusedDeclarationTest {
|
||||
}
|
||||
|
||||
public void testFunctionalExpressions() {
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_8);
|
||||
doTest();
|
||||
}
|
||||
|
||||
@@ -259,4 +252,8 @@ public class UnusedDeclarationTest extends AbstractUnusedDeclarationTest {
|
||||
public void testMethodCallQualifiedWithSuper() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest5() {
|
||||
IdeaTestUtil.withLevel(myModule, LanguageLevel.JDK_1_5,() -> doTest());
|
||||
}
|
||||
}
|
||||
|
||||
+23
-14
@@ -19,33 +19,42 @@ package com.intellij.java.codeInspection;
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.analysis.AnalysisScope;
|
||||
import com.intellij.codeInspection.unusedLibraries.UnusedLibrariesInspection;
|
||||
import com.intellij.openapi.roots.DependencyScope;
|
||||
import com.intellij.openapi.roots.LibraryOrderEntry;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.roots.OrderEntry;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.roots.*;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.project.IntelliJProjectConfiguration;
|
||||
import com.intellij.testFramework.InspectionTestCase;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import com.intellij.testFramework.PsiTestUtil;
|
||||
import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class UnusedLibraryInspectionTest extends InspectionTestCase {
|
||||
|
||||
private final DefaultLightProjectDescriptor myProjectDescriptor = new DefaultLightProjectDescriptor() {
|
||||
@Override
|
||||
public void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model, @NotNull ContentEntry contentEntry) {
|
||||
super.configureModule(module, model, contentEntry);
|
||||
PsiTestUtil.addProjectLibrary(model, "JUnit", IntelliJProjectConfiguration.getProjectLibraryClassesRootPaths("JUnit4"));
|
||||
if (getTestName(true).endsWith("Runtime")) {
|
||||
for (OrderEntry entry : model.getOrderEntries()) {
|
||||
if (entry instanceof LibraryOrderEntry && "JUnit".equals(((LibraryOrderEntry)entry).getLibraryName())) {
|
||||
((LibraryOrderEntry)entry).setScope(DependencyScope.RUNTIME);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return JavaTestUtil.getJavaTestDataPath() + "/inspection/unusedLibrary";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected void setupRootModel(@NotNull String testDir, @NotNull VirtualFile[] sourceDir, String sdkName) {
|
||||
super.setupRootModel(testDir, sourceDir, sdkName);
|
||||
PsiTestUtil.addProjectLibrary(getModule(), "JUnit", IntelliJProjectConfiguration.getProjectLibraryClassesRootPaths("JUnit4"));
|
||||
if (getTestName(true).endsWith("Runtime")) {
|
||||
for (OrderEntry entry : ModuleRootManager.getInstance(getModule()).getOrderEntries()) {
|
||||
if (entry instanceof LibraryOrderEntry && "JUnit".equals(((LibraryOrderEntry)entry).getLibraryName())) {
|
||||
((LibraryOrderEntry)entry).setScope(DependencyScope.RUNTIME);
|
||||
}
|
||||
}
|
||||
}
|
||||
protected LightProjectDescriptor getProjectDescriptor() {
|
||||
return myProjectDescriptor;
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
|
||||
@@ -27,20 +27,21 @@ import com.intellij.codeInspection.deadCode.UnusedDeclarationPresentation;
|
||||
import com.intellij.codeInspection.ex.*;
|
||||
import com.intellij.codeInspection.reference.EntryPoint;
|
||||
import com.intellij.codeInspection.reference.RefElement;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ex.PathManagerEx;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.extensions.ExtensionPoint;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.roots.ContentEntry;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor;
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
|
||||
import com.intellij.testFramework.fixtures.impl.GlobalInspectionContextForTests;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jdom.Element;
|
||||
@@ -56,9 +57,17 @@ import java.util.List;
|
||||
* @author max
|
||||
*/
|
||||
@SuppressWarnings("HardCodedStringLiteral")
|
||||
public abstract class InspectionTestCase extends PsiTestCase {
|
||||
public abstract class InspectionTestCase extends LightCodeInsightFixtureTestCase {
|
||||
private static final boolean MIGRATE_TEST = false;
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.testFramework.InspectionTestCase");
|
||||
private static final DefaultLightProjectDescriptor ourDescriptor = new DefaultLightProjectDescriptor() {
|
||||
@Override
|
||||
public void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model, @NotNull ContentEntry contentEntry) {
|
||||
super.configureModule(module, model, contentEntry);
|
||||
contentEntry.addSourceFolder(contentEntry.getUrl() + "/ext_src", false);
|
||||
contentEntry.addSourceFolder(contentEntry.getUrl() + "/test_src", true);
|
||||
}
|
||||
};
|
||||
private EntryPoint myUnusedCodeExtension;
|
||||
private VirtualFile ext_src;
|
||||
private LightTestMigration myMigration;
|
||||
@@ -73,7 +82,7 @@ public abstract class InspectionTestCase extends PsiTestCase {
|
||||
}
|
||||
|
||||
public InspectionManagerEx getManager() {
|
||||
return (InspectionManagerEx)InspectionManager.getInstance(myProject);
|
||||
return (InspectionManagerEx)InspectionManager.getInstance(getProject());
|
||||
}
|
||||
|
||||
public void doTest(@NonNls @NotNull String folderName, @NotNull LocalInspectionTool tool) {
|
||||
@@ -89,65 +98,58 @@ public abstract class InspectionTestCase extends PsiTestCase {
|
||||
}
|
||||
|
||||
public void doTest(@NonNls @NotNull String folderName, @NotNull GlobalInspectionTool tool, boolean checkRange, boolean runDeadCodeFirst) {
|
||||
doTest(folderName, new GlobalInspectionToolWrapper(tool), "java 1.4", checkRange, runDeadCodeFirst);
|
||||
doTest(folderName, new GlobalInspectionToolWrapper(tool), checkRange, runDeadCodeFirst);
|
||||
}
|
||||
|
||||
public void doTest(@NonNls @NotNull String folderName, @NotNull InspectionToolWrapper tool) {
|
||||
doTest(folderName, tool, "java 1.4");
|
||||
doTest(folderName, tool, false);
|
||||
}
|
||||
|
||||
public void doTest(@NonNls @NotNull String folderName, @NotNull InspectionToolWrapper tool, final boolean checkRange) {
|
||||
doTest(folderName, tool, "java 1.4", checkRange);
|
||||
}
|
||||
|
||||
public void doTest(@NonNls @NotNull String folderName, @NotNull LocalInspectionTool tool, @NonNls final String jdkName) {
|
||||
doTest(folderName, new LocalInspectionToolWrapper(tool), jdkName);
|
||||
}
|
||||
|
||||
public void doTest(@NonNls @NotNull String folderName, @NotNull InspectionToolWrapper tool, @NonNls final String jdkName) {
|
||||
doTest(folderName, tool, jdkName, false);
|
||||
}
|
||||
|
||||
public void doTest(@NonNls @NotNull String folderName, @NotNull InspectionToolWrapper tool, @NonNls final String jdkName, boolean checkRange) {
|
||||
doTest(folderName, tool, jdkName, checkRange, false);
|
||||
public void doTest(@NonNls @NotNull String folderName,
|
||||
@NotNull InspectionToolWrapper tool,
|
||||
boolean checkRange) {
|
||||
doTest(folderName, tool, checkRange, false);
|
||||
}
|
||||
|
||||
public void doTest(@NonNls @NotNull String folderName,
|
||||
@NotNull InspectionToolWrapper toolWrapper,
|
||||
@NonNls final String jdkName,
|
||||
boolean checkRange,
|
||||
boolean runDeadCodeFirst,
|
||||
@NotNull InspectionToolWrapper... additional) {
|
||||
final String testDir = getTestDataPath() + "/" + folderName;
|
||||
final List<InspectionToolWrapper<?, ?>> tools = getTools(runDeadCodeFirst, toolWrapper, additional);
|
||||
GlobalInspectionContextImpl context = runTool(testDir, jdkName, toolWrapper, tools);
|
||||
GlobalInspectionContextImpl context = runTool(folderName, toolWrapper, tools);
|
||||
|
||||
InspectionTestUtil.compareToolResults(context, checkRange, testDir, ContainerUtil.append(Collections.singletonList(toolWrapper), additional));
|
||||
|
||||
if (MIGRATE_TEST) {
|
||||
myMigration = new LightTestMigration(getTestName(false), getClass(), testDir, tools, getTestProjectSdk());
|
||||
myMigration = new LightTestMigration(getTestName(false), getClass(), testDir, tools);
|
||||
}
|
||||
}
|
||||
|
||||
protected void runTool(@NonNls @NotNull String testDir, @NonNls final String jdkName, @NotNull InspectionToolWrapper<?, ?> tool) {
|
||||
runTool(testDir, jdkName, tool, Collections.singletonList(tool));
|
||||
}
|
||||
|
||||
protected GlobalInspectionContextImpl runTool(@NotNull final String testDir,
|
||||
final String jdkName,
|
||||
protected GlobalInspectionContextImpl runTool(@NotNull final String testName,
|
||||
@NotNull InspectionToolWrapper toolWrapper,
|
||||
List<InspectionToolWrapper<?, ?>> tools) {
|
||||
final VirtualFile[] sourceDir = new VirtualFile[1];
|
||||
ApplicationManager.getApplication().runWriteAction(() -> {
|
||||
try {
|
||||
setupRootModel(testDir, sourceDir, jdkName);
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
});
|
||||
VirtualFile projectDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(testDir));
|
||||
AnalysisScope scope = createAnalysisScope(sourceDir[0].equals(projectDir) ? projectDir : sourceDir[0].getParent());
|
||||
VirtualFile projectDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(getTestDataPath(), testName));
|
||||
assertNotNull(projectDir);
|
||||
|
||||
VirtualFile srcDir;
|
||||
if (projectDir.findChild("src") != null) {
|
||||
srcDir = myFixture.copyDirectoryToProject(testName + "/src", "");
|
||||
}
|
||||
else {
|
||||
srcDir = myFixture.copyDirectoryToProject(testName,"");
|
||||
}
|
||||
|
||||
if (projectDir.findChild("ext_src") != null) {
|
||||
ext_src = myFixture.copyDirectoryToProject(testName + "/ext_src", "ext_src");
|
||||
}
|
||||
|
||||
if (projectDir.findChild("test_src") != null) {
|
||||
myFixture.copyDirectoryToProject(testName + "/test_src", "test_src");
|
||||
}
|
||||
|
||||
AnalysisScope scope = createAnalysisScope(srcDir);
|
||||
|
||||
GlobalInspectionContextForTests globalContext = InspectionsKt.createGlobalContextForTool(scope, getProject(), tools);
|
||||
|
||||
@@ -170,31 +172,14 @@ public abstract class InspectionTestCase extends PsiTestCase {
|
||||
|
||||
@NotNull
|
||||
protected AnalysisScope createAnalysisScope(VirtualFile sourceDir) {
|
||||
PsiManager psiManager = PsiManager.getInstance(myProject);
|
||||
PsiManager psiManager = PsiManager.getInstance(getProject());
|
||||
return new AnalysisScope(psiManager.findDirectory(sourceDir));
|
||||
}
|
||||
|
||||
protected void setupRootModel(@NotNull String testDir, @NotNull VirtualFile[] sourceDir, final String sdkName) {
|
||||
VirtualFile projectDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(testDir));
|
||||
assertNotNull("could not find project dir " + testDir, projectDir);
|
||||
sourceDir[0] = projectDir.findChild("src");
|
||||
if (sourceDir[0] == null) {
|
||||
sourceDir[0] = projectDir;
|
||||
}
|
||||
// IMPORTANT! The jdk must be obtained in a way it is obtained in the normal program!
|
||||
//ProjectJdkEx jdk = ProjectJdkTable.getInstance().getInternalJdk();
|
||||
PsiTestUtil.removeAllRoots(myModule, getTestProjectSdk());
|
||||
PsiTestUtil.addContentRoot(myModule, projectDir);
|
||||
PsiTestUtil.addSourceRoot(myModule, sourceDir[0]);
|
||||
ext_src = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(testDir + "/ext_src"));
|
||||
if (ext_src != null) {
|
||||
PsiTestUtil.addSourceRoot(myModule, ext_src);
|
||||
}
|
||||
|
||||
VirtualFile test_src = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(testDir + "/test_src"));
|
||||
if (test_src != null) {
|
||||
PsiTestUtil.addSourceRoot(myModule, test_src, true);
|
||||
}
|
||||
@NotNull
|
||||
@Override
|
||||
protected LightProjectDescriptor getProjectDescriptor() {
|
||||
return ourDescriptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -261,16 +246,6 @@ public abstract class InspectionTestCase extends PsiTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUpJdk() {
|
||||
}
|
||||
|
||||
protected Sdk getTestProjectSdk() {
|
||||
Sdk sdk = IdeaTestUtil.getMockJdk18();
|
||||
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_8);
|
||||
return sdk;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNls
|
||||
protected String getTestDataPath() {
|
||||
|
||||
@@ -9,8 +9,6 @@ import com.intellij.codeInspection.ex.InspectionProfileImpl;
|
||||
import com.intellij.codeInspection.ex.InspectionToolWrapper;
|
||||
import com.intellij.openapi.application.ex.PathManagerEx;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.AnnotationOrderRootType;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -18,10 +16,8 @@ import com.intellij.profile.codeInspection.ProjectInspectionProfileManager;
|
||||
import com.intellij.testFramework.fixtures.*;
|
||||
import com.intellij.testFramework.fixtures.impl.LightTempDirTestFixtureImpl;
|
||||
import com.siyeh.ig.LightInspectionTestCase;
|
||||
import one.util.streamex.EntryStream;
|
||||
import one.util.streamex.StreamEx;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.ComparisonFailure;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -31,7 +27,10 @@ import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.text.MessageFormat;
|
||||
import java.time.Year;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -45,7 +44,6 @@ class LightTestMigration {
|
||||
private final Class<? extends InspectionTestCase> myTestClass;
|
||||
private final Path myDir;
|
||||
private final List<InspectionToolWrapper<?, ?>> myTools;
|
||||
private final Sdk mySdk;
|
||||
private final List<String> myTestNames = new ArrayList<>();
|
||||
|
||||
private static LightTestMigration ourPrevious;
|
||||
@@ -54,25 +52,17 @@ class LightTestMigration {
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(LightTestMigration::flush));
|
||||
}
|
||||
|
||||
private static final Map<String, String> JDK_MAP = EntryStream.of(
|
||||
"java 1.7", "JAVA_1_7",
|
||||
"java 1.8", "JAVA_8",
|
||||
"java 9", "JAVA_9",
|
||||
"java 10", "JAVA_10"
|
||||
).toMap();
|
||||
private Path myBaseDir;
|
||||
private Path myBasePath;
|
||||
|
||||
LightTestMigration(String name,
|
||||
Class<? extends InspectionTestCase> testClass,
|
||||
String dir,
|
||||
List<InspectionToolWrapper<?, ?>> tools,
|
||||
Sdk sdk) {
|
||||
List<InspectionToolWrapper<?, ?>> tools) {
|
||||
myName = name;
|
||||
myTestClass = testClass;
|
||||
myDir = Paths.get(dir);
|
||||
myTools = tools;
|
||||
mySdk = sdk;
|
||||
}
|
||||
|
||||
void tryMigrate() throws Exception {
|
||||
@@ -96,13 +86,7 @@ class LightTestMigration {
|
||||
myBaseDir = myName.isEmpty() ? myDir : myDir.getParent();
|
||||
Path targetFile = myBaseDir.resolve(testName + ".java");
|
||||
IdeaTestFixtureFactory factory = IdeaTestFixtureFactory.getFixtureFactory();
|
||||
LightProjectDescriptor descriptor = new LightProjectDescriptor() {
|
||||
@Nullable
|
||||
@Override
|
||||
public Sdk getSdk() {
|
||||
return mySdk;
|
||||
}
|
||||
};
|
||||
LightProjectDescriptor descriptor = new LightProjectDescriptor();
|
||||
TestFixtureBuilder<IdeaProjectTestFixture> fixtureBuilder = factory.createLightFixtureBuilder(descriptor);
|
||||
IdeaProjectTestFixture fixture = fixtureBuilder.getFixture();
|
||||
JavaCodeInsightTestFixture javaFixture =
|
||||
@@ -161,11 +145,9 @@ class LightTestMigration {
|
||||
String inspections =
|
||||
myTools.stream().map(InspectionToolWrapper::getTool).map(InspectionProfileEntry::getClass).map(Class::getSimpleName)
|
||||
.map(name -> "new " + name + "()").collect(Collectors.joining(", "));
|
||||
System.out.println("JDK version: " + mySdk.getVersionString());
|
||||
String guessedJdk = guessJdk();
|
||||
String year = Year.now().toString();
|
||||
String classTemplate = MessageFormat.format(
|
||||
"// Copyright 2000-{7} JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.\n" +
|
||||
"// Copyright 2000-{6} JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.\n" +
|
||||
"package {0};\n\n" +
|
||||
"{1}" +
|
||||
"\n" +
|
||||
@@ -175,12 +157,6 @@ class LightTestMigration {
|
||||
" return {3};\n" +
|
||||
" '}'\n" +
|
||||
"\n" +
|
||||
" @NotNull\n" +
|
||||
" @Override\n" +
|
||||
" protected LightProjectDescriptor getProjectDescriptor() '{'\n" +
|
||||
" return {6};\n" +
|
||||
" '}'\n" +
|
||||
"\n" +
|
||||
" private void doTest() '{'\n" +
|
||||
" myFixture.enableInspections({4});\n" +
|
||||
" myFixture.testHighlighting(getTestName(false) + \".java\");\n" +
|
||||
@@ -188,7 +164,7 @@ class LightTestMigration {
|
||||
"\n" +
|
||||
"{5}" +
|
||||
"'}'\n",
|
||||
myTestClass.getPackage().getName(), imports, myTestClass.getSimpleName(), pathSpec, inspections, testMethods, guessedJdk, year);
|
||||
myTestClass.getPackage().getName(), imports, myTestClass.getSimpleName(), pathSpec, inspections, testMethods, year);
|
||||
System.out.println("Class template: (" + myTestClass.getSimpleName() + ".java)");
|
||||
System.out.println("==============================");
|
||||
System.out.println(classTemplate);
|
||||
@@ -203,14 +179,6 @@ class LightTestMigration {
|
||||
.map(name -> "import " + name + ";\n").collect(Collectors.joining());
|
||||
}
|
||||
|
||||
private String guessJdk() {
|
||||
String guessedJdk = JDK_MAP.getOrDefault(mySdk.getVersionString(), "JAVA_LATEST");
|
||||
if (mySdk.getRootProvider().getFiles(AnnotationOrderRootType.getInstance()).length != 0) {
|
||||
guessedJdk += "_ANNOTATED";
|
||||
}
|
||||
return guessedJdk;
|
||||
}
|
||||
|
||||
|
||||
private static String getExpectedText(Path javaFile, String fileText, JavaCodeInsightTestFixture javaFixture) {
|
||||
javaFixture.configureByText(javaFile.getFileName().toString(), fileText);
|
||||
|
||||
+1
@@ -49,6 +49,7 @@ public abstract class LightCodeInsightFixtureTestCase extends UsefulTestCase {
|
||||
}
|
||||
|
||||
@NotNull public static final LightProjectDescriptor JAVA_1_4 = new ProjectDescriptor(LanguageLevel.JDK_1_4);
|
||||
@NotNull public static final LightProjectDescriptor JAVA_1_4_ANNOTATED = new ProjectDescriptor(LanguageLevel.JDK_1_4, true);
|
||||
@NotNull public static final LightProjectDescriptor JAVA_1_5 = new ProjectDescriptor(LanguageLevel.JDK_1_5);
|
||||
@NotNull public static final LightProjectDescriptor JAVA_1_6 = new ProjectDescriptor(LanguageLevel.JDK_1_6);
|
||||
@NotNull public static final LightProjectDescriptor JAVA_1_7 = new ProjectDescriptor(LanguageLevel.JDK_1_7);
|
||||
|
||||
+2
-2
@@ -32,7 +32,7 @@ public class SSBasedInspectionTest extends InspectionTestCase {
|
||||
options.setSearchPattern("f();");
|
||||
configurations.add(configuration2);
|
||||
|
||||
inspection.setConfigurations(configurations, myProject);
|
||||
inspection.setConfigurations(configurations, getProject());
|
||||
myWrapper = new LocalInspectionToolWrapper(inspection);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class SSBasedInspectionTest extends InspectionTestCase {
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest("ssBased/" + getTestName(true), myWrapper,"java 1.5");
|
||||
doTest("ssBased/" + getTestName(true), myWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-10
@@ -4,8 +4,8 @@
|
||||
package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.codeInspection.booleanIsAlwaysInverted.BooleanMethodIsAlwaysInvertedInspection;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.siyeh.ig.IGInspectionTestCase;
|
||||
|
||||
public class BooleanMethodIsAlwaysInvertedInspectionTest extends IGInspectionTestCase {
|
||||
@@ -63,15 +63,7 @@ public class BooleanMethodIsAlwaysInvertedInspectionTest extends IGInspectionTes
|
||||
}
|
||||
|
||||
public void testMethodReferenceIgnored() {
|
||||
final LanguageLevelProjectExtension projectExtension = LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject());
|
||||
final LanguageLevel oldLevel = projectExtension.getLanguageLevel();
|
||||
try {
|
||||
projectExtension.setLanguageLevel(LanguageLevel.JDK_1_8);
|
||||
doTest();
|
||||
}
|
||||
finally {
|
||||
projectExtension.setLanguageLevel(oldLevel);
|
||||
}
|
||||
IdeaTestUtil.withLevel(myModule, LanguageLevel.JDK_1_8, () -> doTest());
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
|
||||
@@ -33,7 +33,7 @@ public abstract class IGInspectionTestCase extends InspectionTestCase {
|
||||
|
||||
@Override
|
||||
public void doTest(@NotNull @NonNls final String folderName, @NotNull final LocalInspectionTool tool) {
|
||||
super.doTest(folderName, new LocalInspectionToolWrapper(tool), "java 1.5");
|
||||
super.doTest(folderName, new LocalInspectionToolWrapper(tool));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-8
@@ -1,19 +1,11 @@
|
||||
package com.siyeh.ig.style;
|
||||
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleSettings;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.siyeh.ig.IGInspectionTestCase;
|
||||
|
||||
public class UnnecessaryFullyQualifiedNameInspectionTest extends IGInspectionTestCase {
|
||||
private static final String BASE_DIR = "com/siyeh/igtest/style/";
|
||||
|
||||
@Override
|
||||
protected Sdk getTestProjectSdk() {
|
||||
// uses awt
|
||||
return IdeaTestUtil.getMockJdk17();
|
||||
}
|
||||
|
||||
public void testFqnInJavadoc_Unnecessary_WhenFullyQualifyIfNotImported() {
|
||||
doTestWithFqnInJavadocSetting(BASE_DIR + "unnecessary_fqn_javadoc_fully_qualify_if_not_imported", JavaCodeStyleSettings.FULLY_QUALIFY_NAMES_IF_NOT_IMPORTED);
|
||||
}
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ import com.intellij.testFramework.InspectionTestCase;
|
||||
public class InvalidPropertyKeyInspectionTest extends InspectionTestCase {
|
||||
private void doTest() {
|
||||
LocalInspectionToolWrapper tool = new LocalInspectionToolWrapper(new InvalidPropertyKeyInspection());
|
||||
doTest("invalidPropertyKey/" + getTestName(true), tool, "java 1.5");
|
||||
doTest("invalidPropertyKey/" + getTestName(true), tool);
|
||||
}
|
||||
|
||||
public void testSimple() {
|
||||
|
||||
+8
-20
@@ -35,8 +35,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
|
||||
public class DuplicatePropertyInspection extends GlobalSimpleInspectionTool {
|
||||
@@ -67,18 +65,13 @@ public class DuplicatePropertyInspection extends GlobalSimpleInspectionTool {
|
||||
HTMLComposer.appendAfterHeaderIndention(anchor);
|
||||
HTMLComposer.appendAfterHeaderIndention(anchor);
|
||||
anchor.append("<a HREF=\"");
|
||||
try {
|
||||
final PsiFile file = element.getContainingFile();
|
||||
if (file != null) {
|
||||
final VirtualFile virtualFile = file.getVirtualFile();
|
||||
if (virtualFile != null) {
|
||||
anchor.append(new URL(virtualFile.getUrl() + "#" + elementToLink.getTextRange().getStartOffset()));
|
||||
}
|
||||
final PsiFile file = element.getContainingFile();
|
||||
if (file != null) {
|
||||
final VirtualFile virtualFile = file.getVirtualFile();
|
||||
if (virtualFile != null) {
|
||||
anchor.append(virtualFile.getUrl()).append("#").append(elementToLink.getTextRange().getStartOffset());
|
||||
}
|
||||
}
|
||||
catch (MalformedURLException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
anchor.append("\">");
|
||||
anchor.append(elementToLink.getText().replaceAll("\\$", "\\\\\\$"));
|
||||
anchor.append("</a>");
|
||||
@@ -103,14 +96,9 @@ public class DuplicatePropertyInspection extends GlobalSimpleInspectionTool {
|
||||
final int lineNumber = doc.getLineNumber(psiElement.getTextOffset()) + 1;
|
||||
lineAnchor.append(" ").append(InspectionsBundle.message("inspection.export.results.at.line")).append(" ");
|
||||
lineAnchor.append("<a HREF=\"");
|
||||
try {
|
||||
int offset = doc.getLineStartOffset(lineNumber - 1);
|
||||
offset = CharArrayUtil.shiftForward(doc.getCharsSequence(), offset, " \t");
|
||||
lineAnchor.append(new URL(vFile.getUrl() + "#" + offset));
|
||||
}
|
||||
catch (MalformedURLException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
int offset = doc.getLineStartOffset(lineNumber - 1);
|
||||
offset = CharArrayUtil.shiftForward(doc.getCharsSequence(), offset, " \t");
|
||||
lineAnchor.append(vFile.getUrl()).append("#").append(offset);
|
||||
lineAnchor.append("\">");
|
||||
lineAnchor.append(lineNumber);
|
||||
lineAnchor.append("</a>");
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ public class I18NInspectionTest extends InspectionTestCase {
|
||||
public void testFormTabbedPaneTitle() {
|
||||
LocalInspectionToolWrapper wrapper = new LocalInspectionToolWrapper(new I18nFormInspection());
|
||||
InspectionsKt.enableInspectionTool(getProject(), wrapper, getTestRootDisposable());
|
||||
doTest("i18n/" + getTestName(true), new LocalInspectionToolWrapper(new I18nInspection()), "java 1.4", false, false,
|
||||
doTest("i18n/" + getTestName(true), new LocalInspectionToolWrapper(new I18nInspection()), false, false,
|
||||
wrapper);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user