mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[tests] javadoc highlighting tests merger and cleanup
This commit is contained in:
+39
-44
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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,26 +23,22 @@ import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.openapi.vcs.IssueNavigationConfiguration;
|
||||
import com.intellij.openapi.vcs.IssueNavigationLink;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiRecursiveElementWalkingVisitor;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.psi.PsiReferenceBase;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class JavadocHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
private static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/javaDoc";
|
||||
|
||||
private JavaDocLocalInspection myInspection;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.HIGHEST);
|
||||
myInspection = new JavaDocLocalInspection();
|
||||
myInspection.setIgnoreDuplicatedThrows(false);
|
||||
enableInspectionTools(myInspection, new JavaDocReferenceInspection());
|
||||
@@ -51,14 +47,14 @@ public class JavadocHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return JavaTestUtil.getJavaTestDataPath();
|
||||
return JavaTestUtil.getJavaTestDataPath() + "/codeInsight/daemonCodeAnalyzer/javaDoc/";
|
||||
}
|
||||
|
||||
public void testJavadocPeriod() { myInspection.IGNORE_JAVADOC_PERIOD = false; doTest(); }
|
||||
public void testJavadocPeriod1() { myInspection.IGNORE_JAVADOC_PERIOD = false; doTest(); }
|
||||
public void testJavadocPeriod2() { myInspection.IGNORE_JAVADOC_PERIOD = false; doTest(); }
|
||||
public void testInlineTagAsDescription() { doTest(); }
|
||||
public void testParam0() { doTestWithLangLevel(LanguageLevel.HIGHEST); }
|
||||
public void testParam0() { doTest(); }
|
||||
public void testParam1() { doTest(); }
|
||||
public void testParam2() { doTest(); }
|
||||
public void testParam3() { doTest(); }
|
||||
@@ -81,14 +77,14 @@ public class JavadocHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testInheritJavaDoc() { doTestWithLangLevel(LanguageLevel.JDK_1_3); }
|
||||
public void testLink0() { doTest(); }
|
||||
public void testLinkFromInnerClassToSelfMethod() { doTest(); }
|
||||
public void testValueBadReference() { doTestWithLangLevel(LanguageLevel.HIGHEST); }
|
||||
public void testValueGoodReference() { doTestWithLangLevel(LanguageLevel.HIGHEST); }
|
||||
public void testValueBadReference() { doTest(); }
|
||||
public void testValueGoodReference() { doTest(); }
|
||||
public void testValueReference14() { doTestWithLangLevel(LanguageLevel.JDK_1_4); }
|
||||
public void testValueEmpty() { doTestWithLangLevel(LanguageLevel.JDK_1_4); }
|
||||
public void testValueNotOnField() { doTestWithLangLevel(LanguageLevel.HIGHEST); }
|
||||
public void testValueNotOnStaticField() { doTestWithLangLevel(LanguageLevel.HIGHEST); }
|
||||
public void testValueOnNotInitializedField() { doTestWithLangLevel(LanguageLevel.HIGHEST); }
|
||||
public void testJava18Tags() { doTestWithLangLevel(LanguageLevel.JDK_1_8); }
|
||||
public void testValueEmpty() { doTest(); }
|
||||
public void testValueNotOnField() { doTest(); }
|
||||
public void testValueNotOnStaticField() { doTest(); }
|
||||
public void testValueOnNotInitializedField() { doTest(); }
|
||||
public void testJava18Tags() { doTest(); }
|
||||
public void testUnknownInlineTag() { doTest(); }
|
||||
public void testUnknownTags() { doTest(); }
|
||||
public void testBadCharacters() { doTest(); }
|
||||
@@ -97,49 +93,48 @@ public class JavadocHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testBadReference() { doTest(); }
|
||||
public void testMissingReturnDescription() { doTest(); }
|
||||
public void testDoubleParenthesesInCode() { doTest(); }
|
||||
public void testDuplicateParam() { doTest(); }
|
||||
public void testDuplicateReturn() { doTest(); }
|
||||
public void testDuplicateDeprecated() { doTest(); }
|
||||
public void testDuplicateSerial() { doTest(); }
|
||||
public void testDuplicateThrows() { doTest(); }
|
||||
public void testMissedTags() { doTest(); }
|
||||
public void testDoubleMissedTags() { doTest(); }
|
||||
public void testMissedThrowsTag() { myInspection.METHOD_OPTIONS.ACCESS_JAVADOC_REQUIRED_FOR = "package"; doTest(); }
|
||||
public void testMisplacedThrowsTag() { doTest(); }
|
||||
public void testGenericsParams() { doTest(); }
|
||||
public void testEnumConstructor() { myInspection.METHOD_OPTIONS.ACCESS_JAVADOC_REQUIRED_FOR = "package"; doTest(); }
|
||||
public void testIgnoreDuplicateThrows() { myInspection.setIgnoreDuplicatedThrows(true); doTest(); }
|
||||
public void testIgnoreAccessors() { myInspection.setIgnoreSimpleAccessors(true); doTest(); }
|
||||
|
||||
public void testIssueLinksInJavaDoc() {
|
||||
IssueNavigationConfiguration navigationConfiguration = IssueNavigationConfiguration.getInstance(getProject());
|
||||
List<IssueNavigationLink> oldLinks = navigationConfiguration.getLinks();
|
||||
try {
|
||||
IssueNavigationLink link = new IssueNavigationLink("ABC-\\d+", "http://example.com/$0");
|
||||
navigationConfiguration.setLinks(ContainerUtil.<IssueNavigationLink>newArrayList(link));
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
List<String> expected = ContainerUtil.newArrayList("http://example.com/ABC-1123", "http://example.com/ABC-2",
|
||||
"http://example.com/ABC-22", "http://example.com/ABC-11");
|
||||
List<String> actual = collectWebReferences().stream().map(WebReference::getUrl).collect(Collectors.toList());
|
||||
assertEquals(expected, actual);
|
||||
navigationConfiguration.setLinks(ContainerUtil.newArrayList(link));
|
||||
configureByFile(getTestName(false) + ".java");
|
||||
List<String> expected = ContainerUtil.newArrayList(
|
||||
"http://example.com/ABC-1123", "http://example.com/ABC-2", "http://example.com/ABC-22", "http://example.com/ABC-11");
|
||||
List<WebReference> refs = PlatformTestUtil.collectWebReferences(myFile);
|
||||
assertTrue(refs.stream().allMatch(PsiReferenceBase::isSoft));
|
||||
assertEquals(expected, refs.stream().map(WebReference::getUrl).collect(Collectors.toList()));
|
||||
}
|
||||
finally {
|
||||
navigationConfiguration.setLinks(oldLinks);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void testLinksInJavaDoc() {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
@SuppressWarnings("SpellCheckingInspection") Set<String> expected = ContainerUtil.newHashSet(
|
||||
configureByFile(getTestName(false) + ".java");
|
||||
Set<String> expected = ContainerUtil.newHashSet(
|
||||
"http://www.unicode.org/unicode/standard/standard.html",
|
||||
"http://docs.oracle.com/javase/7/docs/technotes/guides/lang/cl-mt.html",
|
||||
"http://docs.oracle.com/javase/7/docs/tech-notes/guides/lang/cl-mt.html",
|
||||
"https://youtrack.jetbrains.com/issue/IDEA-131621",
|
||||
"mailto:webmaster@jetbrains.com");
|
||||
Set<String> actual = collectWebReferences().stream().map(PsiReferenceBase::getCanonicalText).collect(Collectors.toSet());
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<WebReference> collectWebReferences() {
|
||||
final List<WebReference> refs = new ArrayList<>();
|
||||
myFile.accept(new PsiRecursiveElementWalkingVisitor() {
|
||||
@Override
|
||||
public void visitElement(PsiElement element) {
|
||||
for (PsiReference ref : element.getReferences()) {
|
||||
if (ref instanceof WebReference) refs.add((WebReference)ref);
|
||||
}
|
||||
super.visitElement(element);
|
||||
}
|
||||
});
|
||||
List<WebReference> refs = PlatformTestUtil.collectWebReferences(myFile);
|
||||
assertTrue(refs.stream().allMatch(PsiReferenceBase::isSoft));
|
||||
return refs;
|
||||
assertEquals(expected, refs.stream().map(PsiReferenceBase::getCanonicalText).collect(Collectors.toSet()));
|
||||
}
|
||||
|
||||
private void doTestWithLangLevel(LanguageLevel level) {
|
||||
@@ -148,6 +143,6 @@ public class JavadocHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
}
|
||||
|
||||
protected void doTest() {
|
||||
super.doTest(BASE_PATH + "/" + getTestName(false) + ".java", true, false);
|
||||
super.doTest(getTestName(false) + ".java", true, false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user