|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.google.caja.render.SideBySideRenderer
public abstract class SideBySideRenderer
Renders rewritten source code interleaved with the original. E.g.
// Rewritten by cajoler.
muckWith( IMPORTS___.muckWith(
document.forms[0]) IMPORTS___.document.forms[0]);
Nested Class Summary | |
---|---|
private static class |
SideBySideRenderer.Chunk
|
Field Summary | |
---|---|
private java.util.List<SideBySideRenderer.Chunk> |
chunks
Chunks of original source. |
private FilePosition |
chunkStart
|
private FilePosition |
lastPos
|
private FilePosition |
mark
|
private java.util.Map<InputSource,java.lang.Integer> |
maxLineSeen
|
private java.util.Map<InputSource,java.lang.String[]> |
originalSourceLines
|
private java.lang.StringBuilder |
renderedBuf
|
private TokenConsumer |
renderer
|
Constructor Summary | |
---|---|
SideBySideRenderer(java.util.Map<InputSource,? extends java.lang.CharSequence> originalSource)
|
Method Summary | |
---|---|
void |
consume(java.lang.String text)
Receives tokens from rendered parse trees. |
private void |
emitLine()
|
protected abstract void |
emitLine(FilePosition startOfLine,
java.lang.String original,
java.lang.String rendered)
Called when rendered tokens have been processed for a line of original source. |
private int |
lastLineNo(InputSource src)
|
protected abstract TokenConsumer |
makeRenderer(java.lang.StringBuilder renderedSrc)
|
void |
mark(FilePosition pos)
Marks tokens consumed before the next call as falling in
this range of file positions. |
void |
noMoreTokens()
Called when no more tokens are available. |
private java.lang.String |
originalSourceSnippet(InputSource src,
int startLine,
int endLine)
|
private static java.util.List<Pair<java.lang.String,java.lang.Integer>> |
splitChunks(java.lang.String renderedSrc)
|
protected void |
switchSource(InputSource previous,
InputSource next)
Called when we render a token from a different source than previously. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final java.util.Map<InputSource,java.lang.String[]> originalSourceLines
private final java.util.Map<InputSource,java.lang.Integer> maxLineSeen
private final TokenConsumer renderer
private FilePosition lastPos
private FilePosition mark
private FilePosition chunkStart
private final java.util.List<SideBySideRenderer.Chunk> chunks
private java.lang.StringBuilder renderedBuf
Constructor Detail |
---|
public SideBySideRenderer(java.util.Map<InputSource,? extends java.lang.CharSequence> originalSource)
Method Detail |
---|
protected abstract void emitLine(FilePosition startOfLine, java.lang.String original, java.lang.String rendered)
startOfLine
- a file position into the original source code.original
- zero or more lines of original source code.rendered
- one or more lines of rendered source code.protected void switchSource(InputSource previous, InputSource next)
previous
- the source from which the last rendered token came.next
- the source from which the next rendered token will come,
unless switchSource is called again before consume(java.lang.String)
.protected abstract TokenConsumer makeRenderer(java.lang.StringBuilder renderedSrc)
public void mark(FilePosition pos)
TokenConsumer
consumed
before the next call as falling in
this range of file positions.
mark
in interface TokenConsumer
pos
- null indicates don't know.public void consume(java.lang.String text)
TokenConsumer
consume
in interface TokenConsumer
public void noMoreTokens()
TokenConsumer
noMoreTokens
in interface TokenConsumer
private void emitLine()
private static java.util.List<Pair<java.lang.String,java.lang.Integer>> splitChunks(java.lang.String renderedSrc)
private java.lang.String originalSourceSnippet(InputSource src, int startLine, int endLine)
private int lastLineNo(InputSource src)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |