Klasse TokenManager

java.lang.Object
org.aspectj.org.eclipse.jdt.internal.formatter.TokenManager
Alle implementierten Schnittstellen:
Iterable<Token>

public class TokenManager extends Object implements Iterable<Token>
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.
  • Konstruktordetails

  • Methodendetails

    • get

      public Token get(int index)
    • 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

      public void insert(int tokenIndex, Token token)
      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

      public String toString(int tokenIndex)
      Gets token text with characters escaped as HTML entities where necessary.
      Parameter:
      tokenIndex - index of the token to get.
    • toString

      public String toString(Token token)
      Gets token text with characters escaped as HTML entities where necessary.
    • toString

      public String toString(ASTNode node)
      Gibt zurück:
      part of the source code defined by given node's position and length.
    • getSource

      public String getSource()
    • indexOf

      public int indexOf(Token token)
    • charAt

      public char charAt(int sourcePosition)
    • getSourceLength

      public int getSourceLength()
    • findIndex

      public int findIndex(int positionInSource, int tokenType, boolean forward)
    • iterator

      public Iterator<Token> iterator()
      Angegeben von:
      iterator in Schnittstelle Iterable<Token>
    • stream

      public Stream<Token> stream()
    • firstIndexIn

      public int firstIndexIn(ASTNode node, int tokenType)
    • firstTokenIn

      public Token firstTokenIn(ASTNode node, int tokenType)
    • lastIndexIn

      public int lastIndexIn(ASTNode node, int tokenType)
    • lastTokenIn

      public Token lastTokenIn(ASTNode node, int tokenType)
    • firstIndexAfter

      public int firstIndexAfter(ASTNode node, int tokenType)
    • firstTokenAfter

      public Token firstTokenAfter(ASTNode node, int tokenType)
    • firstIndexBefore

      public int firstIndexBefore(ASTNode node, int tokenType)
    • firstTokenBefore

      public Token firstTokenBefore(ASTNode node, int tokenType)
    • countLineBreaksBetween

      public int countLineBreaksBetween(Token previous, Token current)
    • countLineBreaksBetween

      public int countLineBreaksBetween(String text, int startPosition, int endPosition)
    • getPositionInLine

      public int getPositionInLine(int tokenIndex)
    • findSourcePositionInLine

      public int findSourcePositionInLine(int position)
    • getLength

      public int getLength(Token token, int startPosition)
      Parameter:
      token - the token to measure
      startPosition - 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 fragment
      originalEnd - the last position of the source code fragment
      startPosition - 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

      public int traverse(int startIndex, TokenTraverser traverser)
    • findFirstTokenInLine

      public int findFirstTokenInLine(int startIndex)
    • findFirstTokenInLine

      public int findFirstTokenInLine(int startIndex, boolean includeWraps, boolean includeIndents)
    • isStringConcatenation

      public boolean isStringConcatenation(InfixExpression node)
    • isFake

      public boolean isFake(TypeDeclaration node)
    • 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

      public void addDisableFormatTokenPair(Token formatOffTag, Token formatOnTag)
    • getDisableFormatTokenPairs

      public List<Token[]> getDisableFormatTokenPairs()