Package: org.gmetrics.source

## [Groovy] Interface SourceCode

- Represents a unit of source code to be analyzed

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

- - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `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)
    `` | `String` | `getName()` Get the logical name for this source code.
    `` | `String` | `getPath()` Get the logical path for this source code.
    `` | `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

- - ### Method Detail

    - #### 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

    - #### 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.

    - #### List getLines()

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

    - #### 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

    - #### 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

    - #### String getText()

      Returns:
        the full text of the source code

    - #### boolean isValid()

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

      Returns:
        true only if the source code is valid

    - #### 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