public class ASEmitter extends Object implements IASEmitter, IEmitter
Constructor and Description |
---|
ASEmitter(FilterWriter out) |
Modifier and Type | Method and Description |
---|---|
protected void |
emitAccessorKeyword(IKeywordNode node) |
void |
emitArguments(IContainerNode node) |
void |
emitAsOperator(IBinaryOperatorNode node) |
protected void |
emitAssignedValue(IExpressionNode node) |
void |
emitBinaryOperator(IBinaryOperatorNode node)
Emit an operator statement.
|
void |
emitBlockClose(IContainerNode node) |
void |
emitBlockOpen(IContainerNode node) |
void |
emitCatch(ICatchNode node)
Emit a
catch(){} statement. |
void |
emitClass(IClassNode node)
Emit a Class.
|
void |
emitContainer(IContainerNode node) |
void |
emitDeclarationName(IDefinitionNode node) |
void |
emitDoLoop(IWhileLoopNode node)
Emit a
do{}while() statement. |
void |
emitDynamicAccess(IDynamicAccessNode node) |
void |
emitE4XFilter(IMemberAccessExpressionNode node) |
void |
emitField(IVariableNode node)
Emit a full Class field member.
|
void |
emitFieldDocumentation(IVariableNode node)
Emit a documentation comment for a Class field or constant
IVariableNode . |
void |
emitForEachLoop(IForLoopNode node)
Emit a
for each statement. |
void |
emitForLoop(IForLoopNode node)
Emit a
for statement. |
void |
emitFunctionBlockHeader(IFunctionNode node)
Emit a header at the start of a function block.
|
void |
emitFunctionCall(IFunctionCallNode node)
Emit a function call like
new Foo() or foo(42) . |
void |
emitFunctionObject(IFunctionObjectNode node)
Emit an anonymous
IFunctionObjectNode . |
protected void |
emitFunctionScope(IScopedNode node) |
void |
emitGetAccessor(IGetterNode node)
Emit a full Class getter member.
|
void |
emitGetAccessorDocumentation(IGetterNode node)
Emit a documentation comment for a Class method
IGetterNode . |
void |
emitIdentifier(IIdentifierNode node) |
void |
emitIf(IIfNode node)
Emit a
if(){}else if(){}else{} statement. |
void |
emitImport(IImportNode node) |
void |
emitInterface(IInterfaceNode node)
Emit an Interface.
|
void |
emitIsOperator(IBinaryOperatorNode node) |
void |
emitIterationFlow(IIterationFlowNode node) |
void |
emitKeyword(IKeywordNode node) |
void |
emitLabelStatement(LabeledStatementNode node)
Emit a
foo:{} statement. |
void |
emitLanguageIdentifier(ILanguageIdentifierNode node) |
void |
emitLiteral(ILiteralNode node) |
void |
emitLiteralContainer(ILiteralContainerNode node) |
void |
emitLocalNamedFunction(IFunctionNode node)
Emit an local named function
IFunctionNode . |
void |
emitMemberAccessExpression(IMemberAccessExpressionNode node) |
void |
emitMemberKeyword(IDefinitionNode node) |
protected void |
emitMemberName(IDefinitionNode node) |
void |
emitMetaTag(IMetaTagNode node) |
void |
emitMethod(IFunctionNode node)
Emit a full Class or Interface method member.
|
void |
emitMethodDocumentation(IFunctionNode node)
Emit a documentation comment for a Class method
IFunctionNode . |
void |
emitMethodScope(IScopedNode node) |
protected void |
emitModifiers(IDefinition definition) |
void |
emitNamespace(INamespaceNode node)
Emit a namespace member.
|
void |
emitNamespaceAccessExpression(INamespaceAccessExpressionNode node) |
protected void |
emitNamespaceIdentifier(IDefinitionNode node) |
void |
emitNumericLiteral(INumericLiteralNode node) |
void |
emitObjectLiteralValuePair(IObjectLiteralValuePairNode node) |
void |
emitPackageContents(IPackageDefinition definition) |
void |
emitPackageFooter(IPackageDefinition definition) |
void |
emitPackageHeader(IPackageDefinition definition) |
void |
emitPackageHeaderContents(IPackageDefinition definition) |
void |
emitParameter(IParameterNode node) |
void |
emitParameters(IContainerNode node) |
void |
emitReturn(IReturnNode node) |
void |
emitSetAccessor(ISetterNode node)
Emit a full Class setter member.
|
void |
emitSetAccessorDocumentation(ISetterNode node)
Emit a documentation comment for a Class accessor
IGetterNode . |
void |
emitStatement(IASNode node)
Emit a statement found within an
IBlockNode . |
void |
emitSwitch(ISwitchNode node)
Emit a
switch(){} statement. |
void |
emitTernaryOperator(ITernaryOperatorNode node) |
void |
emitThrow(IThrowNode node)
Emit a
throw statement. |
void |
emitTry(ITryNode node)
Emit a
try{} statement. |
protected void |
emitType(IExpressionNode node) |
void |
emitTypedExpression(ITypedExpressionNode node) |
void |
emitUnaryOperator(IUnaryOperatorNode node) |
void |
emitUseNamespace(IUseNamespaceNode node) |
void |
emitVarDeclaration(IVariableNode node)
Emit a variable declaration found in expression statements within scoped
blocks.
|
void |
emitVariableExpression(IVariableExpressionNode node) |
void |
emitWhileLoop(IWhileLoopNode node)
Emit a
while(){} statement. |
void |
emitWith(IWithNode node)
Emit a
with(){} statement. |
protected ITypeDefinition |
findType(Collection<IDefinition> definitions) |
protected ITypeNode |
findTypeNode(IPackageNode node) |
protected void |
flushBuilder() |
protected StringBuilder |
getBuilder() |
protected static IFunctionNode |
getConstructor(IDefinitionNode[] members) |
protected int |
getCurrentColumn() |
protected int |
getCurrentIndent() |
protected int |
getCurrentLine() |
IDocEmitter |
getDocEmitter() |
protected String |
getIndent(int numIndent) |
List<ICompilerProblem> |
getProblems() |
IBlockWalker |
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 static boolean |
isImplicit(IContainerNode node) |
protected static boolean |
isLastStatement(IASNode node) |
String |
postProcess(String output) |
void |
setBufferWrite(boolean value) |
protected void |
setBuilder(StringBuilder sb) |
void |
setDocEmitter(IDocEmitter value) |
void |
setWalker(IBlockWalker value) |
String |
stringifyNode(IASNode node)
Takes the node argument and created a String representation if it using
the buffer temporarily.
|
protected void |
visitForBody(IContainerNode node) |
void |
write(IEmitterTokens value)
Writes a string to the writer.
|
void |
write(String value) |
protected void |
writeIndent() |
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) |
public ASEmitter(FilterWriter out)
protected boolean isBufferWrite()
public void setBufferWrite(boolean value)
protected StringBuilder getBuilder()
protected void setBuilder(StringBuilder sb)
protected void flushBuilder()
public List<ICompilerProblem> getProblems()
protected int getCurrentIndent()
protected void writeIndent()
public IBlockWalker getWalker()
getWalker
in interface IASEmitter
public void setWalker(IBlockWalker value)
setWalker
in interface IASEmitter
public IDocEmitter getDocEmitter()
getDocEmitter
in interface IASEmitter
public void setDocEmitter(IDocEmitter value)
setDocEmitter
in interface IASEmitter
protected int getCurrentLine()
protected int getCurrentColumn()
public String postProcess(String output)
postProcess
in interface IASEmitter
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 void emitImport(IImportNode node)
emitImport
in interface IASEmitter
public void emitPackageHeader(IPackageDefinition definition)
emitPackageHeader
in interface IASEmitter
public void emitPackageHeaderContents(IPackageDefinition definition)
emitPackageHeaderContents
in interface IASEmitter
public void emitPackageContents(IPackageDefinition definition)
emitPackageContents
in interface IASEmitter
public void emitPackageFooter(IPackageDefinition definition)
emitPackageFooter
in interface IASEmitter
public void emitClass(IClassNode node)
IASEmitter
emitClass
in interface IASEmitter
node
- The IClassNode
class.public void emitInterface(IInterfaceNode node)
IASEmitter
emitInterface
in interface IASEmitter
node
- The IInterfaceNode
class.public void emitVarDeclaration(IVariableNode node)
IASEmitter
emitVarDeclaration
in interface IASEmitter
node
- The IVariableNode
or chain of variable nodes.public void emitFieldDocumentation(IVariableNode node)
IASEmitter
IVariableNode
.emitFieldDocumentation
in interface IASEmitter
node
- The IVariableNode
class field member.public void emitField(IVariableNode node)
IASEmitter
emitField
in interface IASEmitter
node
- The IVariableNode
class field member.public void emitMethodDocumentation(IFunctionNode node)
IASEmitter
IFunctionNode
.emitMethodDocumentation
in interface IASEmitter
node
- The IFunctionNode
class method member.public void emitMethod(IFunctionNode node)
IASEmitter
emitMethod
in interface IASEmitter
node
- The IFunctionNode
class method member.public void emitGetAccessorDocumentation(IGetterNode node)
IASEmitter
IGetterNode
.emitGetAccessorDocumentation
in interface IASEmitter
node
- The IGetterNode
class accessor member.public void emitGetAccessor(IGetterNode node)
IASEmitter
emitGetAccessor
in interface IASEmitter
node
- The IVariableNode
class getter member.public void emitSetAccessorDocumentation(ISetterNode node)
IASEmitter
IGetterNode
.emitSetAccessorDocumentation
in interface IASEmitter
node
- The ISetterNode
class accessor member.public void emitSetAccessor(ISetterNode node)
IASEmitter
emitSetAccessor
in interface IASEmitter
node
- The ISetterNode
class setter member.public void emitLocalNamedFunction(IFunctionNode node)
IASEmitter
IFunctionNode
.emitLocalNamedFunction
in interface IASEmitter
node
- The local named function IFunctionNode
.public void emitFunctionObject(IFunctionObjectNode node)
IASEmitter
IFunctionObjectNode
.emitFunctionObject
in interface IASEmitter
node
- The anonymous IFunctionObjectNode
.public void emitNamespace(INamespaceNode node)
IASEmitter
emitNamespace
in interface IASEmitter
node
- The INamespaceNode
class member.protected void emitNamespaceIdentifier(IDefinitionNode node)
protected void emitModifiers(IDefinition definition)
public void emitMemberKeyword(IDefinitionNode node)
protected void emitMemberName(IDefinitionNode node)
public void emitDeclarationName(IDefinitionNode node)
public void emitParameters(IContainerNode node)
public void emitParameter(IParameterNode node)
emitParameter
in interface IASEmitter
protected void emitType(IExpressionNode node)
protected void emitAssignedValue(IExpressionNode node)
public void emitFunctionBlockHeader(IFunctionNode node)
IASEmitter
emitFunctionBlockHeader
in interface IASEmitter
node
- The IFunctionNode
node.public void emitMethodScope(IScopedNode node)
protected void emitAccessorKeyword(IKeywordNode node)
protected void emitFunctionScope(IScopedNode node)
public void emitStatement(IASNode node)
IASEmitter
IBlockNode
.emitStatement
in interface IASEmitter
node
- The IASNode
statement.public void emitIf(IIfNode node)
IASEmitter
if(){}else if(){}else{}
statement.emitIf
in interface IASEmitter
node
- The IIfNode
node.public void emitForEachLoop(IForLoopNode node)
IASEmitter
for each
statement.emitForEachLoop
in interface IASEmitter
node
- The IForLoopNode
node.public void emitForLoop(IForLoopNode node)
IASEmitter
for
statement.emitForLoop
in interface IASEmitter
node
- The IForLoopNode
node.public void emitSwitch(ISwitchNode node)
IASEmitter
switch(){}
statement.emitSwitch
in interface IASEmitter
node
- The ISwitchNode
node.public void emitWhileLoop(IWhileLoopNode node)
IASEmitter
while(){}
statement.emitWhileLoop
in interface IASEmitter
node
- The IWhileLoopNode
node.public void emitDoLoop(IWhileLoopNode node)
IASEmitter
do{}while()
statement.emitDoLoop
in interface IASEmitter
node
- The IWhileLoopNode
node.public void emitWith(IWithNode node)
IASEmitter
with(){}
statement.emitWith
in interface IASEmitter
node
- The IWithNode
node.public void emitThrow(IThrowNode node)
IASEmitter
throw
statement.emitThrow
in interface IASEmitter
node
- The IThrowNode
node.public void emitTry(ITryNode node)
IASEmitter
try{}
statement.emitTry
in interface IASEmitter
node
- The ITryNode
node.public void emitCatch(ICatchNode node)
IASEmitter
catch(){}
statement.emitCatch
in interface IASEmitter
node
- The ICatchNode
node.public void emitReturn(IReturnNode node)
emitReturn
in interface IASEmitter
public void emitFunctionCall(IFunctionCallNode node)
IASEmitter
new Foo()
or foo(42)
.emitFunctionCall
in interface IASEmitter
node
- The IFunctionCallNode
node.public void emitArguments(IContainerNode node)
emitArguments
in interface IASEmitter
public void emitAsOperator(IBinaryOperatorNode node)
emitAsOperator
in interface IASEmitter
public void emitIsOperator(IBinaryOperatorNode node)
emitIsOperator
in interface IASEmitter
public void emitBinaryOperator(IBinaryOperatorNode node)
IASEmitter
emitBinaryOperator
in interface IASEmitter
node
- The IBinaryOperatorNode
or chain of variable nodes.protected ITypeNode findTypeNode(IPackageNode node)
protected ITypeDefinition findType(Collection<IDefinition> definitions)
protected static IFunctionNode getConstructor(IDefinitionNode[] members)
protected static boolean isLastStatement(IASNode node)
protected static final boolean isImplicit(IContainerNode node)
protected void visitForBody(IContainerNode node)
public void emitLiteral(ILiteralNode node)
emitLiteral
in interface IASEmitter
public void emitLiteralContainer(ILiteralContainerNode node)
emitLiteralContainer
in interface IASEmitter
public void emitIdentifier(IIdentifierNode node)
emitIdentifier
in interface IASEmitter
public void emitNumericLiteral(INumericLiteralNode node)
emitNumericLiteral
in interface IASEmitter
public void emitKeyword(IKeywordNode node)
emitKeyword
in interface IASEmitter
public void emitIterationFlow(IIterationFlowNode node)
emitIterationFlow
in interface IASEmitter
public void emitMemberAccessExpression(IMemberAccessExpressionNode node)
emitMemberAccessExpression
in interface IASEmitter
public void emitDynamicAccess(IDynamicAccessNode node)
emitDynamicAccess
in interface IASEmitter
public void emitTypedExpression(ITypedExpressionNode node)
emitTypedExpression
in interface IASEmitter
public void emitVariableExpression(IVariableExpressionNode node)
emitVariableExpression
in interface IASEmitter
public void emitTernaryOperator(ITernaryOperatorNode node)
emitTernaryOperator
in interface IASEmitter
public void emitObjectLiteralValuePair(IObjectLiteralValuePairNode node)
emitObjectLiteralValuePair
in interface IASEmitter
public void emitLabelStatement(LabeledStatementNode node)
IASEmitter
foo:{}
statement.emitLabelStatement
in interface IASEmitter
node
- The LabeledStatementNode
node.public void emitNamespaceAccessExpression(INamespaceAccessExpressionNode node)
emitNamespaceAccessExpression
in interface IASEmitter
public void emitUnaryOperator(IUnaryOperatorNode node)
emitUnaryOperator
in interface IASEmitter
public void emitLanguageIdentifier(ILanguageIdentifierNode node)
emitLanguageIdentifier
in interface IASEmitter
public void emitMetaTag(IMetaTagNode node)
emitMetaTag
in interface IASEmitter
public void emitContainer(IContainerNode node)
emitContainer
in interface IASEmitter
public void emitE4XFilter(IMemberAccessExpressionNode node)
emitE4XFilter
in interface IASEmitter
public void emitUseNamespace(IUseNamespaceNode node)
emitUseNamespace
in interface IASEmitter
public void emitBlockOpen(IContainerNode node)
emitBlockOpen
in interface IASEmitter
public void emitBlockClose(IContainerNode node)
emitBlockClose
in interface IASEmitter
public String stringifyNode(IASNode node)
IEmitter
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.