Applied patch 3411811: Java 7 support for PMD, thanks to Dinesh Bolkensteyn and SonarSource.

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/branches/pmd/4.3.x@7396 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Romain Pelisse committed 2011-10-13 15:40:35 +00:00
1 parent 85914a9a2c
commit a050468aea
41 files changed
+3262 -2395

No files matched your search

+1
View File
@@ -1,5 +1,6 @@
?? ??, 201? - 4.3:
Add support for Java 7 grammer - thanks to Dinesh Bolkensteyn and SonarSource
Add options --ignore-literals and --ignore-identifiers to the CPD command line task, thanks to Cd-Man
Fixed character reference in xml report - thanks to Seko
Add C# support for CPD - thanks to Florian Bauer
+84 -36
View File
@@ -1,5 +1,9 @@
/**
*
* Added support for Java 7 language constructs
*
* Dinesh Bolkensteyn (SonarSource), 06/11
* ===================================================================
* Added in support for assert as a name using lookaheads
*
* Tom Copeland, 09/03
@@ -70,71 +74,84 @@ import java.util.*;
import net.sourceforge.pmd.PMD;
public class JavaParser {
private boolean isJDK13;
private boolean isJDK15;
private int jdkVersion = 0;
public void setJDK13() {
this.isJDK13 = true;
}
public void setJDK15() {
this.isJDK15 = true;
public void setJdkVersion(int jdkVersion) {
this.jdkVersion = jdkVersion;
}
private void checkForBadAssertUsage(String in, String usage) {
if (!isJDK13 && in.equals("assert")) {
if (jdkVersion > 3 && in.equals("assert")) {
throw new ParseException("Can't use 'assert' as " + usage + " when running in JDK 1.4 mode!");
}
}
private void checkForBadStaticImportUsage() {
if (!isJDK15) {
if (jdkVersion < 5) {
throw new ParseException("Can't use static imports when running in JDK 1.4 mode!");
}
}
private void checkForBadAnnotationUsage() {
if (!isJDK15) {
if (jdkVersion < 5) {
throw new ParseException("Can't use annotations when running in JDK 1.4 mode!");
}
}
private void checkForBadGenericsUsage() {
if (!isJDK15) {
if (jdkVersion < 5) {
throw new ParseException("Can't use generics unless running in JDK 1.5 mode!");
}
}
private void checkForBadVariableArgumentsUsage() {
if (!isJDK15) {
if (jdkVersion < 5) {
throw new ParseException("Can't use variable arguments (varargs) when running in JDK 1.4 mode!");
}
}
private void checkForBadJDK15ForLoopSyntaxArgumentsUsage() {
if (!isJDK15) {
if (jdkVersion < 5) {
throw new ParseException("Can't use JDK 1.5 for loop syntax when running in JDK 1.4 mode!");
}
}
private void checkForBadEnumUsage(String in, String usage) {
if (isJDK15 && in.equals("enum")) {
if (jdkVersion >= 5 && in.equals("enum")) {
throw new ParseException("Can't use 'enum' as " + usage + " when running in JDK 1.5 mode!");
}
}
private void checkForBadHexFloatingPointLiteral() {
if (!isJDK15) {
throw new ParseException("ERROR: Can't use hexadecimal floating point literals in pre-JDK 1.5 target");
if (jdkVersion < 5) {
throw new ParseException("Can't use hexadecimal floating point literals in pre-JDK 1.5 target");
}
}
private void checkForBadNumericalLiteralslUsage(Token token) {
if (jdkVersion < 7) {
if (token.image.contains("_")) {
throw new ParseException("Can't use underscores in numerical literals when running in JDK inferior to 1.7 mode!");
}
if (token.image.startsWith("0b") || token.image.startsWith("0B")) {
throw new ParseException("Can't use binary numerical literals when running in JDK inferior to 1.7 mode!");
}
}
}
private void checkForBadDiamondUsage() {
if (jdkVersion < 7) {
throw new ParseException("Cannot use the diamond generic notation when running in JDK inferior to 1.7 mode!");
}
}
// This is a semantic LOOKAHEAD to determine if we're dealing with an assert
// Note that this can't be replaced with a syntactic lookahead
// since "assert" isn't a string literal token
private boolean isNextTokenAnAssert() {
boolean res = getToken(1).image.equals("assert");
if (res && isJDK13 && getToken(2).image.equals("(")) {
if (res && jdkVersion <= 3 && getToken(2).image.equals("(")) {
res = false;
}
return res;
@@ -162,7 +179,7 @@ public class JavaParser {
}
PARSER_END(JavaParser)
TOKEN_MGR_DECLS : {
TOKEN_MGR_DECLS : {
protected List<Comment> comments = new ArrayList<Comment>();
private Map<Integer, String> excludeMap = new HashMap<Integer, String>();
@@ -286,27 +303,30 @@ TOKEN :
< INTEGER_LITERAL:
<DECIMAL_LITERAL> (["l","L"])?
| <HEX_LITERAL> (["l","L"])?
| <BINARY_LITERAL> (["l","L"])?
| <OCTAL_LITERAL> (["l","L"])?
>
|
< #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* >
< #DECIMAL_LITERAL: (["0"-"9"]((["0"-"9","_"])*["0"-"9"])?) >
|
< #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ >
< #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"]((["0"-"9","a"-"f","A"-"F","_"])*["0"-"9","a"-"f","A"-"F"])?) >
|
< #OCTAL_LITERAL: "0" (["0"-"7"])* >
< #BINARY_LITERAL: "0" ["b","B"] (["0","1"]((["0","1","_"])*["0","1"])?) >
|
< #OCTAL_LITERAL: "0" (["0"-"7"]((["0"-"7","_"])*["0"-"7"])?) >
|
< FLOATING_POINT_LITERAL:
(["0"-"9"])+ "." (["0"-"9"])* (<EXPONENT>)? (["f","F","d","D"])?
| "." (["0"-"9"])+ (<EXPONENT>)? (["f","F","d","D"])?
| (["0"-"9"])+ <EXPONENT> (["f","F","d","D"])?
| (["0"-"9"])+ (<EXPONENT>)? ["f","F","d","D"]
(["0"-"9"]((["0"-"9","_"])*["0"-"9"])?) "." (["0"-"9"]((["0"-"9","_"])*["0"-"9"])?)? (<EXPONENT>)? (["f","F","d","D"])?
| "." (["0"-"9"]((["0"-"9","_"])*["0"-"9"])?) (<EXPONENT>)? (["f","F","d","D"])?
| (["0"-"9"]((["0"-"9","_"])*["0"-"9"])?) <EXPONENT> (["f","F","d","D"])?
| (["0"-"9"]((["0"-"9","_"])*["0"-"9"])?) (<EXPONENT>)? ["f","F","d","D"]
>
|
< HEX_FLOATING_POINT_LITERAL:
(<HEX_LITERAL> (".")? | "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])* "." (["0"-"9","a"-"f","A"-"F"])+) ["p","P"] (["+","-"])? (["0"-"9"])+ (["f","F","d","D"])?
(<HEX_LITERAL> (".")? | "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"]((["0"-"9","a"-"f","A"-"F","_"])*["0"-"9","a"-"f","A"-"F"])?)? "." (["0"-"9","a"-"f","A"-"F"]((["0"-"9","a"-"f","A"-"F","_"])*["0"-"9","a"-"f","A"-"F"])?)) ["p","P"] (["+","-"])? (["0"-"9"]((["0"-"9","_"])*["0"-"9"])?) (["f","F","d","D"])?
>
|
< #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
< #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"]((["0"-"9","_"])*["0"-"9"])?) >
|
< CHARACTER_LITERAL:
"'"
@@ -1191,7 +1211,7 @@ jjtThis.setModifiers(modifiers);
if (!t.image.equals("enum")) {
throw new ParseException("ERROR: expecting enum");
}
if (!this.isJDK15) {
if (jdkVersion < 5) {
throw new ParseException("ERROR: Can't use enum as a keyword in pre-JDK 1.5 target");
}
}
@@ -1326,7 +1346,7 @@ void FormalParameter() :
}
{
( "final" {jjtThis.setFinal();} | Annotation() )*
Type()
Type() ("|" Type())*
[ "..." {checkForBadVariableArgumentsUsage();} {jjtThis.setVarargs();} ]
VariableDeclaratorId()
}
@@ -1392,7 +1412,10 @@ void ClassOrInterfaceType():
void TypeArguments():
{}
{
LOOKAHEAD(2)
"<" {checkForBadGenericsUsage();} TypeArgument() ( "," TypeArgument() )* ">"
|
"<" {checkForBadDiamondUsage();} ">"
}
void TypeArgument():
@@ -1676,9 +1699,9 @@ void Literal() :
{}
{
{ Token t;}
t=<INTEGER_LITERAL> {jjtThis.setImage(t.image); jjtThis.setIntLiteral();}
| t=<FLOATING_POINT_LITERAL> {jjtThis.setImage(t.image); jjtThis.setFloatLiteral();}
| t=<HEX_FLOATING_POINT_LITERAL> { checkForBadHexFloatingPointLiteral(); jjtThis.setImage(t.image); jjtThis.setFloatLiteral();}
t=<INTEGER_LITERAL> { checkForBadNumericalLiteralslUsage(t); jjtThis.setImage(t.image); jjtThis.setIntLiteral();}
| t=<FLOATING_POINT_LITERAL> { checkForBadNumericalLiteralslUsage(t); jjtThis.setImage(t.image); jjtThis.setFloatLiteral();}
| t=<HEX_FLOATING_POINT_LITERAL> { checkForBadHexFloatingPointLiteral(); checkForBadNumericalLiteralslUsage(t); jjtThis.setImage(t.image); jjtThis.setFloatLiteral();}
| t=<CHARACTER_LITERAL> {jjtThis.setImage(t.image); jjtThis.setCharLiteral();}
| t=<STRING_LITERAL> {jjtThis.setImage(t.image); jjtThis.setStringLiteral();}
| BooleanLiteral()
@@ -1933,15 +1956,40 @@ void SynchronizedStatement() :
void TryStatement() :
/*
* Semantic check required here to make sure that at least one
* finally/catch is present.
* resource/finally/catch is present.
*/
{}
{
"try" Block()
"try" (ResourceSpecification())? Block()
( CatchStatement() )*
[ FinallyStatement() ]
}
void ResourceSpecification() :
{}
{
"("
Resources()
(LOOKAHEAD(2) ";")?
")"
}
void Resources() :
{}
{
Resource() (LOOKAHEAD(2) ";" Resource())*
}
void Resource() :
{}
{
( "final" | Annotation() )*
Type()
VariableDeclaratorId()
"="
Expression()
}
void CatchStatement() :
{}
{
@@ -1958,7 +2006,7 @@ void FinallyStatement() :
void AssertStatement() :
{
if (isJDK13) {
if (jdkVersion <= 3) {
throw new ParseException("Can't use 'assert' as a keyword when running in JDK 1.3 mode!");
}
}
@@ -1,12 +1,17 @@
package test.net.sourceforge.pmd.ast;
import net.sourceforge.pmd.PMD;
import net.sourceforge.pmd.SourceType;
import net.sourceforge.pmd.TargetJDK1_3;
import net.sourceforge.pmd.TargetJDK1_4;
import net.sourceforge.pmd.TargetJDK1_5;
import net.sourceforge.pmd.TargetJDK1_7;
import net.sourceforge.pmd.TargetJDKVersion;
import net.sourceforge.pmd.ast.ASTCompilationUnit;
import net.sourceforge.pmd.ast.JavaParser;
import net.sourceforge.pmd.ast.ParseException;
import net.sourceforge.pmd.sourcetypehandlers.SourceTypeHandler;
import net.sourceforge.pmd.sourcetypehandlers.SourceTypeHandlerBroker;
import org.junit.Test;
@@ -175,6 +180,59 @@ public class JDKVersionTest {
jp.CompilationUnit();
}
@Test
public final void testBinaryAndUnderscoresInNumericalLiterals() throws Throwable {
new TargetJDK1_7().createParser(new StringReader(JDK17_NUMERICAL_LITERALS)).CompilationUnit();
}
@Test
public final void testStringInSwitch() throws Throwable {
new TargetJDK1_7().createParser(new StringReader(JDK17_STRING_IN_SWITCH)).CompilationUnit();
}
@Test
public final void testGenericDiamond() throws Throwable {
new TargetJDK1_7().createParser(new StringReader(JDK17_GENERIC_DIAMOND)).CompilationUnit();
}
@Test
public final void testTryWithResources() throws Throwable {
new TargetJDK1_7().createParser(new StringReader(JDK17_TRY_WITH_RESOURCES)).CompilationUnit();
}
@Test
public final void testTryWithResourcesSemi() throws Throwable {
new TargetJDK1_7().createParser(new StringReader(JDK17_TRY_WITH_RESOURCES_SEMI)).CompilationUnit();
}
@Test
public final void testTryWithResourcesMulti() throws Throwable {
new TargetJDK1_7().createParser(new StringReader(JDK17_TRY_WITH_RESOURCES_MULTI)).CompilationUnit();
}
@Test
public final void testTryWithResourcesWithAnnotations() throws Throwable {
new TargetJDK1_7().createParser(new StringReader(JDK17_TRY_WITH_RESOURCES_WITH_ANNOTATIONS)).CompilationUnit();
}
@Test
public final void testTryWithResourcesWithVisitors() throws Throwable {
SourceTypeHandler sourceTypeHandler = SourceTypeHandlerBroker.getVisitorsFactoryForSourceType(SourceType.JAVA_17);
ASTCompilationUnit rootNode = (ASTCompilationUnit)sourceTypeHandler.getParser().parse(new StringReader(JDK17_TRY_WITH_RESOURCES));
sourceTypeHandler.getSymbolFacade().start(rootNode);
sourceTypeHandler.getDataFlowFacade().start(rootNode);
sourceTypeHandler.getTypeResolutionFacade(getClass().getClassLoader()).start(rootNode);
}
@Test
public final void testMulticatch() throws Throwable {
new TargetJDK1_7().createParser(new StringReader(JDK17_MULTICATCH)).CompilationUnit();
}
@Test
public final void testMulticatchWithAnnotations() throws Throwable {
new TargetJDK1_7().createParser(new StringReader(JDK17_MULTICATCH_WITH_ANNOTATIONS)).CompilationUnit();
}
private static final String ANNOTATED_LOCALS =
"public class Foo {" + PMD.EOL +
@@ -346,7 +404,150 @@ public class JDKVersionTest {
"public class Foo {" + PMD.EOL +
" public <T extends E> Foo() {}" + PMD.EOL +
"}";
private static final String JDK17_NUMERICAL_LITERALS =
"public class Test {" + PMD.EOL +
" int i1 = 0b00011110;" + PMD.EOL +
" int i2 = 0B00011110;" + PMD.EOL +
" int i3 = 0xA;" + PMD.EOL +
" int i4 = 0x1___A_F;" + PMD.EOL +
" int i5 = 0b1;" + PMD.EOL +
" int i6 = 0b1___1_0;" + PMD.EOL +
" int i7 = 0;" + PMD.EOL +
" int i8 = 02;" + PMD.EOL +
" int i9 = 0_123;" + PMD.EOL +
" int i10 = 1;" + PMD.EOL +
" int i11 = 1___3;" + PMD.EOL +
" int i12 = 1_43_43598_7;" + PMD.EOL +
" " + PMD.EOL +
" long l1 = 0b00011110L;" + PMD.EOL +
" long l2 = 0B00011110l;" + PMD.EOL +
" long l3 = 0xAL;" + PMD.EOL +
" long l4 = 0x1___A_FL;" + PMD.EOL +
" long l5 = 0b1L;" + PMD.EOL +
" long l6 = 0b1___1_0L;" + PMD.EOL +
" long l7 = 0l;" + PMD.EOL +
" long l8 = 02L;" + PMD.EOL +
" long l9 = 0_123l;" + PMD.EOL +
" long l10 = 1l;" + PMD.EOL +
" long l11 = 1___3l;" + PMD.EOL +
" long l12 = 1_43_43598_7L;" + PMD.EOL +
" long l13 = 1_43_43598_7;" + PMD.EOL +
" " + PMD.EOL +
" float f1 = .1f;" + PMD.EOL +
" float f2 = 1.f;" + PMD.EOL +
" float f3 = 0f;" + PMD.EOL +
" float f4 = 1e0F;" + PMD.EOL +
" float f5 = 1e0f;" + PMD.EOL +
" float f6 = 12.345F;" + PMD.EOL +
" float f7 = .5____2_1f;" + PMD.EOL +
" float f8 = 1__42__3.f;" + PMD.EOL +
" float f9 = 0__2_4__324f;" + PMD.EOL +
" float f10 = 1_34e0F;" + PMD.EOL +
" float f11 = 1__1_2e0f;" + PMD.EOL +
" float f12 = 2_1___2.3__4_5F;" + PMD.EOL +
" float f13 = 1_34e0__4__3f;" + PMD.EOL +
" float f14 = 1__1_2e00__000_4f;" + PMD.EOL +
" float f15 = 2_1___2.3__4_5e00______0_5F;" + PMD.EOL +
" " + PMD.EOL +
" double d1 = .1d;" + PMD.EOL +
" double d2 = 1.D;" + PMD.EOL +
" double d3 = 0d;" + PMD.EOL +
" double d4 = 1e0D;" + PMD.EOL +
" double d5 = 1e0d;" + PMD.EOL +
" double d6 = 12.345D;" + PMD.EOL +
" double d7 = .5____2_1d;" + PMD.EOL +
" double d8 = 1__42__3.D;" + PMD.EOL +
" double d9 = 0__2_4__324d;" + PMD.EOL +
" double d10 = 1_34e0d;" + PMD.EOL +
" double d11 = 1__1_2e0d;" + PMD.EOL +
" double d12 = 2_1___2.3__4_5D;" + PMD.EOL +
" double d13 = 1_34e0__4__3d;" + PMD.EOL +
" double d14 = 1__1_2e00__000_4d;" + PMD.EOL +
" double d15 = 2_1___2.3__4_5e00______0_5D;" + PMD.EOL +
" double d16 = 0.12___34;" + PMD.EOL +
" " + PMD.EOL +
" float hf1 = 0x.1___AFp1;" + PMD.EOL +
" float hf2 = 0x.1___AFp0__0__0f;" + PMD.EOL +
" float hf3 = 0x2__3_34.4___AFP00_00f;" + PMD.EOL +
" " + PMD.EOL +
" double hd1 = 0x.1___AFp1;" + PMD.EOL +
" double hd2 = 0x.1___AFp0__0__0d;" + PMD.EOL +
" double hd3 = 0x2__3_34.4___AFP00_00d;" + PMD.EOL +
" " + PMD.EOL +
" int doc1 = 1234_5678;" + PMD.EOL +
" long doc2 = 1_2_3_4__5_6_7_8L;" + PMD.EOL +
" int doc3 = 0b0001_0010_0100_1000;" + PMD.EOL +
" double doc4 = 3.141_592_653_589_793d;" + PMD.EOL +
" double doc5 = 0x1.ffff_ffff_ffff_fP1_023;" + PMD.EOL +
"}" + PMD.EOL
;
private static final String JDK17_STRING_IN_SWITCH =
"public class Test {" + PMD.EOL +
" public static void main(String[] args) {" + PMD.EOL +
" String mystr = \"value\" + \"2\";" + PMD.EOL +
" switch (mystr) {" + PMD.EOL +
" case \"value1\":" + PMD.EOL +
" break;" + PMD.EOL +
" case \"value2\":" + PMD.EOL +
" break;" + PMD.EOL +
" default:" + PMD.EOL +
" break;" + PMD.EOL +
" }" + PMD.EOL +
" }" + PMD.EOL +
"}" + PMD.EOL
;
private static final String JDK17_GENERIC_DIAMOND =
"public class InputJava7Diamond {" + PMD.EOL +
" HashMap<String> map = new HashMap<>();" + PMD.EOL +
"}";
private static final String JDK17_TRY_WITH_RESOURCES =
"public class InputJava7TryWithResources {" + PMD.EOL +
" public static void main() {" + PMD.EOL +
" try (MyResource resource = new MyResource()) { }" + PMD.EOL +
" }" + PMD.EOL +
"}";
private static final String JDK17_TRY_WITH_RESOURCES_SEMI =
"public class InputJava7TryWithResources {" + PMD.EOL +
" public static void main() {" + PMD.EOL +
" try (MyResource resource = new MyResource();) { }" + PMD.EOL +
" }" + PMD.EOL +
"}";
private static final String JDK17_TRY_WITH_RESOURCES_MULTI =
"public class InputJava7TryWithResources {" + PMD.EOL +
" public static void main() {" + PMD.EOL +
" try (MyResource resource = new MyResource(); MyResource2 resource2 = new MyResource2()) { }" + PMD.EOL +
" }" + PMD.EOL +
"}";
private static final String JDK17_TRY_WITH_RESOURCES_WITH_ANNOTATIONS =
"public class InputJava7TryWithResources {" + PMD.EOL +
" public static void main() {" + PMD.EOL +
" try (@SuppressWarnings(\"all\") final MyResource resource = new MyResource()) { }" + PMD.EOL +
" }" + PMD.EOL +
"}";
private static final String JDK17_MULTICATCH =
"public class InputJava7Multicatch {" + PMD.EOL +
" public static void main() {" + PMD.EOL +
" try { }" + PMD.EOL +
" catch (FileNotFoundException | CustomException e) { }" + PMD.EOL +
" }" + PMD.EOL +
"}";
private static final String JDK17_MULTICATCH_WITH_ANNOTATIONS =
"public class InputJava7Multicatch {" + PMD.EOL +
" public static void main() {" + PMD.EOL +
" try { }" + PMD.EOL +
" catch (final @SuppressWarnings(\"all\") FileNotFoundException | CustomException e) { }" + PMD.EOL +
" }" + PMD.EOL +
"}";
public static junit.framework.Test suite() {
return new junit.framework.JUnit4TestAdapter(JDKVersionTest.class);
}
@@ -567,4 +567,17 @@ public abstract class AbstractJavaRule extends CommonAbstractRule implements
public Object visit(ASTCatchStatement node, Object data) {
return visit((SimpleJavaNode)node, data);
}
public Object visit(ASTResourceSpecification node, Object data) {
return visit((SimpleJavaNode)node, data);
}
public Object visit(ASTResources node, Object data) {
return visit((SimpleJavaNode)node, data);
}
public Object visit(ASTResource node, Object data) {
return visit((SimpleJavaNode)node, data);
}
}
@@ -22,7 +22,7 @@ public class TargetJDK1_3 implements TargetJDKVersion {
*/
public JavaParser createParser(InputStream in) {
JavaParser jp = new JavaParser(new JavaCharStream(in));
jp.setJDK13();
jp.setJdkVersion(3);
return jp;
}
@@ -31,7 +31,7 @@ public class TargetJDK1_3 implements TargetJDKVersion {
*/
public JavaParser createParser(Reader in) {
JavaParser jp = new JavaParser(new JavaCharStream(in));
jp.setJDK13();
jp.setJdkVersion(3);
return jp;
}
@@ -22,14 +22,18 @@ public class TargetJDK1_4 implements TargetJDKVersion {
* @see net.sourceforge.pmd.TargetJDKVersion#createParser(InputStream)
*/
public JavaParser createParser(InputStream in) {
return new JavaParser(new JavaCharStream(in));
JavaParser jp = new JavaParser(new JavaCharStream(in));
jp.setJdkVersion(4);
return jp;
}
/**
* @see net.sourceforge.pmd.TargetJDKVersion#createParser(Reader)
*/
public JavaParser createParser(Reader in) {
return new JavaParser(new JavaCharStream(in));
JavaParser jp = new JavaParser(new JavaCharStream(in));
jp.setJdkVersion(4);
return jp;
}
/**
@@ -22,7 +22,7 @@ public class TargetJDK1_5 implements TargetJDKVersion {
*/
public JavaParser createParser(InputStream in) {
JavaParser jp = new JavaParser(new JavaCharStream(in));
jp.setJDK15();
jp.setJdkVersion(5);
return jp;
}
@@ -31,7 +31,7 @@ public class TargetJDK1_5 implements TargetJDKVersion {
*/
public JavaParser createParser(Reader in) {
JavaParser jp = new JavaParser(new JavaCharStream(in));
jp.setJDK15();
jp.setJdkVersion(5);
return jp;
}
@@ -21,7 +21,7 @@ public class TargetJDK1_6 implements TargetJDKVersion {
*/
public JavaParser createParser(InputStream in) {
JavaParser jp = new JavaParser(new JavaCharStream(in));
jp.setJDK15();
jp.setJdkVersion(6);
return jp;
}
@@ -30,7 +30,7 @@ public class TargetJDK1_6 implements TargetJDKVersion {
*/
public JavaParser createParser(Reader in) {
JavaParser jp = new JavaParser(new JavaCharStream(in));
jp.setJDK15();
jp.setJdkVersion(6);
return jp;
}
@@ -21,7 +21,7 @@ public class TargetJDK1_7 implements TargetJDKVersion {
*/
public JavaParser createParser(InputStream in) {
JavaParser jp = new JavaParser(new JavaCharStream(in));
jp.setJDK15();
jp.setJdkVersion(7);
return jp;
}
@@ -30,7 +30,7 @@ public class TargetJDK1_7 implements TargetJDKVersion {
*/
public JavaParser createParser(Reader in) {
JavaParser jp = new JavaParser(new JavaCharStream(in));
jp.setJDK15();
jp.setJdkVersion(7);
return jp;
}
@@ -0,0 +1,20 @@
/* Generated By:JJTree: Do not edit this line. ASTResource.java Version 4.1 */
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=true,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY= */
package net.sourceforge.pmd.ast;
public class ASTResource extends ASTFormalParameter {
public ASTResource(int id) {
super(id);
}
public ASTResource(JavaParser p, int id) {
super(p, id);
}
/** Accept the visitor. **/
public Object jjtAccept(JavaParserVisitor visitor, Object data) {
return visitor.visit(this, data);
}
}
/* JavaCC - OriginalChecksum=43fe58be01783effb99f58d571b7eed2 (do not edit this line) */
@@ -0,0 +1,20 @@
/* Generated By:JJTree: Do not edit this line. ASTResourceSpecification.java Version 4.1 */
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=true,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY= */
package net.sourceforge.pmd.ast;
public class ASTResourceSpecification extends SimpleJavaNode {
public ASTResourceSpecification(int id) {
super(id);
}
public ASTResourceSpecification(JavaParser p, int id) {
super(p, id);
}
/** Accept the visitor. **/
public Object jjtAccept(JavaParserVisitor visitor, Object data) {
return visitor.visit(this, data);
}
}
/* JavaCC - OriginalChecksum=302a35714ff98375ee6f404b5814bb94 (do not edit this line) */
@@ -0,0 +1,20 @@
/* Generated By:JJTree: Do not edit this line. ASTResources.java Version 4.1 */
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=true,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY= */
package net.sourceforge.pmd.ast;
public class ASTResources extends SimpleJavaNode {
public ASTResources(int id) {
super(id);
}
public ASTResources(JavaParser p, int id) {
super(p, id);
}
/** Accept the visitor. **/
public Object jjtAccept(JavaParserVisitor visitor, Object data) {
return visitor.visit(this, data);
}
}
/* JavaCC - OriginalChecksum=66d98d4d1ab47edf1bbb1000ee168b36 (do not edit this line) */
@@ -109,4 +109,4 @@ public interface CharStream {
void Done();
}
/* JavaCC - OriginalChecksum=ee07529224d9f56bc326274129aba6aa (do not edit this line) */
/* JavaCC - OriginalChecksum=1a0efc5345d544bfbfb4f4aa4874dcc9 (do not edit this line) */
@@ -120,4 +120,4 @@ public class JJTJavaParserState {
}
}
}
/* JavaCC - OriginalChecksum=1f85d5a954d2dafb00b08e69b12b9bd3 (do not edit this line) */
/* JavaCC - OriginalChecksum=8adeb8c34464efb76188cd58df068d02 (do not edit this line) */
@@ -613,4 +613,4 @@ public class JavaCharStream implements CharStream
}
}
/* JavaCC - OriginalChecksum=f18b7eb3e3e62d2724487ac20028cf2f (do not edit this line) */
/* JavaCC - OriginalChecksum=dd099199b60a0a7ee9f65e20db756c9d (do not edit this line) */
File diff suppressed because it is too large. Load diff
@@ -125,119 +125,121 @@ public interface JavaParserConstants {
/** RegularExpression Id. */
int HEX_LITERAL = 65;
/** RegularExpression Id. */
int OCTAL_LITERAL = 66;
int BINARY_LITERAL = 66;
/** RegularExpression Id. */
int FLOATING_POINT_LITERAL = 67;
int OCTAL_LITERAL = 67;
/** RegularExpression Id. */
int HEX_FLOATING_POINT_LITERAL = 68;
int FLOATING_POINT_LITERAL = 68;
/** RegularExpression Id. */
int EXPONENT = 69;
int HEX_FLOATING_POINT_LITERAL = 69;
/** RegularExpression Id. */
int CHARACTER_LITERAL = 70;
int EXPONENT = 70;
/** RegularExpression Id. */
int STRING_LITERAL = 71;
int CHARACTER_LITERAL = 71;
/** RegularExpression Id. */
int IDENTIFIER = 72;
int STRING_LITERAL = 72;
/** RegularExpression Id. */
int LETTER = 73;
int IDENTIFIER = 73;
/** RegularExpression Id. */
int PART_LETTER = 74;
int LETTER = 74;
/** RegularExpression Id. */
int LPAREN = 75;
int PART_LETTER = 75;
/** RegularExpression Id. */
int RPAREN = 76;
int LPAREN = 76;
/** RegularExpression Id. */
int LBRACE = 77;
int RPAREN = 77;
/** RegularExpression Id. */
int RBRACE = 78;
int LBRACE = 78;
/** RegularExpression Id. */
int LBRACKET = 79;
int RBRACE = 79;
/** RegularExpression Id. */
int RBRACKET = 80;
int LBRACKET = 80;
/** RegularExpression Id. */
int SEMICOLON = 81;
int RBRACKET = 81;
/** RegularExpression Id. */
int COMMA = 82;
int SEMICOLON = 82;
/** RegularExpression Id. */
int DOT = 83;
int COMMA = 83;
/** RegularExpression Id. */
int AT = 84;
int DOT = 84;
/** RegularExpression Id. */
int ASSIGN = 85;
int AT = 85;
/** RegularExpression Id. */
int LT = 86;
int ASSIGN = 86;
/** RegularExpression Id. */
int BANG = 87;
int LT = 87;
/** RegularExpression Id. */
int TILDE = 88;
int BANG = 88;
/** RegularExpression Id. */
int HOOK = 89;
int TILDE = 89;
/** RegularExpression Id. */
int COLON = 90;
int HOOK = 90;
/** RegularExpression Id. */
int EQ = 91;
int COLON = 91;
/** RegularExpression Id. */
int LE = 92;
int EQ = 92;
/** RegularExpression Id. */
int GE = 93;
int LE = 93;
/** RegularExpression Id. */
int NE = 94;
int GE = 94;
/** RegularExpression Id. */
int SC_OR = 95;
int NE = 95;
/** RegularExpression Id. */
int SC_AND = 96;
int SC_OR = 96;
/** RegularExpression Id. */
int INCR = 97;
int SC_AND = 97;
/** RegularExpression Id. */
int DECR = 98;
int INCR = 98;
/** RegularExpression Id. */
int PLUS = 99;
int DECR = 99;
/** RegularExpression Id. */
int MINUS = 100;
int PLUS = 100;
/** RegularExpression Id. */
int STAR = 101;
int MINUS = 101;
/** RegularExpression Id. */
int SLASH = 102;
int STAR = 102;
/** RegularExpression Id. */
int BIT_AND = 103;
int SLASH = 103;
/** RegularExpression Id. */
int BIT_OR = 104;
int BIT_AND = 104;
/** RegularExpression Id. */
int XOR = 105;
int BIT_OR = 105;
/** RegularExpression Id. */
int REM = 106;
int XOR = 106;
/** RegularExpression Id. */
int LSHIFT = 107;
int REM = 107;
/** RegularExpression Id. */
int PLUSASSIGN = 108;
int LSHIFT = 108;
/** RegularExpression Id. */
int MINUSASSIGN = 109;
int PLUSASSIGN = 109;
/** RegularExpression Id. */
int STARASSIGN = 110;
int MINUSASSIGN = 110;
/** RegularExpression Id. */
int SLASHASSIGN = 111;
int STARASSIGN = 111;
/** RegularExpression Id. */
int ANDASSIGN = 112;
int SLASHASSIGN = 112;
/** RegularExpression Id. */
int ORASSIGN = 113;
int ANDASSIGN = 113;
/** RegularExpression Id. */
int XORASSIGN = 114;
int ORASSIGN = 114;
/** RegularExpression Id. */
int REMASSIGN = 115;
int XORASSIGN = 115;
/** RegularExpression Id. */
int LSHIFTASSIGN = 116;
int REMASSIGN = 116;
/** RegularExpression Id. */
int RSIGNEDSHIFTASSIGN = 117;
int LSHIFTASSIGN = 117;
/** RegularExpression Id. */
int RUNSIGNEDSHIFTASSIGN = 118;
int RSIGNEDSHIFTASSIGN = 118;
/** RegularExpression Id. */
int ELLIPSIS = 119;
int RUNSIGNEDSHIFTASSIGN = 119;
/** RegularExpression Id. */
int RUNSIGNEDSHIFT = 120;
int ELLIPSIS = 120;
/** RegularExpression Id. */
int RSIGNEDSHIFT = 121;
int RUNSIGNEDSHIFT = 121;
/** RegularExpression Id. */
int GT = 122;
int RSIGNEDSHIFT = 122;
/** RegularExpression Id. */
int GT = 123;
/** Lexical state. */
int DEFAULT = 0;
@@ -314,6 +316,7 @@ public interface JavaParserConstants {
"<INTEGER_LITERAL>",
"<DECIMAL_LITERAL>",
"<HEX_LITERAL>",
"<BINARY_LITERAL>",
"<OCTAL_LITERAL>",
"<FLOATING_POINT_LITERAL>",
"<HEX_FLOATING_POINT_LITERAL>",
File diff suppressed because it is too large. Load diff
@@ -94,24 +94,27 @@ public interface JavaParserTreeConstants
public int JJTTHROWSTATEMENT = 88;
public int JJTSYNCHRONIZEDSTATEMENT = 89;
public int JJTTRYSTATEMENT = 90;
public int JJTCATCHSTATEMENT = 91;
public int JJTFINALLYSTATEMENT = 92;
public int JJTASSERTSTATEMENT = 93;
public int JJTRUNSIGNEDSHIFT = 94;
public int JJTRSIGNEDSHIFT = 95;
public int JJTANNOTATION = 96;
public int JJTNORMALANNOTATION = 97;
public int JJTMARKERANNOTATION = 98;
public int JJTSINGLEMEMBERANNOTATION = 99;
public int JJTMEMBERVALUEPAIRS = 100;
public int JJTMEMBERVALUEPAIR = 101;
public int JJTMEMBERVALUE = 102;
public int JJTMEMBERVALUEARRAYINITIALIZER = 103;
public int JJTANNOTATIONTYPEDECLARATION = 104;
public int JJTANNOTATIONTYPEBODY = 105;
public int JJTANNOTATIONTYPEMEMBERDECLARATION = 106;
public int JJTANNOTATIONMETHODDECLARATION = 107;
public int JJTDEFAULTVALUE = 108;
public int JJTRESOURCESPECIFICATION = 91;
public int JJTRESOURCES = 92;
public int JJTRESOURCE = 93;
public int JJTCATCHSTATEMENT = 94;
public int JJTFINALLYSTATEMENT = 95;
public int JJTASSERTSTATEMENT = 96;
public int JJTRUNSIGNEDSHIFT = 97;
public int JJTRSIGNEDSHIFT = 98;
public int JJTANNOTATION = 99;
public int JJTNORMALANNOTATION = 100;
public int JJTMARKERANNOTATION = 101;
public int JJTSINGLEMEMBERANNOTATION = 102;
public int JJTMEMBERVALUEPAIRS = 103;
public int JJTMEMBERVALUEPAIR = 104;
public int JJTMEMBERVALUE = 105;
public int JJTMEMBERVALUEARRAYINITIALIZER = 106;
public int JJTANNOTATIONTYPEDECLARATION = 107;
public int JJTANNOTATIONTYPEBODY = 108;
public int JJTANNOTATIONTYPEMEMBERDECLARATION = 109;
public int JJTANNOTATIONMETHODDECLARATION = 110;
public int JJTDEFAULTVALUE = 111;
public String[] jjtNodeName = {
@@ -206,6 +209,9 @@ public interface JavaParserTreeConstants
"ThrowStatement",
"SynchronizedStatement",
"TryStatement",
"ResourceSpecification",
"Resources",
"Resource",
"CatchStatement",
"FinallyStatement",
"AssertStatement",
@@ -226,4 +232,4 @@ public interface JavaParserTreeConstants
"DefaultValue",
};
}
/* JavaCC - OriginalChecksum=28e68740207e50a892e7959c0ef43ae0 (do not edit this line) */
/* JavaCC - OriginalChecksum=29b39dcf60c8732d67ff9c7dfd922984 (do not edit this line) */
@@ -94,6 +94,9 @@ public interface JavaParserVisitor
public Object visit(ASTThrowStatement node, Object data);
public Object visit(ASTSynchronizedStatement node, Object data);
public Object visit(ASTTryStatement node, Object data);
public Object visit(ASTResourceSpecification node, Object data);
public Object visit(ASTResources node, Object data);
public Object visit(ASTResource node, Object data);
public Object visit(ASTCatchStatement node, Object data);
public Object visit(ASTFinallyStatement node, Object data);
public Object visit(ASTAssertStatement node, Object data);
@@ -113,4 +116,4 @@ public interface JavaParserVisitor
public Object visit(ASTAnnotationMethodDeclaration node, Object data);
public Object visit(ASTDefaultValue node, Object data);
}
/* JavaCC - OriginalChecksum=c64246870a5e6312a32af1f3a34598f9 (do not edit this line) */
/* JavaCC - OriginalChecksum=2ea4ba8f9c55c7ee106d2ff1cb84080a (do not edit this line) */
@@ -430,6 +430,18 @@ public class JavaParserVisitorAdapter implements JavaParserVisitor {
public Object visit(ASTTryStatement node, Object data) {
return visit((SimpleJavaNode) node, data);
}
public Object visit(ASTResourceSpecification node, Object data) {
return visit((SimpleJavaNode) node, data);
}
public Object visit(ASTResources node, Object data) {
return visit((SimpleJavaNode) node, data);
}
public Object visit(ASTResource node, Object data) {
return visit((SimpleJavaNode) node, data);
}
public Object visit(ASTFinallyStatement node, Object data) {
return visit((SimpleJavaNode) node, data);
@@ -195,4 +195,4 @@ public class ParseException extends RuntimeException {
}
}
/* JavaCC - OriginalChecksum=ef5dac5cf3d0acb71ed277e8df8173a1 (do not edit this line) */
/* JavaCC - OriginalChecksum=02c72629b8dcd84edc31480a87e9bc97 (do not edit this line) */
+1 -1
View File
@@ -132,4 +132,4 @@ public class Token {
}
}
/* JavaCC - OriginalChecksum=0fc45836ac24c23412a256e5ad480628 (do not edit this line) */
/* JavaCC - OriginalChecksum=db0cc77f0ac78d4798a0b95cf8c2feee (do not edit this line) */
@@ -138,4 +138,4 @@ public class TokenMgrError extends RuntimeException
this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
}
}
/* JavaCC - OriginalChecksum=d89e07f1292843b46af7dff7e1b97290 (do not edit this line) */
/* JavaCC - OriginalChecksum=69f02ca7fa92b5820fa9f9f7338f31ca (do not edit this line) */
@@ -195,4 +195,4 @@ public class ParseException extends RuntimeException {
}
}
/* JavaCC - OriginalChecksum=8b42f597f21215eb130252440c369111 (do not edit this line) */
/* JavaCC - OriginalChecksum=31bfc5f76d73ac014456ff24b3421ec1 (do not edit this line) */
@@ -473,4 +473,4 @@ public class SimpleCharStream
}
}
/* JavaCC - OriginalChecksum=9bbb8cb4295bb8f7d58e31ce57dc2e0f (do not edit this line) */
/* JavaCC - OriginalChecksum=164c9467b96e643d0dc94f9340461e10 (do not edit this line) */
@@ -121,4 +121,4 @@ public class Token {
}
}
/* JavaCC - OriginalChecksum=1917659c640ac2c65feaa32a37580421 (do not edit this line) */
/* JavaCC - OriginalChecksum=c274035bc4ab4fd85bbf63e60efd01fe (do not edit this line) */
@@ -137,4 +137,4 @@ public class TokenMgrError extends Error
this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
}
}
/* JavaCC - OriginalChecksum=7925b33c412b4bfa3a7147ae3e790276 (do not edit this line) */
/* JavaCC - OriginalChecksum=a4f605ad03bdc43d3d36a44f2ccfce1a (do not edit this line) */
@@ -2,7 +2,7 @@
/* JavaCCOptions:STATIC=false */
/**
* JSP Parser for PMD.
* @author Pieter � Application Engineers NV/SA � http://www.ae.be
* @author Pieter – Application Engineers NV/SA – http://www.ae.be
*/
package net.sourceforge.pmd.jsp.ast;
@@ -114,4 +114,4 @@ public interface CharStream extends net.sourceforge.pmd.ast.CharStream {
void Done();
}
/* JavaCC - OriginalChecksum=41ae2339795c47e740cf9814e6433c13 (do not edit this line) */
/* JavaCC - OriginalChecksum=087c58fccada72eb2e83d4ed4684e607 (do not edit this line) */
@@ -120,4 +120,4 @@ public class JJTJspParserState {
}
}
}
/* JavaCC - OriginalChecksum=8975088f82e71516c3dfebdcadc05dff (do not edit this line) */
/* JavaCC - OriginalChecksum=c5c95d986dd0b349daf5295b6db479e4 (do not edit this line) */
Loaded 30 of 41 files, more files were not shown because too many files have changed in this diff. Show more