Groovy Documentation

groovy.org.codenarc.util
[Groovy] Class SourceCodeUtil

java.lang.Object
  groovy.org.codenarc.util.SourceCodeUtil

class SourceCodeUtil

Contains source related static utility methods

Authors:
Marcin Erdmann


Method Summary
static List nodeSourceLines(SourceCode source, org.codehaus.groovy.ast.ASTNode node)

static List sourceLinesBetween(SourceCode source, int startLine, int startColumn, int endLine, int endColumn)

Retrieves source lines between the start line and column and end line and column.

static List sourceLinesBetweenNodes(SourceCode source, org.codehaus.groovy.ast.ASTNode startNode, org.codehaus.groovy.ast.ASTNode endNode)

 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Method Detail

nodeSourceLines

static List nodeSourceLines(SourceCode source, org.codehaus.groovy.ast.ASTNode node)


sourceLinesBetween

static List sourceLinesBetween(SourceCode source, int startLine, int startColumn, int endLine, int endColumn)
Retrieves source lines between the start line and column and end line and column. Lines and columns are counted starting at one as do the lines and columns describing a beginning and end of ASTNode.
throws:
IllegalArgumentException when start is not before end, and any of the start/end parameters is lower than one
Parameters:
source - Source from which the lines are to be extracted
startLine - has to be greater than zero
startColumn - has to be greater than zero
endLine - has to be greater than zero
endColumn - has to be greater than zero
Returns:
a List of string containing the extracted code


sourceLinesBetweenNodes

static List sourceLinesBetweenNodes(SourceCode source, org.codehaus.groovy.ast.ASTNode startNode, org.codehaus.groovy.ast.ASTNode endNode)


 

Groovy Documentation