Merge branch 'master' into japicmp
This commit is contained in:
@@ -8,7 +8,6 @@ import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
|
@@ -9,9 +9,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import net.sourceforge.pmd.test.lang.rule.AbstractRuleSetFactoryTest;
|
||||
import net.sourceforge.pmd.lang.rule.RuleSet;
|
||||
import net.sourceforge.pmd.lang.rule.RuleSetLoader;
|
||||
import net.sourceforge.pmd.test.lang.rule.AbstractRuleSetFactoryTest;
|
||||
|
||||
import com.github.stefanbirkner.systemlambda.SystemLambda;
|
||||
|
||||
|
@@ -6,8 +6,8 @@ package net.sourceforge.pmd.lang.apex.cpd;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import net.sourceforge.pmd.lang.test.cpd.CpdTextComparisonTest;
|
||||
import net.sourceforge.pmd.lang.apex.ApexLanguageModule;
|
||||
import net.sourceforge.pmd.lang.test.cpd.CpdTextComparisonTest;
|
||||
|
||||
class ApexCpdLexerTest extends CpdTextComparisonTest {
|
||||
|
||||
|
@@ -6,8 +6,8 @@ package net.sourceforge.pmd.lang.coco.cpd;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import net.sourceforge.pmd.lang.test.cpd.CpdTextComparisonTest;
|
||||
import net.sourceforge.pmd.lang.coco.CocoLanguageModule;
|
||||
import net.sourceforge.pmd.lang.test.cpd.CpdTextComparisonTest;
|
||||
|
||||
class CocoCpdLexerTest extends CpdTextComparisonTest {
|
||||
CocoCpdLexerTest() {
|
||||
|
@@ -12,9 +12,9 @@ import org.junit.jupiter.api.Test;
|
||||
import net.sourceforge.pmd.cpd.CpdLanguageProperties;
|
||||
import net.sourceforge.pmd.cpd.CpdLexer;
|
||||
import net.sourceforge.pmd.cpd.Tokens;
|
||||
import net.sourceforge.pmd.lang.cpp.CppLanguageModule;
|
||||
import net.sourceforge.pmd.lang.test.cpd.CpdTextComparisonTest;
|
||||
import net.sourceforge.pmd.lang.test.cpd.LanguagePropertyConfig;
|
||||
import net.sourceforge.pmd.lang.cpp.CppLanguageModule;
|
||||
|
||||
class CppCpdLexerTest extends CpdTextComparisonTest {
|
||||
|
||||
|
@@ -10,9 +10,9 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import net.sourceforge.pmd.cpd.CpdLanguageProperties;
|
||||
import net.sourceforge.pmd.lang.ast.LexException;
|
||||
import net.sourceforge.pmd.lang.test.cpd.CpdTextComparisonTest;
|
||||
import net.sourceforge.pmd.lang.test.cpd.LanguagePropertyConfig;
|
||||
import net.sourceforge.pmd.lang.ast.LexException;
|
||||
|
||||
class CsCpdLexerTest extends CpdTextComparisonTest {
|
||||
|
||||
|
@@ -4,8 +4,8 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.html.ast;
|
||||
|
||||
import net.sourceforge.pmd.lang.test.ast.BaseParsingHelper;
|
||||
import net.sourceforge.pmd.lang.html.HtmlLanguageModule;
|
||||
import net.sourceforge.pmd.lang.test.ast.BaseParsingHelper;
|
||||
|
||||
public final class HtmlParsingHelper extends BaseParsingHelper<HtmlParsingHelper, ASTHtmlDocument> {
|
||||
|
||||
|
@@ -7,8 +7,8 @@ package net.sourceforge.pmd.lang.html.cpd;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import net.sourceforge.pmd.lang.test.cpd.CpdTextComparisonTest;
|
||||
import net.sourceforge.pmd.lang.html.HtmlLanguageModule;
|
||||
import net.sourceforge.pmd.lang.test.cpd.CpdTextComparisonTest;
|
||||
|
||||
class HtmlCpdLexerTest extends CpdTextComparisonTest {
|
||||
|
||||
|
@@ -7,15 +7,18 @@ package net.sourceforge.pmd.lang.java.ast.internal;
|
||||
import static net.sourceforge.pmd.util.AssertionUtil.shouldNotReachHere;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTAmbiguousName;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTAnnotationTypeDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTArgumentList;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTArrayAccess;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTArrayType;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTCastExpression;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTClassDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTClassLiteral;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTClassType;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTConstructorCall;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTConstructorDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTEnumDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTExecutableDeclaration;
|
||||
@@ -30,6 +33,7 @@ import net.sourceforge.pmd.lang.java.ast.ASTList;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTLiteral;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTMethodCall;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTMethodReference;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTPrimaryExpression;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTPrimitiveType;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTRecordDeclaration;
|
||||
@@ -122,10 +126,10 @@ public final class PrettyPrintingUtil {
|
||||
}
|
||||
} else if (t instanceof ASTUnionType) {
|
||||
CollectionUtil.joinOn(sb, ((ASTUnionType) t).getComponents(),
|
||||
PrettyPrintingUtil::prettyPrintTypeNode, " | ");
|
||||
PrettyPrintingUtil::prettyPrintTypeNode, " | ");
|
||||
} else if (t instanceof ASTIntersectionType) {
|
||||
CollectionUtil.joinOn(sb, ((ASTIntersectionType) t).getComponents(),
|
||||
PrettyPrintingUtil::prettyPrintTypeNode, " & ");
|
||||
PrettyPrintingUtil::prettyPrintTypeNode, " & ");
|
||||
} else if (t instanceof ASTAmbiguousName) {
|
||||
sb.append(((ASTAmbiguousName) t).getName());
|
||||
} else {
|
||||
@@ -249,6 +253,7 @@ public final class PrettyPrintingUtil {
|
||||
|
||||
@Override
|
||||
public Void visitJavaNode(JavaNode node, StringBuilder data) {
|
||||
data.append("<<NOT_IMPLEMENTED: ").append(node).append(">>");
|
||||
return null; // don't recurse
|
||||
}
|
||||
|
||||
@@ -326,17 +331,39 @@ public final class PrettyPrintingUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visit(ASTAmbiguousName node, StringBuilder data) {
|
||||
data.append(node.getName());
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visit(ASTMethodCall node, StringBuilder sb) {
|
||||
addQualifier(node, sb);
|
||||
ppTypeArgs(sb, node.getExplicitTypeArguments());
|
||||
sb.append(node.getMethodName());
|
||||
if (node.getArguments().isEmpty()) {
|
||||
ppArguments(sb, node.getArguments());
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visit(ASTConstructorCall node, StringBuilder sb) {
|
||||
addQualifier(node, sb);
|
||||
sb.append("new ");
|
||||
ppTypeArgs(sb, node.getExplicitTypeArguments());
|
||||
prettyPrintTypeNode(sb, node.getTypeNode());
|
||||
ppArguments(sb, node.getArguments());
|
||||
return null;
|
||||
}
|
||||
|
||||
private void ppArguments(StringBuilder sb, ASTArgumentList arguments) {
|
||||
if (arguments.isEmpty()) {
|
||||
sb.append("()");
|
||||
} else {
|
||||
final int argStart = sb.length();
|
||||
sb.append('(');
|
||||
boolean first = true;
|
||||
for (ASTExpression arg : node.getArguments()) {
|
||||
for (ASTExpression arg : arguments) {
|
||||
if (sb.length() - argStart >= MAX_ARG_LENGTH) {
|
||||
sb.append("...");
|
||||
break;
|
||||
@@ -348,18 +375,30 @@ public final class PrettyPrintingUtil {
|
||||
}
|
||||
sb.append(')');
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visit(ASTMethodReference node, StringBuilder sb) {
|
||||
ppMaybeInParens(sb, node.getQualifier());
|
||||
sb.append("::");
|
||||
ppTypeArgs(sb, node.getExplicitTypeArguments());
|
||||
sb.append(node.getMethodName());
|
||||
return null;
|
||||
}
|
||||
|
||||
private void ppMaybeInParens(StringBuilder sb, ASTExpression qualifier) {
|
||||
if (!(qualifier instanceof ASTPrimaryExpression)) {
|
||||
ppInParens(sb, qualifier);
|
||||
} else {
|
||||
qualifier.acceptVisitor(this, sb);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void addQualifier(QualifiableExpression node, StringBuilder data) {
|
||||
ASTExpression qualifier = node.getQualifier();
|
||||
if (qualifier != null) {
|
||||
if (!(qualifier instanceof ASTPrimaryExpression)) {
|
||||
ppInParens(data, qualifier);
|
||||
} else {
|
||||
qualifier.acceptVisitor(this, data);
|
||||
}
|
||||
ppMaybeInParens(data, qualifier);
|
||||
data.append('.');
|
||||
}
|
||||
|
||||
@@ -371,6 +410,20 @@ public final class PrettyPrintingUtil {
|
||||
return data.append(')');
|
||||
}
|
||||
|
||||
|
||||
private void ppTypeArgs(StringBuilder data, @Nullable ASTTypeArguments targs) {
|
||||
if (targs == null) {
|
||||
return;
|
||||
}
|
||||
data.append('<');
|
||||
prettyPrintTypeNode(data, targs.get(0));
|
||||
for (int i = 1; i < targs.size(); i++) {
|
||||
data.append(", ");
|
||||
prettyPrintTypeNode(data, targs.get(i));
|
||||
}
|
||||
data.append('>');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@@ -4,6 +4,9 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.java.rule.bestpractices;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTBlock;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTMethodCall;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration;
|
||||
@@ -13,10 +16,6 @@ import net.sourceforge.pmd.properties.NumericConstraints;
|
||||
import net.sourceforge.pmd.properties.PropertyDescriptor;
|
||||
import net.sourceforge.pmd.properties.PropertyFactory;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class JUnitTestContainsTooManyAssertsRule extends AbstractJavaRulechainRule {
|
||||
|
||||
private static final PropertyDescriptor<Integer> MAX_ASSERTS =
|
||||
|
@@ -4,6 +4,9 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.java.rule.bestpractices;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTBlock;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTMethodCall;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration;
|
||||
@@ -12,9 +15,6 @@ import net.sourceforge.pmd.lang.java.rule.internal.TestFrameworksUtil;
|
||||
import net.sourceforge.pmd.properties.PropertyDescriptor;
|
||||
import net.sourceforge.pmd.properties.PropertyFactory;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class JUnitTestsShouldIncludeAssertRule extends AbstractJavaRulechainRule {
|
||||
|
||||
private static final PropertyDescriptor<Set<String>> EXTRA_ASSERT_METHOD_NAMES =
|
||||
|
@@ -55,8 +55,8 @@ import net.sourceforge.pmd.lang.java.types.TypeOps;
|
||||
import net.sourceforge.pmd.lang.java.types.TypeTestUtil;
|
||||
import net.sourceforge.pmd.properties.PropertyDescriptor;
|
||||
import net.sourceforge.pmd.properties.PropertyFactory;
|
||||
import net.sourceforge.pmd.util.OptionalBool;
|
||||
import net.sourceforge.pmd.reporting.RuleContext;
|
||||
import net.sourceforge.pmd.util.OptionalBool;
|
||||
|
||||
/**
|
||||
* This rule can detect possible violations of the Law of Demeter. The Law of
|
||||
|
@@ -11,13 +11,13 @@ import java.util.stream.Collectors;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
import net.sourceforge.pmd.lang.test.ast.RelevantAttributePrinter;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTExpression;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTModifierList;
|
||||
import net.sourceforge.pmd.lang.java.ast.JModifier;
|
||||
import net.sourceforge.pmd.lang.java.ast.ModifierOwner;
|
||||
import net.sourceforge.pmd.lang.rule.xpath.Attribute;
|
||||
import net.sourceforge.pmd.lang.test.ast.RelevantAttributePrinter;
|
||||
|
||||
/**
|
||||
* Special tweak to remove deprecated attributes of {@link ModifierOwner}
|
||||
|
@@ -24,7 +24,6 @@ import net.sourceforge.pmd.lang.LanguageProcessor;
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
import net.sourceforge.pmd.lang.ast.SemanticErrorReporter;
|
||||
import net.sourceforge.pmd.lang.ast.SemanticException;
|
||||
import net.sourceforge.pmd.lang.test.ast.BaseParsingHelper;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit;
|
||||
import net.sourceforge.pmd.lang.java.ast.JavaParser;
|
||||
import net.sourceforge.pmd.lang.java.internal.JavaAstProcessor;
|
||||
@@ -33,6 +32,7 @@ import net.sourceforge.pmd.lang.java.types.TypeSystem;
|
||||
import net.sourceforge.pmd.lang.java.types.internal.infer.TypeInferenceLogger;
|
||||
import net.sourceforge.pmd.lang.java.types.internal.infer.TypeInferenceLogger.SimpleLogger;
|
||||
import net.sourceforge.pmd.lang.java.types.internal.infer.TypeInferenceLogger.VerboseLogger;
|
||||
import net.sourceforge.pmd.lang.test.ast.BaseParsingHelper;
|
||||
import net.sourceforge.pmd.util.log.PmdReporter;
|
||||
import net.sourceforge.pmd.util.log.internal.SimpleMessageReporter;
|
||||
|
||||
|
@@ -10,8 +10,8 @@ import static net.sourceforge.pmd.test.AbstractLanguageVersionTest.TestDescripto
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import net.sourceforge.pmd.test.AbstractLanguageVersionTest;
|
||||
import net.sourceforge.pmd.lang.Language;
|
||||
import net.sourceforge.pmd.test.AbstractLanguageVersionTest;
|
||||
|
||||
class LanguageVersionTest extends AbstractLanguageVersionTest {
|
||||
|
||||
|
@@ -9,9 +9,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import net.sourceforge.pmd.test.lang.rule.AbstractRuleSetFactoryTest;
|
||||
import net.sourceforge.pmd.lang.rule.RuleSet;
|
||||
import net.sourceforge.pmd.lang.rule.RuleSetLoader;
|
||||
import net.sourceforge.pmd.test.lang.rule.AbstractRuleSetFactoryTest;
|
||||
|
||||
import com.github.stefanbirkner.systemlambda.SystemLambda;
|
||||
|
||||
|
@@ -16,9 +16,9 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import net.sourceforge.pmd.lang.ast.ParseException;
|
||||
import net.sourceforge.pmd.lang.test.ast.BaseParsingHelper;
|
||||
import net.sourceforge.pmd.lang.java.BaseJavaTreeDumpTest;
|
||||
import net.sourceforge.pmd.lang.java.JavaParsingHelper;
|
||||
import net.sourceforge.pmd.lang.test.ast.BaseParsingHelper;
|
||||
|
||||
class JDKVersionTest extends BaseJavaTreeDumpTest {
|
||||
|
||||
|
@@ -11,9 +11,9 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import net.sourceforge.pmd.lang.ast.ParseException;
|
||||
import net.sourceforge.pmd.lang.test.ast.BaseParsingHelper;
|
||||
import net.sourceforge.pmd.lang.java.BaseJavaTreeDumpTest;
|
||||
import net.sourceforge.pmd.lang.java.JavaParsingHelper;
|
||||
import net.sourceforge.pmd.lang.test.ast.BaseParsingHelper;
|
||||
|
||||
/**
|
||||
* Tests new java14 standard features.
|
||||
|
@@ -9,9 +9,9 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import net.sourceforge.pmd.lang.ast.ParseException;
|
||||
import net.sourceforge.pmd.lang.test.ast.BaseParsingHelper;
|
||||
import net.sourceforge.pmd.lang.java.BaseJavaTreeDumpTest;
|
||||
import net.sourceforge.pmd.lang.java.JavaParsingHelper;
|
||||
import net.sourceforge.pmd.lang.test.ast.BaseParsingHelper;
|
||||
|
||||
class Java15TreeDumpTest extends BaseJavaTreeDumpTest {
|
||||
private final JavaParsingHelper java15 =
|
||||
|
@@ -18,11 +18,11 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import net.sourceforge.pmd.lang.ast.NodeStream;
|
||||
import net.sourceforge.pmd.lang.ast.ParseException;
|
||||
import net.sourceforge.pmd.lang.test.ast.BaseParsingHelper;
|
||||
import net.sourceforge.pmd.lang.java.BaseJavaTreeDumpTest;
|
||||
import net.sourceforge.pmd.lang.java.JavaParsingHelper;
|
||||
import net.sourceforge.pmd.lang.java.symbols.JElementSymbol;
|
||||
import net.sourceforge.pmd.lang.java.types.JPrimitiveType;
|
||||
import net.sourceforge.pmd.lang.test.ast.BaseParsingHelper;
|
||||
|
||||
class Java16TreeDumpTest extends BaseJavaTreeDumpTest {
|
||||
private final JavaParsingHelper java16 =
|
||||
|
@@ -10,9 +10,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import net.sourceforge.pmd.lang.ast.ParseException;
|
||||
import net.sourceforge.pmd.lang.test.ast.BaseParsingHelper;
|
||||
import net.sourceforge.pmd.lang.java.BaseJavaTreeDumpTest;
|
||||
import net.sourceforge.pmd.lang.java.JavaParsingHelper;
|
||||
import net.sourceforge.pmd.lang.test.ast.BaseParsingHelper;
|
||||
|
||||
class Java17TreeDumpTest extends BaseJavaTreeDumpTest {
|
||||
private final JavaParsingHelper java17 =
|
||||
|
@@ -7,9 +7,9 @@ package net.sourceforge.pmd.lang.java.ast;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import net.sourceforge.pmd.lang.test.ast.BaseParsingHelper;
|
||||
import net.sourceforge.pmd.lang.java.BaseJavaTreeDumpTest;
|
||||
import net.sourceforge.pmd.lang.java.JavaParsingHelper;
|
||||
import net.sourceforge.pmd.lang.test.ast.BaseParsingHelper;
|
||||
|
||||
class Java9TreeDumpTest extends BaseJavaTreeDumpTest {
|
||||
|
||||
|
@@ -20,12 +20,12 @@ import org.junit.jupiter.api.Timeout;
|
||||
|
||||
import net.sourceforge.pmd.lang.ast.ParseException;
|
||||
import net.sourceforge.pmd.lang.ast.impl.javacc.MalformedSourceException;
|
||||
import net.sourceforge.pmd.lang.test.ast.BaseParsingHelper;
|
||||
import net.sourceforge.pmd.lang.document.FileId;
|
||||
import net.sourceforge.pmd.lang.java.BaseJavaTreeDumpTest;
|
||||
import net.sourceforge.pmd.lang.java.JavaParsingHelper;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTAssignableExpr.ASTNamedReferenceExpr;
|
||||
import net.sourceforge.pmd.lang.java.types.AstTestUtil;
|
||||
import net.sourceforge.pmd.lang.test.ast.BaseParsingHelper;
|
||||
|
||||
class ParserCornersTest extends BaseJavaTreeDumpTest {
|
||||
private final JavaParsingHelper java = JavaParsingHelper.DEFAULT.withResourceContext(getClass());
|
||||
|
@@ -19,8 +19,10 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import net.sourceforge.pmd.lang.java.BaseParserTest;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTConstructorCall;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTMethodCall;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTMethodReference;
|
||||
import net.sourceforge.pmd.util.StringUtil;
|
||||
|
||||
class PrettyPrintingUtilTest extends BaseParserTest {
|
||||
@@ -59,6 +61,30 @@ class PrettyPrintingUtilTest extends BaseParserTest {
|
||||
assertThat(prettyPrint(m), contentEquals("((Object) this).foo(12)"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void ppMethodRef() {
|
||||
ASTCompilationUnit root = java.parse("class A { { foo(ASTW::meth); } }");
|
||||
@NonNull ASTMethodReference m = root.descendants(ASTMethodReference.class).firstOrThrow();
|
||||
|
||||
assertThat(prettyPrint(m), contentEquals("ASTW::meth"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void ppCtorCall() {
|
||||
ASTCompilationUnit root = java.parse("class A { { new Foo(1); } }");
|
||||
@NonNull ASTConstructorCall m = root.descendants(ASTConstructorCall.class).firstOrThrow();
|
||||
|
||||
assertThat(prettyPrint(m), contentEquals("new Foo(1)"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void ppMethodRefWithTyArgs() {
|
||||
ASTCompilationUnit root = java.parse("class A { { foo(ASTW::<String>meth); } }");
|
||||
@NonNull ASTMethodReference m = root.descendants(ASTMethodReference.class).firstOrThrow();
|
||||
|
||||
assertThat(prettyPrint(m), contentEquals("ASTW::<String>meth"));
|
||||
}
|
||||
|
||||
private static Matcher<CharSequence> contentEquals(String str) {
|
||||
return new BaseMatcher<CharSequence>() {
|
||||
@Override
|
||||
|
@@ -12,12 +12,12 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import net.sourceforge.pmd.cpd.CpdLanguageProperties;
|
||||
import net.sourceforge.pmd.cpd.CpdLexer;
|
||||
import net.sourceforge.pmd.lang.test.cpd.CpdTextComparisonTest;
|
||||
import net.sourceforge.pmd.lang.test.cpd.LanguagePropertyConfig;
|
||||
import net.sourceforge.pmd.lang.ast.LexException;
|
||||
import net.sourceforge.pmd.lang.document.FileId;
|
||||
import net.sourceforge.pmd.lang.document.TextDocument;
|
||||
import net.sourceforge.pmd.lang.java.JavaLanguageModule;
|
||||
import net.sourceforge.pmd.lang.test.cpd.CpdTextComparisonTest;
|
||||
import net.sourceforge.pmd.lang.test.cpd.LanguagePropertyConfig;
|
||||
|
||||
class JavaCpdLexerTest extends CpdTextComparisonTest {
|
||||
|
||||
|
@@ -17,6 +17,7 @@ class JUnit4TestShouldUseAfterAnnotationTest extends PmdRuleTst {
|
||||
public void setUp() {
|
||||
// A setup code
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
// A tear down code
|
||||
|
@@ -17,6 +17,7 @@ class JUnit4TestShouldUseBeforeAnnotationTest extends PmdRuleTst {
|
||||
public void setUp() {
|
||||
// A setup code
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
// A tear down code
|
||||
|
@@ -1,11 +1,16 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.java.rule.internal;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import net.sourceforge.pmd.lang.java.JavaParsingHelper;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTMethodCall;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class TestFrameworksUtilTest {
|
||||
|
||||
|
@@ -10,9 +10,6 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
import net.sourceforge.pmd.lang.test.ast.BaseParsingHelper;
|
||||
import net.sourceforge.pmd.lang.test.ast.BaseTreeDumpTest;
|
||||
import net.sourceforge.pmd.lang.test.ast.RelevantAttributePrinter;
|
||||
import net.sourceforge.pmd.lang.java.JavaParsingHelper;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTAssignableExpr.ASTNamedReferenceExpr;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration;
|
||||
@@ -20,6 +17,9 @@ import net.sourceforge.pmd.lang.java.ast.ASTVariableId;
|
||||
import net.sourceforge.pmd.lang.java.ast.InvocationNode;
|
||||
import net.sourceforge.pmd.lang.java.ast.TypeNode;
|
||||
import net.sourceforge.pmd.lang.rule.xpath.Attribute;
|
||||
import net.sourceforge.pmd.lang.test.ast.BaseParsingHelper;
|
||||
import net.sourceforge.pmd.lang.test.ast.BaseTreeDumpTest;
|
||||
import net.sourceforge.pmd.lang.test.ast.RelevantAttributePrinter;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@@ -8,7 +8,6 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.mozilla.javascript.CompilerEnvirons;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user