Merge pull request #875 from parrt/fix-TokenStreamRewriter-doc-getText

Fixes #819. fix-TokenStreamRewriter-doc-getText
This commit is contained in:
Terence Parr 2015-05-19 17:42:22 -07:00
commit 1374896a16
1 changed files with 10 additions and 3 deletions

View File

@ -92,7 +92,7 @@ import java.util.Map;
* ...
* rewriter.insertAfter(t, "text to put after t");}
* rewriter.insertAfter(u, "text after u");}
* System.out.println(rewriter.toString());
* System.out.println(rewriter.getText());
* </pre>
*
* <p>
@ -104,8 +104,8 @@ import java.util.Map;
* <pre>
* rewriter.insertAfter("pass1", t, "text to put after t");}
* rewriter.insertAfter("pass2", u, "text after u");}
* System.out.println(rewriter.toString("pass1"));
* System.out.println(rewriter.toString("pass2"));
* System.out.println(rewriter.getText("pass1"));
* System.out.println(rewriter.getText("pass2"));
* </pre>
*
* <p>
@ -371,6 +371,13 @@ public class TokenStreamRewriter {
return getText(DEFAULT_PROGRAM_NAME, Interval.of(0,tokens.size()-1));
}
/** Return the text from the original tokens altered per the
* instructions given to this rewriter in programName.
*/
public String getText(String programName) {
return getText(programName, Interval.of(0,tokens.size()-1));
}
/** Return the text associated with the tokens in the interval from the
* original token stream but with the alterations given to this rewriter.
* The interval refers to the indexes in the original token stream.