diff --git a/pmd-java/pom.xml b/pmd-java/pom.xml index ecfba6022e..6f083e3b69 100644 --- a/pmd-java/pom.xml +++ b/pmd-java/pom.xml @@ -18,7 +18,7 @@ ${basedir}/src/test/java - **/testdata/*.java + **/testdata/**/*.java diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java8Test.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java8Test.java new file mode 100644 index 0000000000..42af570ec6 --- /dev/null +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java8Test.java @@ -0,0 +1,23 @@ +/** + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.lang.java.ast; + +import org.junit.Test; + +import net.sourceforge.pmd.lang.java.ParserTstUtil; +import net.sourceforge.pmd.typeresolution.testdata.java8.UsesJavaStreams; +import net.sourceforge.pmd.typeresolution.testdata.java8.UsesRepeatableAnnotations; + +public class Java8Test { + @Test + public void interfaceMethodShouldBeParseable() { + ParserTstUtil.parseJava18(UsesJavaStreams.class); + } + + @Test + public void repeatableAnnotationsMethodShouldBeParseable() { + ParserTstUtil.parseJava18(UsesRepeatableAnnotations.class); + } +} diff --git a/pmd-java8/src/test/java/net/sourceforge/pmd/typeresolution/ClassTypeResolverJava8Test.java b/pmd-java/src/test/java/net/sourceforge/pmd/typeresolution/ClassTypeResolverJava8Test.java similarity index 53% rename from pmd-java8/src/test/java/net/sourceforge/pmd/typeresolution/ClassTypeResolverJava8Test.java rename to pmd-java/src/test/java/net/sourceforge/pmd/typeresolution/ClassTypeResolverJava8Test.java index 349023a998..7b608abea7 100644 --- a/pmd-java8/src/test/java/net/sourceforge/pmd/typeresolution/ClassTypeResolverJava8Test.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/typeresolution/ClassTypeResolverJava8Test.java @@ -6,42 +6,25 @@ package net.sourceforge.pmd.typeresolution; import static org.junit.Assert.assertEquals; -import java.io.InputStream; -import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import org.jaxen.JaxenException; import org.junit.Test; -import net.sourceforge.pmd.lang.LanguageRegistry; -import net.sourceforge.pmd.lang.LanguageVersionHandler; import net.sourceforge.pmd.lang.ast.Node; -import net.sourceforge.pmd.lang.java.JavaLanguageModule; +import net.sourceforge.pmd.lang.java.ParserTstUtil; import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit; import net.sourceforge.pmd.lang.java.ast.ASTPrimaryExpression; import net.sourceforge.pmd.lang.java.ast.ASTPrimaryPrefix; import net.sourceforge.pmd.lang.java.ast.AbstractJavaTypeNode; -import net.sourceforge.pmd.typeresolution.testdata.SuperClass; -import net.sourceforge.pmd.typeresolution.testdata.SuperExpression; -import net.sourceforge.pmd.typeresolution.testdata.ThisExpression; -import net.sourceforge.pmd.typeresolution.testdata.UsesJavaStreams; -import net.sourceforge.pmd.typeresolution.testdata.UsesRepeatableAnnotations; +import net.sourceforge.pmd.typeresolution.testdata.java8.SuperClass; +import net.sourceforge.pmd.typeresolution.testdata.java8.SuperExpression; +import net.sourceforge.pmd.typeresolution.testdata.java8.ThisExpression; public class ClassTypeResolverJava8Test { - - @Test - public void interfaceMethodShouldBeParseable() { - ASTCompilationUnit acu = parseAndTypeResolveForClass18(UsesJavaStreams.class); - } - - @Test - public void repeatableAnnotationsMethodShouldBeParseable() { - ASTCompilationUnit acu = parseAndTypeResolveForClass18(UsesRepeatableAnnotations.class); - } - @Test public void testThisExpression() throws JaxenException { ASTCompilationUnit acu = parseAndTypeResolveForClass18(ThisExpression.class); @@ -90,27 +73,7 @@ public class ClassTypeResolverJava8Test { } private ASTCompilationUnit parseAndTypeResolveForClass18(Class clazz) { - return parseAndTypeResolveForClass(clazz, "1.8"); - } - - // Note: If you're using Eclipse or some other IDE to run this test, you - // _must_ have the regress folder in - // the classpath. Normally the IDE doesn't put source directories themselves - // directly in the classpath, only - // the output directories are in the classpath. - private ASTCompilationUnit parseAndTypeResolveForClass(Class clazz, String version) { - String sourceFile = clazz.getName().replace('.', '/') + ".java"; - InputStream is = ClassTypeResolverJava8Test.class.getClassLoader().getResourceAsStream(sourceFile); - if (is == null) { - throw new IllegalArgumentException("Unable to find source file " + sourceFile + " for " + clazz); - } - LanguageVersionHandler languageVersionHandler = LanguageRegistry.getLanguage(JavaLanguageModule.NAME) - .getVersion(version).getLanguageVersionHandler(); - ASTCompilationUnit acu = (ASTCompilationUnit) languageVersionHandler - .getParser(languageVersionHandler.getDefaultParserOptions()).parse(null, new InputStreamReader(is)); - languageVersionHandler.getSymbolFacade().start(acu); - languageVersionHandler.getQualifiedNameResolutionFacade(ClassTypeResolverJava8Test.class.getClassLoader()).start(acu); - languageVersionHandler.getTypeResolutionFacade(ClassTypeResolverJava8Test.class.getClassLoader()).start(acu); - return acu; + String source = ParserTstUtil.getSourceFromClass(clazz); + return ParserTstUtil.parseAndTypeResolveJava("1.8", source); } } diff --git a/pmd-java8/src/test/java/net/sourceforge/pmd/typeresolution/testdata/SuperClass.java b/pmd-java/src/test/java/net/sourceforge/pmd/typeresolution/testdata/java8/SuperClass.java similarity index 71% rename from pmd-java8/src/test/java/net/sourceforge/pmd/typeresolution/testdata/SuperClass.java rename to pmd-java/src/test/java/net/sourceforge/pmd/typeresolution/testdata/java8/SuperClass.java index 8948350c58..06d23d09be 100644 --- a/pmd-java8/src/test/java/net/sourceforge/pmd/typeresolution/testdata/SuperClass.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/typeresolution/testdata/java8/SuperClass.java @@ -3,7 +3,7 @@ */ -package net.sourceforge.pmd.typeresolution.testdata; +package net.sourceforge.pmd.typeresolution.testdata.java8; public class SuperClass { protected SuperClass s; diff --git a/pmd-java8/src/test/java/net/sourceforge/pmd/typeresolution/testdata/SuperExpression.java b/pmd-java/src/test/java/net/sourceforge/pmd/typeresolution/testdata/java8/SuperExpression.java similarity index 82% rename from pmd-java8/src/test/java/net/sourceforge/pmd/typeresolution/testdata/SuperExpression.java rename to pmd-java/src/test/java/net/sourceforge/pmd/typeresolution/testdata/java8/SuperExpression.java index 12d94fb786..42d45e79ef 100644 --- a/pmd-java8/src/test/java/net/sourceforge/pmd/typeresolution/testdata/SuperExpression.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/typeresolution/testdata/java8/SuperExpression.java @@ -3,7 +3,7 @@ */ -package net.sourceforge.pmd.typeresolution.testdata; +package net.sourceforge.pmd.typeresolution.testdata.java8; public class SuperExpression extends SuperClass { public void foo() { diff --git a/pmd-java8/src/test/java/net/sourceforge/pmd/typeresolution/testdata/ThisExpression.java b/pmd-java/src/test/java/net/sourceforge/pmd/typeresolution/testdata/java8/ThisExpression.java similarity index 86% rename from pmd-java8/src/test/java/net/sourceforge/pmd/typeresolution/testdata/ThisExpression.java rename to pmd-java/src/test/java/net/sourceforge/pmd/typeresolution/testdata/java8/ThisExpression.java index 926d7e9afd..a3cc822e19 100644 --- a/pmd-java8/src/test/java/net/sourceforge/pmd/typeresolution/testdata/ThisExpression.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/typeresolution/testdata/java8/ThisExpression.java @@ -3,7 +3,7 @@ */ -package net.sourceforge.pmd.typeresolution.testdata; +package net.sourceforge.pmd.typeresolution.testdata.java8; public class ThisExpression { diff --git a/pmd-java8/src/test/java/net/sourceforge/pmd/typeresolution/testdata/UsesJavaStreams.java b/pmd-java/src/test/java/net/sourceforge/pmd/typeresolution/testdata/java8/UsesJavaStreams.java similarity index 89% rename from pmd-java8/src/test/java/net/sourceforge/pmd/typeresolution/testdata/UsesJavaStreams.java rename to pmd-java/src/test/java/net/sourceforge/pmd/typeresolution/testdata/java8/UsesJavaStreams.java index 0fc2dffb0a..17de9bf023 100644 --- a/pmd-java8/src/test/java/net/sourceforge/pmd/typeresolution/testdata/UsesJavaStreams.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/typeresolution/testdata/java8/UsesJavaStreams.java @@ -2,7 +2,7 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.typeresolution.testdata; +package net.sourceforge.pmd.typeresolution.testdata.java8; public class UsesJavaStreams { interface WithStaticAndDefaultMethod { diff --git a/pmd-java8/src/test/java/net/sourceforge/pmd/typeresolution/testdata/UsesRepeatableAnnotations.java b/pmd-java/src/test/java/net/sourceforge/pmd/typeresolution/testdata/java8/UsesRepeatableAnnotations.java similarity index 78% rename from pmd-java8/src/test/java/net/sourceforge/pmd/typeresolution/testdata/UsesRepeatableAnnotations.java rename to pmd-java/src/test/java/net/sourceforge/pmd/typeresolution/testdata/java8/UsesRepeatableAnnotations.java index cbf4ad7afd..bb5aed45b4 100644 --- a/pmd-java8/src/test/java/net/sourceforge/pmd/typeresolution/testdata/UsesRepeatableAnnotations.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/typeresolution/testdata/java8/UsesRepeatableAnnotations.java @@ -2,13 +2,13 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.typeresolution.testdata; +package net.sourceforge.pmd.typeresolution.testdata.java8; import java.lang.annotation.Repeatable; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import net.sourceforge.pmd.typeresolution.testdata.UsesRepeatableAnnotations.Multitude; +import net.sourceforge.pmd.typeresolution.testdata.java8.UsesRepeatableAnnotations.Multitude; @Multitude("1") @Multitude("2") diff --git a/pmd-java8/pom.xml b/pmd-java8/pom.xml deleted file mode 100644 index 49a56524a7..0000000000 --- a/pmd-java8/pom.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - 4.0.0 - pmd-java8 - PMD Java 8 Integration - - - net.sourceforge.pmd - pmd - 7.0.0-SNAPSHOT - - - - - - ${basedir}/src/test/resources - - - ${basedir}/src/test/java - - **/testdata/*.java - - - - - - ${basedir}/src/main/resources - true - - - - - maven-resources-plugin - - false - - ${*} - - - - - - - - net.sourceforge.pmd - pmd-java - ${project.version} - - - - net.sourceforge.pmd - pmd-core - - - - junit - junit - test - - - diff --git a/pmd-java8/src/test/java/net/sourceforge/pmd/lang/java/bugs/InterfaceMethodTest.java b/pmd-java8/src/test/java/net/sourceforge/pmd/lang/java/bugs/InterfaceMethodTest.java deleted file mode 100644 index af097bbd7f..0000000000 --- a/pmd-java8/src/test/java/net/sourceforge/pmd/lang/java/bugs/InterfaceMethodTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * BSD-style license; for more info see http://pmd.sourceforge.net/license.html - */ - -package net.sourceforge.pmd.lang.java.bugs; - -import java.io.InputStream; -import java.io.InputStreamReader; - -import org.junit.Ignore; -import org.junit.Test; - -import net.sourceforge.pmd.lang.LanguageRegistry; -import net.sourceforge.pmd.lang.LanguageVersionHandler; -import net.sourceforge.pmd.lang.java.JavaLanguageModule; -import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit; -import net.sourceforge.pmd.typeresolution.testdata.UsesJavaStreams; - -@Ignore -public class InterfaceMethodTest { - - @Test - public void shouldNotFail() { - ASTCompilationUnit acu = parseAndTypeResolveForClass(UsesJavaStreams.class); - } - - // Note: If you're using Eclipse or some other IDE to run this test, you - // _must_ have the regress folder in - // the classpath. Normally the IDE doesn't put source directories themselves - // directly in the classpath, only - // the output directories are in the classpath. - private ASTCompilationUnit parseAndTypeResolveForClass(Class clazz) { - String sourceFile = clazz.getName().replace('.', '/') + ".java"; - InputStream is = InterfaceMethodTest.class.getClassLoader().getResourceAsStream(sourceFile); - if (is == null) { - throw new IllegalArgumentException("Unable to find source file " + sourceFile + " for " + clazz); - } - LanguageVersionHandler languageVersionHandler = LanguageRegistry.getLanguage(JavaLanguageModule.NAME) - .getVersion("1.8").getLanguageVersionHandler(); - ASTCompilationUnit acu = (ASTCompilationUnit) languageVersionHandler - .getParser(languageVersionHandler.getDefaultParserOptions()).parse(null, new InputStreamReader(is)); - languageVersionHandler.getSymbolFacade().start(acu); - languageVersionHandler.getTypeResolutionFacade(InterfaceMethodTest.class.getClassLoader()).start(acu); - return acu; - } -} diff --git a/pom.xml b/pom.xml index 43727a859a..3683608b73 100644 --- a/pom.xml +++ b/pom.xml @@ -1156,7 +1156,6 @@ Additionally it includes CPD, the copy-paste-detector. CPD finds duplicated code pmd-go pmd-groovy pmd-java - pmd-java8 pmd-javascript pmd-jsp pmd-kotlin