Groovy 1.7.0

org.codehaus.groovy.transform.powerassert
Class SourceText

java.lang.Object
  org.codehaus.groovy.transform.powerassert.SourceText

class SourceText
extends Object

Provides the source text for an assertion statement and translates coordinates in the original source text to coordinates relative to the assertion's (normalized) source text.

author:
Peter Niederwieser


Constructor Summary
SourceText(AssertStatement stat, SourceUnit sourceUnit, Janitor janitor)

Constructs a SourceText by reading the given assertion's source text from the given source unit.

 
Method Summary
int getNormalizedColumn(int line, int column)

Returns the column in getNormalizedText() corresponding to the given line and column in the original source text.

int getNormalizedColumn(String str, int line, int column)

Returns the normalized column of the last occurrence of the given substring within the original source text ending before the given line and column (exclusive), or -1 if no such occurrence is found.

String getNormalizedText()

Returns the assertion's source text after removing line breaks.

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

Constructor Detail

SourceText

public SourceText(AssertStatement stat, SourceUnit sourceUnit, Janitor janitor)
Constructs a SourceText by reading the given assertion's source text from the given source unit.
param:
stat an assertion statement
param:
sourceUnit the source unit containing the assertion statement
param:
janitor a Janitor for cleaning up reader sources


 
Method Detail

getNormalizedColumn

public int getNormalizedColumn(int line, int column)
Returns the column in getNormalizedText() corresponding to the given line and column in the original source text. The first character in the normalized text has column 1.
param:
line a line number
param:
column a column number
return:
the column in getNormalizedText() corresponding to the given line and column in the original source text


getNormalizedColumn

public int getNormalizedColumn(String str, int line, int column)
Returns the normalized column of the last occurrence of the given substring within the original source text ending before the given line and column (exclusive), or -1 if no such occurrence is found.
param:
str a substring in the original source text
param:
line a line number
param:
column a column number
return:
the normalized column of the last occurrence of the given substring within the original source text ending before the given line and column (exclusive), or -1 if no such occurrence is found


getNormalizedText

public String getNormalizedText()
Returns the assertion's source text after removing line breaks.

Limitation: Line comments within the assertion's source text are not handled.

return:
the assertion's source text after removing line breaks.


 

Copyright © 2003-2009 The Codehaus. All rights reserved.