Groovy Documentation

org.gmetrics.source
Interface SourceCode


interface SourceCode

Represents a unit of source code to be analyzed

author:
Chris Mair
version:
$Revision: 24 $ - $Date: 2009-12-10 21:17:05 -0500 (Thu, 10 Dec 2009) $


Method Summary
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 getName()

Get the logical name for this source code.

String getPath()

Get the logical path for this source code.

String getText()

String line(int lineNumber)

Get the trimmed line at the specified index

 

Method Detail

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)


getName

String getName()
Get the logical name for this source code. If this object is a file, then the name is the filename, without a path.
return:
the name for this source; may be null


getPath

String getPath()
Get the logical path for this source code. If this object is a file, then the name is the full path in the filesystem. File separators are normalized to forward slash (/).
return:
the name for this source; may be null


getText

String getText()
return:
the full text of the source code


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


 

Groovy Documentation