Added information to ASTExplicitConstructorInvocation

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@1411 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Tom Copeland
2003-02-10 15:30:51 +00:00
parent 5dda872edb
commit 14598883cb
7 changed files with 70 additions and 70 deletions

View File

@ -591,10 +591,9 @@ void ConstructorDeclaration() :
void ExplicitConstructorInvocation() :
{}
{
LOOKAHEAD("this" Arguments() ";")
"this" Arguments() ";"
LOOKAHEAD("this" Arguments() ";") "this" {((ASTExplicitConstructorInvocation)jjtThis).setIsThis();} Arguments() ";"
|
[ LOOKAHEAD(2) PrimaryExpression() "." ] "super" Arguments() ";"
[ LOOKAHEAD(2) PrimaryExpression() "." ] "super" {((ASTExplicitConstructorInvocation)jjtThis).setIsSuper();} Arguments() ";"
}
void Initializer() :

View File

@ -59,8 +59,8 @@
<taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask"/>
<pmd rulesetfiles="rulesets/tmp.xml" shortFilenames="false">
<formatter type="html" toFile="foo.html"/>
<fileset dir="C:\j2sdk1.4.1_01\src\java\">
<include name="**/*.java"/>
<fileset dir="C:\">
<include name="Foo.java"/>
</fileset>
</pmd>
</target>

View File

@ -223,7 +223,9 @@ public class Foo {
<description>
Assigning a "null" to a variable (outside of its declaration) is usually in
bad form. Some times, the assignment is an indication that the programmer doesn't
completely understand what is going on in the code.
completely understand what is going on in the code. NOTE: This sort of assignment
may in rare cases be useful to encourage garbage collection. If that's what you're using
it for, by all means, disregard this rule :-)
</description>
<priority>3</priority>
<example>

View File

@ -82,21 +82,6 @@ public class Foo
</example>
</rule>
<rule name="SymbolTableTestRule"
message="test"
class="net.sourceforge.pmd.rules.SymbolTableTestRule">
<description>
asdsad
</description>
<priority>3</priority>
<example>
<![CDATA[
// asdadas
]]>
</example>
</rule>
<rule name="AssignmentInOperandRule"
message="Avoid assigments in operands"
class="net.sourceforge.pmd.rules.AssignmentInOperandRule">

View File

@ -16,4 +16,23 @@ public class ASTExplicitConstructorInvocation extends SimpleNode {
public Object jjtAccept(JavaParserVisitor visitor, Object data) {
return visitor.visit(this, data);
}
private boolean isThis;
private boolean isSuper;
public void setIsThis() {
this.isThis = true;
}
public void setIsSuper() {
this.isSuper = true;
}
public boolean isThis() {
return this.isThis;
}
public boolean isSuper() {
return this.isSuper;
}
}

View File

@ -1562,6 +1562,7 @@ public class JavaParser/*@bgen(jjtree)*/implements JavaParserTreeConstants, Java
try {
if (jj_2_13(2147483647)) {
jj_consume_token(THIS);
((ASTExplicitConstructorInvocation)jjtn000).setIsThis();
Arguments();
jj_consume_token(SEMICOLON);
} else {
@ -1594,6 +1595,7 @@ public class JavaParser/*@bgen(jjtree)*/implements JavaParserTreeConstants, Java
;
}
jj_consume_token(SUPER);
((ASTExplicitConstructorInvocation)jjtn000).setIsSuper();
Arguments();
jj_consume_token(SEMICOLON);
break;
@ -5077,12 +5079,6 @@ jjtree.openNodeScope(jjtn000);boolean hasElse = false;
return false;
}
final private boolean jj_3R_69() {
if (jj_scan_token(STATIC)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
final private boolean jj_3_13() {
if (jj_scan_token(THIS)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
@ -5093,6 +5089,12 @@ jjtree.openNodeScope(jjtn000);boolean hasElse = false;
return false;
}
final private boolean jj_3R_69() {
if (jj_scan_token(STATIC)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
final private boolean jj_3R_43() {
Token xsp;
xsp = jj_scanpos;
@ -6006,14 +6008,6 @@ jjtree.openNodeScope(jjtn000);boolean hasElse = false;
return false;
}
final private boolean jj_3R_381() {
if (jj_scan_token(COLON)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
if (jj_3R_60()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
final private boolean jj_3R_311() {
if (jj_scan_token(STATIC)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
@ -6052,6 +6046,14 @@ jjtree.openNodeScope(jjtn000);boolean hasElse = false;
return false;
}
final private boolean jj_3R_381() {
if (jj_scan_token(COLON)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
if (jj_3R_60()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
final private boolean jj_3R_267() {
Token xsp;
while (true) {
@ -6262,6 +6264,12 @@ jjtree.openNodeScope(jjtn000);boolean hasElse = false;
return false;
}
final private boolean jj_3R_262() {
if (jj_3R_270()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
final private boolean jj_3R_227() {
if (jj_scan_token(ASSERT)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
@ -6276,12 +6284,6 @@ jjtree.openNodeScope(jjtn000);boolean hasElse = false;
return false;
}
final private boolean jj_3R_262() {
if (jj_3R_270()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
final private boolean jj_3_3() {
Token xsp;
while (true) {
@ -6312,16 +6314,16 @@ jjtree.openNodeScope(jjtn000);boolean hasElse = false;
return false;
}
final private boolean jj_3R_380() {
if (jj_scan_token(FINALLY)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
if (jj_3R_70()) return true;
final private boolean jj_3R_258() {
if (jj_3R_266()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
final private boolean jj_3R_258() {
if (jj_3R_266()) return true;
final private boolean jj_3R_380() {
if (jj_scan_token(FINALLY)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
if (jj_3R_70()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
@ -6471,12 +6473,6 @@ jjtree.openNodeScope(jjtn000);boolean hasElse = false;
return false;
}
final private boolean jj_3R_375() {
if (jj_3R_387()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
final private boolean jj_3R_250() {
if (jj_3R_253()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
@ -6495,6 +6491,12 @@ jjtree.openNodeScope(jjtn000);boolean hasElse = false;
return false;
}
final private boolean jj_3R_375() {
if (jj_3R_387()) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
final private boolean jj_3R_225() {
if (jj_scan_token(SYNCHRONIZED)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
@ -6667,12 +6669,6 @@ jjtree.openNodeScope(jjtn000);boolean hasElse = false;
return false;
}
final private boolean jj_3R_64() {
if (jj_scan_token(FINAL)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
final private boolean jj_3_1() {
Token xsp;
while (true) {
@ -6685,6 +6681,12 @@ jjtree.openNodeScope(jjtn000);boolean hasElse = false;
return false;
}
final private boolean jj_3R_64() {
if (jj_scan_token(FINAL)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
return false;
}
final private boolean jj_3R_372() {
if (jj_scan_token(ELSE)) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;

View File

@ -5,21 +5,14 @@ import net.sourceforge.pmd.AbstractRule;
import net.sourceforge.pmd.ast.ASTPrimarySuffix;
import net.sourceforge.pmd.ast.ASTPrimaryPrefix;
import net.sourceforge.pmd.ast.ASTName;
import net.sourceforge.pmd.ast.ASTExplicitConstructorInvocation;
public class SymbolTableTestRule extends AbstractRule implements Rule {
public Object visit(ASTPrimarySuffix node, Object data) {
System.out.println("ASTPrimarySuffix: image: " + node.getImage());
public Object visit(ASTExplicitConstructorInvocation node, Object data) {
System.out.println("ASTExplicitConstructorInvocation: isSuper: " + node.isSuper());
System.out.println("ASTExplicitConstructorInvocation: isThis: " + node.isThis());
return super.visit(node,data);
}
public Object visit(ASTPrimaryPrefix node, Object data) {
System.out.println("ASTPrimaryPrefix: image: " + node.getImage());
return super.visit(node,data);
}
public Object visit(ASTName node, Object data) {
System.out.println("ASTName: image: " + node.getImage());
return super.visit(node,data);
}
}