Groovy Documentation

org.gmetrics.source
Class AbstractSourceCode

java.lang.Object
  org.gmetrics.source.AbstractSourceCode

class AbstractSourceCode

Abstract superclass for SourceCode implementations

author:
Chris Mair
version:
$Revision: 32 $ - $Date: 2009-12-15 21:37:46 -0500 (Tue, 15 Dec 2009) $


Property Summary
static def FILE_SEPARATOR

static def LOG

 
Constructor Summary
AbstractSourceCode()

 
Method Summary
protected def createSourceUnit()

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()

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


 
Constructor Detail

AbstractSourceCode

AbstractSourceCode()


 
Method Detail

createSourceUnit

protected def createSourceUnit()


getAst

ModuleNode getAst()
Return the Groovy AST (Abstract Syntax Tree) for this source file
return:
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.
param:
charIndex - the index of the character within the source code (zero-based)
return:
the line number (one-based) containing the specified character; Return -1 if charIndex is not valid.


getLines

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


line

String line(int lineNumber)
Get the trimmed line at the specified index
param:
lineNumber - the line number; may be negative
return:
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 '/'.
param:
path - the path to normalize
return:
the normalized value


 

Groovy Documentation