Klasse TokenManager
java.lang.Object
org.aspectj.org.eclipse.jdt.internal.formatter.TokenManager
A helper class that can be used to easily access source code and find tokens on any position.
It also has some other methods that are useful on multiple stages of formatting.
-
Konstruktorübersicht
KonstruktorenKonstruktorBeschreibungTokenManager(List<Token> tokens, String source, DefaultCodeFormatterOptions options) TokenManager(List<Token> tokens, TokenManager parent) -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoidaddDisableFormatTokenPair(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) Von Klasse geerbte Methoden java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitVon Schnittstelle geerbte Methoden java.lang.Iterable
forEach, spliterator
-
Konstruktordetails
-
TokenManager
-
TokenManager
-
-
Methodendetails
-
get
-
size
public int size()- Gibt zurück:
- 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.- Parameter:
tokenIndex- index of the token to get.
-
toString
Gets token text with characters escaped as HTML entities where necessary. -
toString
- Gibt zurück:
- part of the source code defined by given node's position and length.
-
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
- Parameter:
token- the token to measurestartPosition- position in line of the first character (affects tabs calculation)- Gibt zurück:
- 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.- Parameter:
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)- Gibt zurück:
- length, considering tabs and escaping characters as HTML entities
-
toIndent
public int toIndent(int indent, boolean isWrapped) - Parameter:
indent- desired indentation (in positions, not in levels)isWrapped- whether indented element is wrapped- Gibt zurück:
- 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
-