Class TokenManager
java.lang.Object
org.aspectj.org.eclipse.jdt.internal.formatter.TokenManager
-
Constructor Summary
ConstructorsConstructorDescriptionTokenManager(List<Token> tokens, String source, DefaultCodeFormatterOptions options) TokenManager(List<Token> tokens, TokenManager parent) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDisableFormatTokenPair(Token formatOffTag, Token formatOnTag) voidaddNLSAlignIndex(int index, int align) charcharAt(int sourcePosition) intcountLineBreaksBetween(String text, int startPosition, int endPosition) intcountLineBreaksBetween(Token previous, Token current) intfindFirstTokenInLine(int startIndex) intfindFirstTokenInLine(int startIndex, boolean includeWraps, boolean includeIndents) intfindIndex(int positionInSource, int tokenType, boolean forward) intfindSourcePositionInLine(int position) intfirstIndexAfter(ASTNode node, int tokenType) intfirstIndexBefore(ASTNode node, int tokenType) intfirstIndexIn(ASTNode node, int tokenType) firstTokenAfter(ASTNode node, int tokenType) firstTokenBefore(ASTNode node, int tokenType) firstTokenIn(ASTNode node, int tokenType) get(int index) intgetLength(int originalStart, int originalEnd, int startPosition) Calculates the length of a source code fragment.intintgetNLSAlign(int index) intgetPositionInLine(int tokenIndex) intintvoidAdds given token at given index.booleanisFake(TypeDeclaration node) booleanisInHeader(int tokenIndex) booleaniterator()intlastIndexIn(ASTNode node, int tokenType) lastTokenIn(ASTNode node, int tokenType) voidremove(int tokenIndex) Removes the token at given index.voidsetHeaderEndIndex(int headerEndIndex) intsize()stream()inttoIndent(int indent, boolean isWrapped) toString(int tokenIndex) Gets token text with characters escaped as HTML entities where necessary.Gets token text with characters escaped as HTML entities where necessary.inttraverse(int startIndex, TokenTraverser traverser) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
TokenManager
-
TokenManager
-
-
Method Details
-
get
-
size
public int size()- Returns:
- total number of tokens
-
remove
public void remove(int tokenIndex) Removes the token at given index.Warning: never call this method after wrap policies have been added to tokens since wrap parent indexes may become invalid.
-
insert
Adds given token at given index.Warning: never call this method after wrap policies have been added to tokens since wrap parent indexes may become invalid.
-
toString
Gets token text with characters escaped as HTML entities where necessary.- Parameters:
tokenIndex- index of the token to get.
-
toString
-
toString
-
getSource
-
indexOf
-
charAt
public char charAt(int sourcePosition) -
getSourceLength
public int getSourceLength() -
findIndex
public int findIndex(int positionInSource, int tokenType, boolean forward) -
iterator
-
stream
-
firstIndexIn
-
firstTokenIn
-
lastIndexIn
-
lastTokenIn
-
firstIndexAfter
-
firstTokenAfter
-
firstIndexBefore
-
firstTokenBefore
-
countLineBreaksBetween
-
countLineBreaksBetween
-
getPositionInLine
public int getPositionInLine(int tokenIndex) -
findSourcePositionInLine
public int findSourcePositionInLine(int position) -
getLength
- Parameters:
token- the token to measurestartPosition- position in line of the first character (affects tabs calculation)- Returns:
- actual length of given token, considering tabs and escaping characters as HTML entities
-
getLength
public int getLength(int originalStart, int originalEnd, int startPosition) Calculates the length of a source code fragment.- Parameters:
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)- Returns:
- length, considering tabs and escaping characters as HTML entities
-
toIndent
public int toIndent(int indent, boolean isWrapped) - Parameters:
indent- desired indentation (in positions, not in levels)isWrapped- whether indented element is wrapped- Returns:
- actual indentation that can be achieved with current settings
-
traverse
-
findFirstTokenInLine
public int findFirstTokenInLine(int startIndex) -
findFirstTokenInLine
public int findFirstTokenInLine(int startIndex, boolean includeWraps, boolean includeIndents) -
isStringConcatenation
-
isFake
-
addNLSAlignIndex
public void addNLSAlignIndex(int index, int align) -
getNLSAlign
public int getNLSAlign(int index) -
setHeaderEndIndex
public void setHeaderEndIndex(int headerEndIndex) -
isInHeader
public boolean isInHeader(int tokenIndex) -
addDisableFormatTokenPair
-
getDisableFormatTokenPairs
-