custom check

androuser <[email protected]> Tue, 16 Aug 2011 23:33:27 -0700 (PDT)
Newsgroups gmane.comp.java.audit.checkstyle.user
Message-ID <[email protected]>
Hi, 
We have been using CheckStyle in our project to create custom checks. We
have a requirement, which I 
am unable to implement through checkStyle. The 
requirement is all classes having names ending with *VO.java must 
have a method named "toString". 

this is my visittoken method

i am getting class in aAst.

public void visitToken(DetailAST aAst) {
    final DetailAST className = aAst.findFirstToken(TokenTypes.IDENT);
    if (className.getText().endsWith("VO") ||
className.getText().endsWith("DTO")) {
         DetailAST objBlock = aAst.findFirstToken(TokenTypes.OBJBLOCK);
         DetailAST temp = aAst;
         for(int i=1;i<=objBlock.getChildCount();i++) {
	if(i == 1) {
	    temp = objBlock.getFirstChild();
	    System.out.println(i + "******" +temp.getText());
	}
						
	else {
	    if(temp.getNextSibling().getText() == "METHOD_DEF") {
                     temp =
temp.getNextSibling().findFirstToken(TokenTypes.IDENT);
	        System.out.println(i + "/////////" + temp.getText());
                 }
	}
         }
     }
}

all am able to get is the tokentype... that is METHOD_DEF.. but i need the
actual method names in the class.

Please help me with this.

Thanks, 
AndroUser

--
View this message in context: http://checkstyle.2069334.n4.nabble.com/custom-check-tp3749244p3749244.html
Sent from the CheckStyle - User mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system, 
user administration capabilities and model configuration. Take 
the hassle out of deploying and managing Subversion and the 
tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2