Lombok.ast - v0.2

lombok.ast.printer
Interface SourceFormatter

All Known Implementing Classes:
HtmlFormatter, StructureFormatter, TextFormatter

public interface SourceFormatter


Field Summary
static String FAIL
           
 
Method Summary
 void addError(int errorStart, int errorEnd, String errorMessage)
          Registers a parse error with the formatter.
 void append(String text)
          Add raw text to the output stream.
 void buildBlock(Node node)
          Opens a new AST level which is normally rendered as a block (example: statements, methods, type bodies).
 void buildInline(Node node)
          Opens a new AST level which is normally rendered inline (example: expressions, literals, modifiers, identifiers, etc).
 void closeBlock()
          Closes the previous buildBlock(Node) call.
 void closeInline()
          Closes the previous buildInline(Node) call.
 void endSuppressBlock()
          Closes the previous startSuppressBlock() call.
 void endSuppressIndent()
          Closes the previous startSuppressIndent() call.
 void fail(String fail)
          The AST is not valid; it applies to the current level.
 String finish()
          Generate the source representation and return it as a string.
 void keyword(String text)
           
 void nameNextElement(String name)
          The next buildInline(Node) or buildBlock(Node)'s relation to the current block is named by this call.
 void operator(String text)
           
 void property(String name, Object value)
           
 void setTimeTaken(long taken)
          Reports the total time taken in milliseconds by the parser.
 void space()
          Generate horizontal space.
 void startSuppressBlock()
          The next buildBlock(Node) call should NOT be rendered in its own vertical area, but should instead be treated as an inline element.
 void startSuppressIndent()
          The next buildBlock(Node) call should NOT indent.
 void verticalSpace()
          Generate an extra vertical spacer if the output format allows for it.
 

Field Detail

FAIL

static final String FAIL
See Also:
Constant Field Values
Method Detail

fail

void fail(String fail)
The AST is not valid; it applies to the current level.

Parameters:
fail - Human readable explanation of what's wrong with the AST at this level.

property

void property(String name,
              Object value)

keyword

void keyword(String text)

operator

void operator(String text)

verticalSpace

void verticalSpace()
Generate an extra vertical spacer if the output format allows for it. Only occurs between block elements. Example: Between a package statement and the import statements, verticalSpace will be called.


space

void space()
Generate horizontal space. Where relevant, the space should be 1 character wide.


append

void append(String text)
Add raw text to the output stream. NB: Parentheses, braces and brackets that are structurally relevant as opening and/or closing a group are always appended separately; therefore, if you want to do special highlighting on parens that go together, you only have to check if the text appended is a single character long and contains a brace, bracket, or paren.

Parameters:
text - The raw text to print. If your output format requires it, it is the implementor's responsibility to escape this text.

buildInline

void buildInline(Node node)
Opens a new AST level which is normally rendered inline (example: expressions, literals, modifiers, identifiers, etc).

Parameters:
node - The AST node that this level represents. Can be null which signals that the current node has an inline substructure.

closeInline

void closeInline()
Closes the previous buildInline(Node) call.


startSuppressBlock

void startSuppressBlock()
The next buildBlock(Node) call should NOT be rendered in its own vertical area, but should instead be treated as an inline element. Example: The execution statement is part of an if statement but has to be a statement, which is normally a block element. This call is generated before the execution statement so that the execution statement is printed inline with the if statement.


endSuppressBlock

void endSuppressBlock()
Closes the previous startSuppressBlock() call.


startSuppressIndent

void startSuppressIndent()
The next buildBlock(Node) call should NOT indent. Example: The case or default statement inside a switch block.


endSuppressIndent

void endSuppressIndent()
Closes the previous startSuppressIndent() call.


buildBlock

void buildBlock(Node node)
Opens a new AST level which is normally rendered as a block (example: statements, methods, type bodies).

Parameters:
node - The AST node that this level represents. Can be null which signals that the current node has a block substructure.

closeBlock

void closeBlock()
Closes the previous buildBlock(Node) call.


addError

void addError(int errorStart,
              int errorEnd,
              String errorMessage)
Registers a parse error with the formatter.


finish

String finish()
Generate the source representation and return it as a string.


setTimeTaken

void setTimeTaken(long taken)
Reports the total time taken in milliseconds by the parser.


nameNextElement

void nameNextElement(String name)
The next buildInline(Node) or buildBlock(Node)'s relation to the current block is named by this call. Not all elements will get a name, and the name only applies to the next buildBlock/Inline call, not to any further calls.


Lombok.ast - v0.2

Copyright © 2010-2011 The Project Lombok Authors, licensed under the MIT licence.