Groovy Documentation

org.codenarc.rule
Class AbstractAstVisitor

java.lang.Object
  org.codehaus.groovy.ast.CodeVisitorSupport
      org.codehaus.groovy.ast.ClassCodeVisitorSupport
          org.codenarc.rule.AbstractAstVisitor

class AbstractAstVisitor
extends org.codehaus.groovy.ast.ClassCodeVisitorSupport

Abstract superclass for Groovy AST Visitors used with Rules

author:
Chris Mair
version:
$Revision: 341 $ - $Date: 2010-05-04 21:33:09 -0400 (Tue, 04 May 2010) $


Property Summary
protected static def BOOLEAN_CLASS

protected static def CONSTANT_EXPRESSION_VALUES

static def MAX_SOURCE_LINE_LENGTH

static def SOURCE_LINE_LAST_SEGMENT_LENGTH

Rule rule

SourceCode sourceCode

List violations

Set visited

 
Constructor Summary
AbstractAstVisitor()

 
Method Summary
protected void addViolation(ASTNode node, def message = null)

Add a new Violation to the list of violations found by this visitor.

protected void addViolation(Violation violation)

Add a new Violation to the list of violations found by this visitor.

protected SourceUnit getSourceUnit()

protected boolean isConstantBooleanExpression(def booleanExpression)

protected def isFirstVisit(def expression)

Return true if the AST expression has not already been visited.

protected String sourceLine(ASTNode node)

Return the source line corresponding to the specified AST node

 
Methods inherited from class org.codehaus.groovy.ast.ClassCodeVisitorSupport
visitReturnStatement, visitProperty, visitField, visitConstructor, visitMethod, visitClass, visitAnnotations, visitPackage, visitImports, visitVariableExpression, visitAssertStatement, visitBlockStatement, visitBreakStatement, visitCaseStatement, visitCatchStatement, visitContinueStatement, visitDoWhileLoop, visitExpressionStatement, visitForLoop, visitIfElse, visitSwitch, visitSynchronizedStatement, visitThrowStatement, visitTryCatchFinally, visitWhileLoop, visitConstantExpression, visitClassExpression, visitListExpression, visitPropertyExpression, visitMethodCallExpression, visitStaticMethodCallExpression, visitConstructorCallExpression, visitBinaryExpression, visitTernaryExpression, visitShortTernaryExpression, visitPostfixExpression, visitPrefixExpression, visitBooleanExpression, visitNotExpression, visitClosureExpression, visitTupleExpression, visitArrayExpression, visitMapExpression, visitMapEntryExpression, visitRangeExpression, visitSpreadExpression, visitSpreadMapExpression, visitMethodPointerExpression, visitUnaryMinusExpression, visitUnaryPlusExpression, visitBitwiseNegationExpression, visitCastExpression, visitDeclarationExpression, visitAttributeExpression, visitFieldExpression, visitRegexExpression, visitGStringExpression, visitArgumentlistExpression, visitClosureListExpression, visitBytecodeExpression, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 
Methods inherited from class org.codehaus.groovy.ast.CodeVisitorSupport
visitConstantExpression, visitReturnStatement, visitClassExpression, visitListExpression, visitPropertyExpression, visitVariableExpression, visitAssertStatement, visitBlockStatement, visitBreakStatement, visitCaseStatement, visitCatchStatement, visitContinueStatement, visitDoWhileLoop, visitExpressionStatement, visitForLoop, visitIfElse, visitSwitch, visitSynchronizedStatement, visitThrowStatement, visitTryCatchFinally, visitWhileLoop, visitMethodCallExpression, visitStaticMethodCallExpression, visitConstructorCallExpression, visitBinaryExpression, visitTernaryExpression, visitShortTernaryExpression, visitPostfixExpression, visitPrefixExpression, visitBooleanExpression, visitNotExpression, visitClosureExpression, visitTupleExpression, visitArrayExpression, visitMapExpression, visitMapEntryExpression, visitRangeExpression, visitSpreadExpression, visitSpreadMapExpression, visitMethodPointerExpression, visitUnaryMinusExpression, visitUnaryPlusExpression, visitBitwiseNegationExpression, visitCastExpression, visitDeclarationExpression, visitAttributeExpression, visitFieldExpression, visitRegexExpression, visitGStringExpression, visitArgumentlistExpression, visitClosureListExpression, visitBytecodeExpression, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Property Detail

BOOLEAN_CLASS

protected static final def BOOLEAN_CLASS


CONSTANT_EXPRESSION_VALUES

protected static final def CONSTANT_EXPRESSION_VALUES


MAX_SOURCE_LINE_LENGTH

public static final def MAX_SOURCE_LINE_LENGTH


SOURCE_LINE_LAST_SEGMENT_LENGTH

public static final def SOURCE_LINE_LAST_SEGMENT_LENGTH


rule

Rule rule


sourceCode

SourceCode sourceCode


violations

List violations


visited

Set visited


 
Constructor Detail

AbstractAstVisitor

AbstractAstVisitor()


 
Method Detail

addViolation

protected void addViolation(ASTNode node, def message = null)
Add a new Violation to the list of violations found by this visitor. Only add the violation if the node lineNumber >= 0.
param:
node - the Groovy AST Node
param:
message - the message for the violation; defaults to null


addViolation

protected void addViolation(Violation violation)
Add a new Violation to the list of violations found by this visitor.
param:
violation - the violation to add


getSourceUnit

protected SourceUnit getSourceUnit()


isConstantBooleanExpression

protected boolean isConstantBooleanExpression(def booleanExpression)


isFirstVisit

protected def isFirstVisit(def expression)
Return true if the AST expression has not already been visited. If it is the first visit, register the expression so that the next visit will return false.
param:
expression - the AST expression to check
return:
true if the AST expression has NOT already been visited


sourceLine

protected String sourceLine(ASTNode node)
Return the source line corresponding to the specified AST node
param:
node - the Groovy AST node


 

Groovy Documentation