public class TokenManager extends java.lang.Object implements java.lang.Iterable<Token>
| Constructor and Description |
|---|
TokenManager(java.util.List<Token> tokens,
java.lang.String source,
DefaultCodeFormatterOptions options) |
TokenManager(java.util.List<Token> tokens,
TokenManager parent) |
| Modifier and Type | Method and Description |
|---|---|
void |
addDisableFormatTokenPair(Token formatOffTag,
Token formatOnTag) |
void |
addNLSAlignIndex(int index,
int align) |
void |
applyFormatOff() |
char |
charAt(int sourcePosition) |
int |
countLineBreaksBetween(java.lang.String text,
int startPosition,
int endPosition) |
int |
countLineBreaksBetween(Token previous,
Token current) |
int |
findFirstTokenInLine(int startIndex) |
int |
findFirstTokenInLine(int startIndex,
boolean includeWraps,
boolean includeForced) |
int |
findIndex(int positionInSource,
int tokenType,
boolean forward) |
int |
findSourcePositionInLine(int position) |
int |
firstIndexAfter(ASTNode node,
int tokenType) |
int |
firstIndexBefore(ASTNode node,
int tokenType) |
int |
firstIndexIn(ASTNode node,
int tokenType) |
Token |
firstTokenAfter(ASTNode node,
int tokenType) |
Token |
firstTokenBefore(ASTNode node,
int tokenType) |
Token |
firstTokenIn(ASTNode node,
int tokenType) |
Token |
get(int index) |
int |
getLength(int originalStart,
int originalEnd,
int startPosition)
Calculates the length of a source code fragment.
|
int |
getLength(Token token,
int startPosition) |
int |
getNLSAlign(int index) |
int |
getPositionInLine(int tokenIndex) |
java.lang.String |
getSource() |
int |
getSourceLength() |
int |
indexOf(Token token) |
void |
insert(int tokenIndex,
Token token)
Adds given token at given index.
|
boolean |
isGuardClause(Block node) |
boolean |
isInHeader(int tokenIndex) |
java.util.Iterator<Token> |
iterator() |
int |
lastIndexIn(ASTNode node,
int tokenType) |
Token |
lastTokenIn(ASTNode node,
int tokenType) |
void |
remove(int tokenIndex)
Removes the token at given index.
|
void |
setHeaderEndIndex(int headerEndIndex) |
int |
size() |
int |
toIndent(int indent,
boolean isWrapped) |
java.lang.String |
toString(ASTNode node) |
java.lang.String |
toString(int tokenIndex)
Gets token text with characters escaped as HTML entities where necessary.
|
java.lang.String |
toString(Token token)
Gets token text with characters escaped as HTML entities where necessary.
|
int |
traverse(int startIndex,
TokenTraverser traverser) |
public TokenManager(java.util.List<Token> tokens, java.lang.String source, DefaultCodeFormatterOptions options)
public TokenManager(java.util.List<Token> tokens, TokenManager parent)
public Token get(int index)
public int size()
public void remove(int tokenIndex)
Warning: never call this method after wrap policies have been added to tokens since wrap parent indexes may become invalid.
public void insert(int tokenIndex,
Token token)
Warning: never call this method after wrap policies have been added to tokens since wrap parent indexes may become invalid.
public java.lang.String toString(int tokenIndex)
tokenIndex - index of the token to get.public java.lang.String toString(Token token)
public java.lang.String toString(ASTNode node)
public java.lang.String getSource()
public int indexOf(Token token)
public char charAt(int sourcePosition)
public int getSourceLength()
public int findIndex(int positionInSource,
int tokenType,
boolean forward)
public java.util.Iterator<Token> iterator()
iterator in interface java.lang.Iterable<Token>public boolean isGuardClause(Block node)
public int firstIndexIn(ASTNode node, int tokenType)
public int lastIndexIn(ASTNode node, int tokenType)
public int firstIndexAfter(ASTNode node, int tokenType)
public int firstIndexBefore(ASTNode node, int tokenType)
public int countLineBreaksBetween(java.lang.String text,
int startPosition,
int endPosition)
public int getPositionInLine(int tokenIndex)
public int findSourcePositionInLine(int position)
public int getLength(Token token, int startPosition)
token - the token to measurestartPosition - position in line of the first character (affects tabs calculation)public int getLength(int originalStart,
int originalEnd,
int startPosition)
originalStart - the first position of the source code fragmentoriginalEnd - the last position of the source code fragmentstartPosition - position in line of the first character (affects tabs calculation)public int toIndent(int indent,
boolean isWrapped)
indent - desired indentation (in positions, not in levels)isWrapped - whether indented element is wrappedpublic int traverse(int startIndex,
TokenTraverser traverser)
public int findFirstTokenInLine(int startIndex)
public int findFirstTokenInLine(int startIndex,
boolean includeWraps,
boolean includeForced)
public void addNLSAlignIndex(int index,
int align)
public int getNLSAlign(int index)
public void setHeaderEndIndex(int headerEndIndex)
public boolean isInHeader(int tokenIndex)
public void addDisableFormatTokenPair(Token formatOffTag, Token formatOnTag)
public void applyFormatOff()