Added initializer block info
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@2065 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -4,6 +4,7 @@ Fixed bug 583047 - ASTName column numbers are now correct
|
||||
Fixed bug 761048 - Symbol table now creates a scope level for anonymous inner classes
|
||||
Fixed bug 763529 - AccessorClassGenerationRule no longer crashes when given a final inner class
|
||||
Added ability to accept a comma-delimited string of files and directories on the command line.
|
||||
Modified grammer to provide information on whether an initializer block is static.
|
||||
ASTViewer now shows node images and modifiers
|
||||
ASTViewer now saves last edited text to ~/.pmd_astviewer
|
||||
Moved the PMD Swing UI into a separate module - pmd-swingui.
|
||||
|
@ -599,7 +599,7 @@ void ExplicitConstructorInvocation() :
|
||||
void Initializer() :
|
||||
{}
|
||||
{
|
||||
[ "static" ] Block()
|
||||
[ "static" {jjtThis.setStatic();} ] Block()
|
||||
}
|
||||
|
||||
|
||||
|
@ -4,12 +4,34 @@ import junit.framework.TestCase;
|
||||
import net.sourceforge.pmd.PMD;
|
||||
import net.sourceforge.pmd.ast.ASTCompilationUnit;
|
||||
import net.sourceforge.pmd.ast.JavaParser;
|
||||
import net.sourceforge.pmd.ast.ASTInitializer;
|
||||
import net.sourceforge.pmd.symboltable.SymbolFacade;
|
||||
|
||||
import java.io.StringReader;
|
||||
|
||||
public class AcceptanceTest extends TestCase {
|
||||
|
||||
public void testClashingSymbols() {
|
||||
JavaParser parser = new JavaParser(new StringReader(TEST1));
|
||||
ASTCompilationUnit c = parser.CompilationUnit();
|
||||
SymbolFacade stb = new SymbolFacade();
|
||||
stb.initializeWith(c);
|
||||
}
|
||||
|
||||
public void testInitializer() {
|
||||
JavaParser parser = new JavaParser(new StringReader(TEST2));
|
||||
ASTCompilationUnit c = parser.CompilationUnit();
|
||||
ASTInitializer a = (ASTInitializer)(c.findChildrenOfType(ASTInitializer.class)).get(0);
|
||||
assertFalse(a.isStatic());
|
||||
}
|
||||
|
||||
public void testStaticInitializer() {
|
||||
JavaParser parser = new JavaParser(new StringReader(TEST3));
|
||||
ASTCompilationUnit c = parser.CompilationUnit();
|
||||
ASTInitializer a = (ASTInitializer)(c.findChildrenOfType(ASTInitializer.class)).get(0);
|
||||
assertTrue(a.isStatic());
|
||||
}
|
||||
|
||||
private static final String TEST1 =
|
||||
"import java.io.*;" + PMD.EOL +
|
||||
"public class Foo {" + PMD.EOL +
|
||||
@ -19,10 +41,14 @@ public class AcceptanceTest extends TestCase {
|
||||
" }" + PMD.EOL +
|
||||
"}" + PMD.EOL;
|
||||
|
||||
public void testClashingSymbols() {
|
||||
JavaParser parser = new JavaParser(new StringReader(TEST1));
|
||||
ASTCompilationUnit c = parser.CompilationUnit();
|
||||
SymbolFacade stb = new SymbolFacade();
|
||||
stb.initializeWith(c);
|
||||
}
|
||||
private static final String TEST2 =
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" {} " + PMD.EOL +
|
||||
"}" + PMD.EOL;
|
||||
|
||||
private static final String TEST3 =
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" static {} " + PMD.EOL +
|
||||
"}" + PMD.EOL;
|
||||
|
||||
}
|
||||
|
@ -16,4 +16,14 @@ public class ASTInitializer extends SimpleNode {
|
||||
public Object jjtAccept(JavaParserVisitor visitor, Object data) {
|
||||
return visitor.visit(this, data);
|
||||
}
|
||||
|
||||
private boolean isStatic;
|
||||
|
||||
public boolean isStatic() {
|
||||
return isStatic;
|
||||
}
|
||||
|
||||
public void setStatic() {
|
||||
isStatic = true;
|
||||
}
|
||||
}
|
||||
|
@ -1635,6 +1635,7 @@ public class JavaParser/*@bgen(jjtree)*/implements JavaParserTreeConstants, Java
|
||||
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
|
||||
case STATIC:
|
||||
jj_consume_token(STATIC);
|
||||
jjtn000.setStatic();
|
||||
break;
|
||||
default:
|
||||
jj_la1[43] = jj_gen;
|
||||
|
@ -10,6 +10,7 @@
|
||||
<section name="Credits">
|
||||
<subsection name="Individuals">
|
||||
<ul>
|
||||
<li>Bernd Jansen - grammer modification</li>
|
||||
<li>Jarle Naess - bug report</li>
|
||||
<li>Jeff Anderson - VariableNamingConventionsRule, MethodNamingConventionsRule, ClassNamingConventionsRule</li>
|
||||
<li>Frank van Puffelen - documentation suggestions</li>
|
||||
|
Reference in New Issue
Block a user