Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.deft.extension.tools.astlayouter
Class ASTLayouter

    java.lang.Object
      org.deft.extension.tools.astlayouter.ASTLayouter

    public class ASTLayouter

extends java.lang.Object

The TokenLayouter provides basic layout operation on an AST.

Author:
  Martin Heinzerling

Constructor Summary
`ASTLayouter(java.util.List<org.deft.repository.ast.TokenNode> tokenNodes)`

Method Summary
`int` | `getColOfLine(org.deft.repository.ast.Token targetToken)`
`int` | `getEndCol()`
`int` | `getEndLine()`
`org.deft.repository.ast.Token` | `getNextTokenInSameLine(org.deft.repository.ast.Token targetToken)`
`org.deft.repository.ast.Token` | `getPrevTokenInSameLine(org.deft.repository.ast.Token targetToken)`
`void` | `indentRelative(int offset)` Indents the whole AST.
`void` | `indentRelative(org.deft.repository.ast.Token startToken, org.deft.repository.ast.Token endToken, int offset)` Indents a block of token.
`void` | `insertLineBreakAfter(org.deft.repository.ast.Token targetToken)`
`void` | `insertLineBreakBefore(org.deft.repository.ast.Token targetToken)`
`void` | `insertLinesAfter(org.deft.repository.ast.Token targetToken, int offset)`
`void` | `insertLinesBefore(int offset)` Insert lines before the first token.
`void` | `insertLinesBefore(org.deft.repository.ast.Token targetToken, int offset)`
`void` | `insertSpacesAfter(org.deft.repository.ast.Token targetToken, int offset)`
`void` | `insertSpacesBefore(org.deft.repository.ast.Token targetToken, int offset)`
`void` | `reload(java.util.List<org.deft.repository.ast.TokenNode> tokenNodes)` You have to reload a TokenLayouter after modification.
`void` | `removeLineBreakAfter(org.deft.repository.ast.Token targetToken)` Removes linebreak in the line of the Token.
`void` | `removeLineBreakBefore(org.deft.repository.ast.Token targetToken)` Removes linebreak in the line of the Token.
`void` | `repairOffset()` Recalculates the offset of each token in the layout.
`void` | `reset()` First token starts at position (1,1).
`java.lang.String` | `toString()`
`void` | `trim(org.deft.repository.ast.Token targetToken)`
`void` | `trimLeft(org.deft.repository.ast.Token targetToken)`
`void` | `trimLinesAfter(org.deft.repository.ast.Token targetToken)`
`void` | `trimLinesBefore(org.deft.repository.ast.Token targetToken)`
`void` | `trimRight(org.deft.repository.ast.Token targetToken)`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### ASTLayouter

    public ASTLayouter(java.util.List<org.deft.repository.ast.TokenNode> tokenNodes)

Method Detail

### reload

    public void reload(java.util.List<org.deft.repository.ast.TokenNode> tokenNodes)

  You have to reload a TokenLayouter after modification.

  Parameters:
    `tokenNodes` - serialized AST

### repairOffset

    public void repairOffset()

  Recalculates the offset of each token in the layout. Recommended after last operation.

### insertSpacesBefore

    public void insertSpacesBefore(org.deft.repository.ast.Token targetToken,
                                   int offset)

  Parameters:
    `targetToken` - token
    `offset` - spaces

### insertSpacesAfter

    public void insertSpacesAfter(org.deft.repository.ast.Token targetToken,
                                  int offset)

  Parameters:
    `targetToken` - token
    `offset` - spaces

### insertLinesBefore

    public void insertLinesBefore(org.deft.repository.ast.Token targetToken,
                                  int offset)

  Parameters:
    `targetToken` - token
    `offset` - lines

### insertLinesBefore

    public void insertLinesBefore(int offset)

  Insert lines before the first token.

  Parameters:
    `offset` - lines

### insertLinesAfter

    public void insertLinesAfter(org.deft.repository.ast.Token targetToken,
                                 int offset)

  Parameters:
    `targetToken` - token
    `offset` - lines

### insertLineBreakBefore

    public void insertLineBreakBefore(org.deft.repository.ast.Token targetToken)

  Parameters:
    `targetToken` - token

### insertLineBreakAfter

    public void insertLineBreakAfter(org.deft.repository.ast.Token targetToken)

  Parameters:
    `targetToken` - token

### removeLineBreakAfter

    public void removeLineBreakAfter(org.deft.repository.ast.Token targetToken)

  Removes linebreak in the line of the Token.

  Parameters:
    `targetToken` - token

### removeLineBreakBefore

    public void removeLineBreakBefore(org.deft.repository.ast.Token targetToken)

  Removes linebreak in the line of the Token.

  Parameters:
    `targetToken` - token

### trim

    public void trim(org.deft.repository.ast.Token targetToken)

  Parameters:
    `targetToken` - token

### trimLeft

    public void trimLeft(org.deft.repository.ast.Token targetToken)

  Parameters:
    `targetToken` - token

### trimRight

    public void trimRight(org.deft.repository.ast.Token targetToken)

  Parameters:
    `targetToken` - token

### trimLinesBefore

    public void trimLinesBefore(org.deft.repository.ast.Token targetToken)

  Parameters:
    `targetToken` - token

### trimLinesAfter

    public void trimLinesAfter(org.deft.repository.ast.Token targetToken)

  Parameters:
    `targetToken` - token

### indentRelative

    public void indentRelative(org.deft.repository.ast.Token startToken,
                               org.deft.repository.ast.Token endToken,
                               int offset)

  Indents a block of token.

  Parameters:
    `startToken` - token
    `endToken` - inclusive
    `offset` - cols

### indentRelative

    public void indentRelative(int offset)

  Indents the whole AST.

  Parameters:
    `offset` - cols

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

### reset

    public void reset()

  First token starts at position (1,1).

### getEndLine

    public int getEndLine()

### getColOfLine

    public int getColOfLine(org.deft.repository.ast.Token targetToken)

  Parameters:
    `targetToken` - token
  Returns:
    start of line with this token

### getEndCol

    public int getEndCol()

  Returns:
    last col of the layout

### getNextTokenInSameLine

    public org.deft.repository.ast.Token getNextTokenInSameLine(org.deft.repository.ast.Token targetToken)

  Parameters:
    `targetToken` - token
  Returns:
    Token or null

### getPrevTokenInSameLine

    public org.deft.repository.ast.Token getPrevTokenInSameLine(org.deft.repository.ast.Token targetToken)

  Parameters:
    `targetToken` - token
  Returns:
    Token or null

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD