Groovy Documentation

org.gmetrics.source
[Groovy] Class AbstractSourceCode

java.lang.Object
  org.gmetrics.source.AbstractSourceCode
All Implemented Interfaces:
SourceCode

abstract class AbstractSourceCode

Abstract superclass for SourceCode implementations

Authors:
Chris Mair
Version:
\$Revision: 155 \$ - \$Date: 2011-09-27 20:33:08 -0400 (Tue, 27 Sep 2011) \$


Property Summary
static def FILE_SEPARATOR

static def LOG

 
Method Summary
protected def createSourceUnit()

org.codehaus.groovy.ast.ModuleNode getAst()

Return the Groovy AST (Abstract Syntax Tree) for this source file

int getLineNumberForCharacterIndex(int charIndex)

Return the line index for the line containing the character at the specified index within the source code.

List getLines()

@return the List of lines of the source code (with line terminators removed)

boolean isValid()

Return true if and only if the source code can be successfully compiled

String line(int lineNumber)

Get the trimmed line at the specified index

protected String normalizePath(String path)

Return the normalized value of the specified path.

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

Property Detail

FILE_SEPARATOR

static final def FILE_SEPARATOR


LOG

static final def LOG


 
Method Detail

createSourceUnit

protected def createSourceUnit()


getAst

org.codehaus.groovy.ast.ModuleNode getAst()
Return the Groovy AST (Abstract Syntax Tree) for this source file
Returns:
the ModuleNode representing the AST for this source file


getLineNumberForCharacterIndex

int getLineNumberForCharacterIndex(int charIndex)
Return the line index for the line containing the character at the specified index within the source code.
Parameters:
charIndex - - the index of the character within the source code (zero-based)
Returns:
the line number (one-based) containing the specified character; Return -1 if charIndex is not valid.


getLines

List getLines()
Returns:
the List of lines of the source code (with line terminators removed)


isValid

boolean isValid()
Return true if and only if the source code can be successfully compiled
Returns:
true only if the source code is valid


line

String line(int lineNumber)
Get the trimmed line at the specified index
Parameters:
lineNumber - - the line number; may be negative
Returns:
the trimmed line at the specified index, or null if lineNumber is not valid


normalizePath

protected String normalizePath(String path)
Return the normalized value of the specified path. Convert file separator chars to standard '/'.
Parameters:
path - - the path to normalize
Returns:
the normalized value


 

Groovy Documentation