mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 13:31:28 +07:00
[tests] javadoc highlighting tests merger and cleanup
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* @author me
|
||||
*/
|
||||
abstract class Foo {
|
||||
/**
|
||||
* @param <warning descr="'@param i' tag description is missing">i</warning>
|
||||
* @param <warning descr="'@param j' tag description is missing">j</warning>
|
||||
*/
|
||||
public abstract void foo(int i, int j);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* Test.
|
||||
* @deprecated You bet.
|
||||
* <warning descr="Duplicate @deprecated tag">@deprecated</warning> Gotcha.
|
||||
*/
|
||||
class Foo {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class Test {
|
||||
/**
|
||||
* Test.
|
||||
* @param s my string
|
||||
* <warning descr="Duplicate @param tag for parameter 's'">@param</warning> s another string
|
||||
*/
|
||||
void test(String s) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
class Test {
|
||||
/**
|
||||
* Test.
|
||||
* @return my string
|
||||
* <warning descr="Duplicate @return tag">@return</warning> another string
|
||||
*/
|
||||
String test() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ class Test {
|
||||
/**
|
||||
* Test.
|
||||
* @serial something
|
||||
* @serial something else
|
||||
* <warning descr="Duplicate @serial tag">@serial</warning> something else
|
||||
*/
|
||||
private int a;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class Test {
|
||||
/**
|
||||
* Test.
|
||||
* @throws java.lang.Exception in case of problems
|
||||
* <warning descr="Duplicate @throws or @exception tag for exception 'java.lang.Exception'">@exception</warning> java.lang.Exception in case of other problems
|
||||
*/
|
||||
void test() throws java.lang.Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
enum Foo {
|
||||
;
|
||||
|
||||
Foo() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class Foo {
|
||||
/**
|
||||
* description
|
||||
*
|
||||
* @param i this is a parameter
|
||||
* @param <T> type of object to do something with.
|
||||
*/
|
||||
public <T> void foo(T i){}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
public class Test {
|
||||
class Test {
|
||||
private int myFoo;
|
||||
|
||||
public int getFoo() {
|
||||
@@ -0,0 +1,8 @@
|
||||
class Test {
|
||||
/**
|
||||
* @throws ArrayIndexOutOfBoundsException in some case
|
||||
* @throws ArrayIndexOutOfBoundsException and in some other case
|
||||
*/
|
||||
void foo() throws ArrayIndexOutOfBoundsException {
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
* <i>The Unicode Standard</i></a>
|
||||
*/
|
||||
class LinksInJavaDoc {
|
||||
// Since Java 7 classloading is parallel on parallel capable classloader (http://docs.oracle.com/javase/7/docs/technotes/guides/lang/cl-mt.html)
|
||||
// Since Java 7 classloading is parallel on parallel capable classloader (http://docs.oracle.com/javase/7/docs/tech-notes/guides/lang/cl-mt.html)
|
||||
// Parallel classloading avoids deadlocks like https://youtrack.jetbrains.com/issue/IDEA-131621,
|
||||
// Use mailto:webmaster@jetbrains.com to report abuse
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
class Test {
|
||||
/**
|
||||
* @throws java.io.IOException exception in some case
|
||||
* @throws Exception exception in other case
|
||||
*/
|
||||
public void foo() throws Exception, java.io.IOException {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* @author me
|
||||
*/
|
||||
abstract class Foo {
|
||||
/**
|
||||
* @param i this is a parameter
|
||||
*/
|
||||
public abstract void foo(int i);
|
||||
}
|
||||
|
||||
/**
|
||||
* @author me
|
||||
*/
|
||||
class Bar extends Foo {
|
||||
/**
|
||||
*/
|
||||
public void foo(int i) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class Test {
|
||||
<warning descr="Required tag '@throws' java.io.IOException is missing">/**</warning>
|
||||
* @throws java.lang.ArrayIndexOutOfBoundsException in some case
|
||||
*/
|
||||
void foo() throws java.io.IOException, java.lang.ArrayIndexOutOfBoundsException {
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>Foo.java</file>
|
||||
<line>6</line>
|
||||
<description>missing</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>Foo.java</file>
|
||||
<line>7</line>
|
||||
<description>missing</description>
|
||||
</problem>
|
||||
</problems>
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
/**
|
||||
@author me
|
||||
*/
|
||||
public abstract class Foo {
|
||||
/**
|
||||
@param i
|
||||
@param j
|
||||
*/
|
||||
public abstract void foo(int i, int j);
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>Foo.java</file>
|
||||
<line>4</line>
|
||||
<description>Duplicate @deprecated tag</description>
|
||||
</problem>
|
||||
</problems>
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
/**
|
||||
* Test.
|
||||
* @deprecated You bet.
|
||||
* @deprecated Gotcha.
|
||||
*/
|
||||
class Foo {
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>Foo.java</file>
|
||||
<line>5</line>
|
||||
<description>Duplicate @param tag for parameter 's'</description>
|
||||
</problem>
|
||||
</problems>
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
class Test {
|
||||
/**
|
||||
* Test.
|
||||
* @param s my string
|
||||
* @param s another string
|
||||
*/
|
||||
void test(String s) {
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>Foo.java</file>
|
||||
<line>5</line>
|
||||
<description>Duplicate @return tag</description>
|
||||
</problem>
|
||||
</problems>
|
||||
@@ -1,9 +0,0 @@
|
||||
class Test {
|
||||
/**
|
||||
* Test.
|
||||
* @return my string
|
||||
* @return another string
|
||||
*/
|
||||
String test() {
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>Foo.java</file>
|
||||
<line>5</line>
|
||||
<description>Duplicate @serial tag</description>
|
||||
</problem>
|
||||
</problems>
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>Foo.java</file>
|
||||
<line>5</line>
|
||||
<description>Duplicate @throws tag for exception 'java.lang.Exception'</description>
|
||||
</problem>
|
||||
</problems>
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
class Test {
|
||||
/**
|
||||
* Test.
|
||||
* @throws java.lang.Exception in case of problems
|
||||
* @exception java.lang.Exception in case of other problems
|
||||
*/
|
||||
void test() throws java.lang.Exception {
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
</problems>
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
public enum Foo {
|
||||
;
|
||||
|
||||
Foo() {
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
</problems>
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
public class Foo {
|
||||
/**
|
||||
*description
|
||||
*@param i this is a parameter
|
||||
*@param <T> type of object to do something with.
|
||||
*/
|
||||
public <T> void foo(T i){}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
</problems>
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
</problems>
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
class Test {
|
||||
/**
|
||||
*@throws ArrayIndexOutOfBoundsException in some case
|
||||
*@throws ArrayIndexOutOfBoundsException and in some other case
|
||||
*/
|
||||
void foo() throws ArrayIndexOutOfBoundsException {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
</problems>
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
public class Test {
|
||||
/**
|
||||
* @throws java.io.IOException exception in some case
|
||||
* @throws Exception exception in other case
|
||||
*/
|
||||
public void foo() throws Exception, java.io.IOException {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
</problems>
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
/**
|
||||
@author me
|
||||
*/
|
||||
public class Bar extends Foo {
|
||||
/**
|
||||
*/
|
||||
public void foo(int i) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
/**
|
||||
@author me
|
||||
*/
|
||||
public abstract class Foo {
|
||||
/**
|
||||
@param i this is a parameter
|
||||
*/
|
||||
public abstract void foo(int i);
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>Test.java</file>
|
||||
<line>2</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Declaration has Javadoc problems</problem_class>
|
||||
<description>Required tag <code>@throws</code> java.io.IOException is missing</description>
|
||||
</problem>
|
||||
</problems>
|
||||
@@ -1,8 +0,0 @@
|
||||
class Test {
|
||||
/**
|
||||
*@throws java.lang.ArrayIndexOutOfBoundsException in some case
|
||||
*/
|
||||
void foo() throws java.io.IOException, java.lang.ArrayIndexOutOfBoundsException {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -1,87 +1,35 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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.ex.LocalInspectionToolWrapper;
|
||||
import com.intellij.codeInspection.javaDoc.JavaDocLocalInspection;
|
||||
import com.intellij.testFramework.InspectionTestCase;
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
|
||||
|
||||
public class JavaDocInspectionTest extends InspectionTestCase {
|
||||
public class JavaDocInspectionTest extends LightCodeInsightFixtureTestCase {
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return JavaTestUtil.getJavaTestDataPath() + "/inspection";
|
||||
protected String getBasePath() {
|
||||
return JavaTestUtil.getRelativeJavaTestDataPath() + "/inspection/javaDocInspection";
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest("javaDocInspection/" + getTestName(true), new JavaDocLocalInspection());
|
||||
}
|
||||
|
||||
public void testDuplicateParam() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testDuplicateReturn() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// tests for duplicate class tags
|
||||
public void testDuplicateDeprecated() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// tests for duplicate field tags
|
||||
public void testDuplicateSerial() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testDuplicateThrows() throws Exception {
|
||||
JavaDocLocalInspection tool = new JavaDocLocalInspection();
|
||||
tool.setIgnoreDuplicatedThrows(false);
|
||||
doTest("javaDocInspection/" + getTestName(true), tool);
|
||||
}
|
||||
|
||||
//inherited javadoc
|
||||
public void testMissedTags() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testDoubleMissedTags() throws Exception{
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testMissedThrowsTag() throws Exception {
|
||||
final JavaDocLocalInspection localInspection = new JavaDocLocalInspection();
|
||||
localInspection.METHOD_OPTIONS.ACCESS_JAVADOC_REQUIRED_FOR = "package";
|
||||
doTest("javaDocInspection/" + getTestName(true), localInspection);
|
||||
}
|
||||
|
||||
public void testMisorderedThrowsTag() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testGenericsParams() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testEnumConstructor() throws Exception {
|
||||
final JavaDocLocalInspection localInspection = new JavaDocLocalInspection();
|
||||
localInspection.METHOD_OPTIONS.ACCESS_JAVADOC_REQUIRED_FOR = "package";
|
||||
doTest("javaDocInspection/" + getTestName(true), localInspection);
|
||||
}
|
||||
|
||||
public void testIgnoreDuplicateThrows() throws Exception {
|
||||
final JavaDocLocalInspection inspection = new JavaDocLocalInspection();
|
||||
doTest("javaDocInspection/" + getTestName(true), inspection);
|
||||
}
|
||||
|
||||
public void testIgnoreAccessors() throws Exception {
|
||||
final JavaDocLocalInspection inspection = new JavaDocLocalInspection();
|
||||
inspection.setIgnoreSimpleAccessors(true);
|
||||
doTest("javaDocInspection/" + getTestName(true), inspection);
|
||||
}
|
||||
|
||||
public void testPackageInfo() throws Exception {
|
||||
final JavaDocLocalInspection inspection = new JavaDocLocalInspection();
|
||||
public void testPackageInfo() {
|
||||
JavaDocLocalInspection inspection = new JavaDocLocalInspection();
|
||||
inspection.IGNORE_DEPRECATED = true;
|
||||
inspection.setPackageOption("public", "@author");
|
||||
doTest("javaDocInspection/" + getTestName(true), inspection);
|
||||
myFixture.testInspection("packageInfo", new LocalInspectionToolWrapper(inspection));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,7 @@ import com.intellij.openapi.extensions.ExtensionsArea;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileEditor.impl.LoadTextUtil;
|
||||
import com.intellij.openapi.fileTypes.FileTypes;
|
||||
import com.intellij.openapi.paths.WebReference;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Queryable;
|
||||
import com.intellij.openapi.util.*;
|
||||
@@ -49,6 +50,9 @@ import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileFilter;
|
||||
import com.intellij.openapi.vfs.ex.temp.TempFileSystem;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiRecursiveElementWalkingVisitor;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.util.*;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import com.intellij.util.io.ZipUtil;
|
||||
@@ -915,4 +919,21 @@ public class PlatformTestUtil {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<WebReference> collectWebReferences(@NotNull PsiElement element) {
|
||||
List<WebReference> refs = new ArrayList<>();
|
||||
element.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);
|
||||
}
|
||||
});
|
||||
return refs;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -2208,29 +2208,14 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase {
|
||||
configureByFile(BASE_PATH +getTestName(false) + ".xml");
|
||||
doDoTest(true, false);
|
||||
|
||||
final List<WebReference> list = new ArrayList<WebReference>();
|
||||
List<WebReference> list = PlatformTestUtil.collectWebReferences(myFile);
|
||||
assertEquals(2, list.size());
|
||||
|
||||
myFile.accept(new XmlRecursiveElementWalkingVisitor() {
|
||||
@Override
|
||||
public void visitElement(PsiElement element) {
|
||||
for(PsiReference reference: element.getReferences()) {
|
||||
if (reference instanceof WebReference) list.add((WebReference)reference);
|
||||
}
|
||||
super.visitElement(element);
|
||||
}
|
||||
});
|
||||
|
||||
assertEquals(list.size(), 2);
|
||||
Collections.sort(list, new Comparator<WebReference>() {
|
||||
@Override
|
||||
public int compare(WebReference o1, WebReference o2) {
|
||||
return o1.getCanonicalText().length() - o2.getCanonicalText().length();
|
||||
}
|
||||
});
|
||||
Collections.sort(list, (o1, o2) -> o1.getCanonicalText().length() - o2.getCanonicalText().length());
|
||||
|
||||
assertEquals("https://www.jetbrains.com/ruby/download", list.get(0).getCanonicalText());
|
||||
assertTrue(list.get(0).getElement() instanceof XmlAttributeValue);
|
||||
assertEquals("http://blog.jetbrains.com/ruby/2012/04/rubymine-4-0-3-update-is-available/", list.get(1).getCanonicalText());
|
||||
assertTrue(list.get(1).getElement() instanceof XmlComment);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user