public class Emitter extends Object implements IEmitter
Modifier and Type | Field and Description |
---|---|
protected List<ICompilerProblem> |
problems |
Constructor and Description |
---|
Emitter(FilterWriter out) |
Modifier and Type | Method and Description |
---|---|
protected void |
flushBuilder() |
protected StringBuilder |
getBuilder() |
protected int |
getCurrentIndent() |
protected String |
getIndent(int numIndent) |
List<ICompilerProblem> |
getProblems() |
IASBlockWalker |
getWalker() |
void |
indentPop()
Pops an indent from the emitter so after newlines are emitted, the output
is correctly formatted.
|
void |
indentPush()
Pushes an indent into the emitter so after newlines are emitted, the
output is correctly formatted.
|
protected boolean |
isBufferWrite() |
protected void |
setBufferWrite(boolean value) |
void |
setWalker(IASBlockWalker value) |
String |
stringifyNode(IASNode node)
Takes the node argument and created a String representation if it using
the buffer temporarily.
|
void |
write(IEmitterTokens value)
Writes a string to the writer.
|
void |
write(String value) |
void |
writeNewline()
Writes newline character(s)
|
void |
writeNewline(IEmitterTokens value)
Writes the
value and then a newline which will automatically
have the indent applied after the \n character. |
void |
writeNewline(IEmitterTokens value,
boolean pushIndent)
Writes the
value after a push or pop of the indent. |
void |
writeNewline(String value) |
void |
writeNewline(String value,
boolean pushIndent) |
void |
writeSymbol(String value) |
void |
writeToken(IEmitterTokens value)
Writes a
ASEmitterTokens character to the buffer and appends a
space after automatically. |
void |
writeToken(String value) |
protected List<ICompilerProblem> problems
public Emitter(FilterWriter out)
protected boolean isBufferWrite()
protected void setBufferWrite(boolean value)
protected StringBuilder getBuilder()
protected void flushBuilder()
public List<ICompilerProblem> getProblems()
protected int getCurrentIndent()
public IASBlockWalker getWalker()
public void setWalker(IASBlockWalker value)
public void write(IEmitterTokens value)
IEmitter
protected String getIndent(int numIndent)
public void indentPush()
IEmitter
indentPush
in interface IEmitter
public void indentPop()
IEmitter
public void writeNewline()
IEmitter
writeNewline
in interface IEmitter
public void writeNewline(IEmitterTokens value)
IEmitter
value
and then a newline which will automatically
have the indent applied after the \n character.writeNewline
in interface IEmitter
value
- The String value to write before the \n is appended.public void writeNewline(String value)
writeNewline
in interface IEmitter
public void writeNewline(IEmitterTokens value, boolean pushIndent)
IEmitter
value
after a push or pop of the indent.
This method effectively lets you write a value and then indent our
outdent. The method can be useful in the following where your cursor
writer is at [0]
, you write
writeNewline("if (foo) {", true);
and the cursor after the
call will end up at [1]
.
[0]if (foo) { [1]this.something; }
writeNewline
in interface IEmitter
value
- The String value to write before the \n is appended.pushIndent
- Whether to push indent true
or pop indent
false
.public void writeNewline(String value, boolean pushIndent)
writeNewline
in interface IEmitter
public void writeSymbol(String value)
public void writeToken(IEmitterTokens value)
IEmitter
ASEmitterTokens
character to the buffer and appends a
space after automatically.writeToken
in interface IEmitter
value
- The ASEmitterTokens
value.public void writeToken(String value)
writeToken
in interface IEmitter
public String stringifyNode(IASNode node)
Note; This method is still beta, it need more logic if an emitter is actually using the buffer!
stringifyNode
in interface IEmitter
node
- The node walk and create a String for.Copyright © 2016 The Apache Software Foundation. All rights reserved.