Groovy Documentation

groovy.org.codenarc.source
[Groovy] Interface SourceCode


interface SourceCode

Represents a unit of source code to be analyzed

Authors:
Chris Mair


Field Summary
static int DEFAULT_COMPILER_PHASE

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

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

int getAstCompilerPhase()

@return compiler phase (as in org.codehaus.groovy.control.Phases) up to which the AST will be processed

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)

Map getMethodCallExpressions()

This method gives you all of the MethodCallExpressions defined in the AST without forcing you to walk the entire tree on every request.

String getName()

Get the logical name for this source code.

String getPath()

Get the logical path for this source code.

SuppressionAnalyzer getSuppressionAnalyzer()

Returns information about this classes' suppressed warnings.

String getText()

@return the full text of the source code

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

 

Field Detail

DEFAULT_COMPILER_PHASE

public static final int DEFAULT_COMPILER_PHASE


 
Method Detail

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


getAstCompilerPhase

int getAstCompilerPhase()
Returns:
compiler phase (as in org.codehaus.groovy.control.Phases) up to which the AST will be processed


getLineNumberForCharacterIndex

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


getLines

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


getMethodCallExpressions

Map getMethodCallExpressions()
This method gives you all of the MethodCallExpressions defined in the AST without forcing you to walk the entire tree on every request. They are cached for the lifespan of the SourceCode.
Returns:


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.
Returns:
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 (/).
Returns:
the name for this source; may be null


getSuppressionAnalyzer

SuppressionAnalyzer getSuppressionAnalyzer()
Returns information about this classes' suppressed warnings.
Returns:
suppression analyzer


getText

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


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
Returns:
the trimmed line at the specified index, or null if lineNumber is not valid
Parameters:
lineNumber - - the zero-based line number; may be negative


 

Groovy Documentation