Package ghidra.app.decompiler

# Class ClangToken

java.lang.Object
ghidra.app.decompiler.ClangToken

All Implemented Interfaces:
  `ClangNode`

Direct Known Subclasses:
  `ClangBreak`, `ClangCaseToken`, `ClangCommentToken`, `ClangFieldToken`, `ClangFuncNameToken`, `ClangLabelToken`, `ClangOpToken`, `ClangSyntaxToken`, `ClangTypeToken`, `ClangVariableToken`

public class ClangToken extends Object implements ClangNode
Class representing a source code language token. A token has numerous display attributes and may link to the data-flow analysis

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `COMMENT_COLOR`
  `static final int`
  `CONST_COLOR`
  `static final int`
  `DEFAULT_COLOR`
  `static final int`
  `ERROR_COLOR`
  `static final int`
  `FUNCTION_COLOR`
  `static final int`
  `GLOBAL_COLOR`
  `static final int`
  `KEYWORD_COLOR`
  `static final int`
  `MAX_COLOR`
  `static final int`
  `PARAMETER_COLOR`
  `static final int`
  `SPECIAL_COLOR`
  `static final int`
  `TYPE_COLOR`
  `static final int`
  `VARIABLE_COLOR`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ClangToken(ClangNode par)`
  `ClangToken(ClangNode par, String txt)`
  `ClangToken(ClangNode par, String txt, int color)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static ClangToken`
  `buildSpacer(ClangNode par, int indent, String indentStr)`
  Add a spacer token to the given text grouping
  `static ClangToken`
  `buildToken(int node, ClangNode par, Decoder decoder, PcodeFactory pfactory)`
  Decode one specialized token from the current position in an encoded stream.
  `ClangNode`
  `Child(int i)`
  Get the i-th child grouping
  `void`
  `decode(Decoder decoder, PcodeFactory pfactory)`
  Decode this token from the current position in an encoded stream
  `void`
  `flatten(List<ClangNode> list)`
  Flatten this text into a list of tokens (see ClangToken)
  `ClangFunction`
  `getClangFunction()`
  Get the text representing an entire function of which this is part.
  `Color`
  `getHighlight()`
  Get the background highlight color used to render this token, or null if not highlighted
  `HighSymbol`
  `getHighSymbol(HighFunction highFunction)`
  Get the symbol associated with this token or null otherwise.
  `HighVariable`
  `getHighVariable()`
  Get the high-level variable associate with this token or null otherwise
  `ClangLine`
  `getLineParent()`
  Get the element representing an entire line of text that contains this element
  `Address`
  `getMaxAddress()`
  Get the biggest Program address associated with the code that this text represents
  `Address`
  `getMinAddress()`
  Get the smallest Program address associated with the code that this text represents
  `PcodeOp`
  `getPcodeOp()`
  Many tokens directly represent a pcode operator in the data-flow
  `Scalar`
  `getScalar()`
  If the token represents an underlying integer constant, return the constant as a Scalar.
  `int`
  `getSyntaxType()`
  Get the "syntax" type (color) associated with this token (keyword, type, etc)
  `String`
  `getText()`
  `Varnode`
  `getVarnode()`
  Many tokens directly represent a variable in the data-flow
  `boolean`
  `isMatchingToken()`
  `boolean`
  `isVariableRef()`
  `Iterator<ClangToken>`
  `iterator(boolean forward)`
  Get an iterator over tokens starting with this ClangToken.
  `int`
  `numChildren()`
  Return the number of immediate groupings this text breaks up into
  `ClangNode`
  `Parent()`
  Get the immediate grouping (parent) containing this text element.
  `void`
  `setHighlight(Color val)`
  Set a highlighting background color for all text elements
  `void`
  `setLineParent(ClangLine line)`
  Set (change) the line which this text element part of.
  `void`
  `setMatchingToken(boolean matchingToken)`
  Set whether or not additional "matching" highlighting is applied to this token.
  `String`
  `toString()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### KEYWORD_COLOR

    public static final int KEYWORD_COLOR
    See Also:
      - Constant Field Values

  - ### COMMENT_COLOR

    public static final int COMMENT_COLOR
    See Also:
      - Constant Field Values

  - ### TYPE_COLOR

    public static final int TYPE_COLOR
    See Also:
      - Constant Field Values

  - ### FUNCTION_COLOR

    public static final int FUNCTION_COLOR
    See Also:
      - Constant Field Values

  - ### VARIABLE_COLOR

    public static final int VARIABLE_COLOR
    See Also:
      - Constant Field Values

  - ### CONST_COLOR

    public static final int CONST_COLOR
    See Also:
      - Constant Field Values

  - ### PARAMETER_COLOR

    public static final int PARAMETER_COLOR
    See Also:
      - Constant Field Values

  - ### GLOBAL_COLOR

    public static final int GLOBAL_COLOR
    See Also:
      - Constant Field Values

  - ### DEFAULT_COLOR

    public static final int DEFAULT_COLOR
    See Also:
      - Constant Field Values

  - ### ERROR_COLOR

    public static final int ERROR_COLOR
    See Also:
      - Constant Field Values

  - ### SPECIAL_COLOR

    public static final int SPECIAL_COLOR
    See Also:
      - Constant Field Values

  - ### MAX_COLOR

    public static final int MAX_COLOR
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### ClangToken

    public ClangToken(ClangNode par)

  - ### ClangToken

    public ClangToken(ClangNode par, String txt)

  - ### ClangToken

    public ClangToken(ClangNode par, String txt, int color)

- ## Method Details

  - ### Parent

    public ClangNode Parent()
    Description copied from interface: `ClangNode`
    Get the immediate grouping (parent) containing this text element. If this is a complete document, null is returned.
    Specified by:
      `Parent` in interface `ClangNode`
    Returns:
      the parent grouping or null

  - ### getLineParent

    public ClangLine getLineParent()
    Get the element representing an entire line of text that contains this element
    Returns:
      the containing ClangLine

  - ### setLineParent

    public void setLineParent(ClangLine line)
    Set (change) the line which this text element part of.
    Parameters:
      `line` - is the new ClangLine

  - ### getMinAddress

    public Address getMinAddress()
    Description copied from interface: `ClangNode`
    Get the smallest Program address associated with the code that this text represents
    Specified by:
      `getMinAddress` in interface `ClangNode`
    Returns:
      the smallest Address

  - ### getMaxAddress

    public Address getMaxAddress()
    Description copied from interface: `ClangNode`
    Get the biggest Program address associated with the code that this text represents
    Specified by:
      `getMaxAddress` in interface `ClangNode`
    Returns:
      the biggest Address

  - ### numChildren

    public int numChildren()
    Description copied from interface: `ClangNode`
    Return the number of immediate groupings this text breaks up into
    Specified by:
      `numChildren` in interface `ClangNode`
    Returns:
      the number of child groupings

  - ### Child

    public ClangNode Child(int i)
    Description copied from interface: `ClangNode`
    Get the i-th child grouping
    Specified by:
      `Child` in interface `ClangNode`
    Parameters:
      `i` - is the index selecting the grouping
    Returns:
      the selected grouping

  - ### getClangFunction

    public ClangFunction getClangFunction()
    Description copied from interface: `ClangNode`
    Get the text representing an entire function of which this is part.
    Specified by:
      `getClangFunction` in interface `ClangNode`
    Returns:
      text for the whole function

  - ### setHighlight

    public void setHighlight(Color val)
    Description copied from interface: `ClangNode`
    Set a highlighting background color for all text elements
    Specified by:
      `setHighlight` in interface `ClangNode`
    Parameters:
      `val` - is the color to set

  - ### getHighlight

    public Color getHighlight()
    Get the background highlight color used to render this token, or null if not highlighted
    Returns:
      the Color or null

  - ### setMatchingToken

    public void setMatchingToken(boolean matchingToken)
    Set whether or not additional "matching" highlighting is applied to this token. Currently this means a bounding box is drawn around the token.
    Parameters:
      `matchingToken` - is true to enable highlighting, false to disable

  - ### isMatchingToken

    public boolean isMatchingToken()
    Returns:
      true if this token should be displayed with "matching" highlighting

  - ### isVariableRef

    public boolean isVariableRef()
    Returns:
      true if this token represents a variable (in source code)

  - ### getSyntaxType

    public int getSyntaxType()
    Get the "syntax" type (color) associated with this token (keyword, type, etc)
    Returns:
      the color code

  - ### getText

    public String getText()
    Returns:
      this token's display text as a string

  - ### decode

    public void decode(Decoder decoder, PcodeFactory pfactory) throws DecoderException
    Decode this token from the current position in an encoded stream
    Parameters:
      `decoder` - is the decoder for the stream
      `pfactory` - is used to look up p-code objects associated with the token
    Throws:
      `DecoderException` - for problems decoding the stream

  - ### flatten

    public void flatten(List<ClangNode> list)
    Description copied from interface: `ClangNode`
    Flatten this text into a list of tokens (see ClangToken)
    Specified by:
      `flatten` in interface `ClangNode`
    Parameters:
      `list` - is the container that will contain the tokens

  - ### buildToken

    public static ClangToken buildToken(int node, ClangNode par, Decoder decoder, PcodeFactory pfactory) throws DecoderException
    Decode one specialized token from the current position in an encoded stream. This serves as a factory for allocating the various objects derived from ClangToken
    Parameters:
      `node` - is the particular token type (already) decoded from the stream
      `par` - is the text grouping which will contain the token
      `decoder` - is the decoder for the stream
      `pfactory` - is used to look up p-code objects associated with tokens
    Returns:
      the new ClangToken
    Throws:
      `DecoderException` - for problems decoding the stream

  - ### buildSpacer

    public static ClangToken buildSpacer(ClangNode par, int indent, String indentStr)
    Add a spacer token to the given text grouping
    Parameters:
      `par` - is the text grouping
      `indent` - is the number of levels to indent
      `indentStr` - is a string representing containg the number of spaces in one indent level
    Returns:
      the new spacer token

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### getHighVariable

    public HighVariable getHighVariable()
    Get the high-level variable associate with this token or null otherwise
    Returns:
      HighVariable

  - ### getHighSymbol

    public HighSymbol getHighSymbol(HighFunction highFunction)
    Get the symbol associated with this token or null otherwise. This token may be directly associated with the symbol or a reference, in which case the symbol is looked up in the containing HighFunction
    Parameters:
      `highFunction` - is the function
    Returns:
      HighSymbol

  - ### getVarnode

    public Varnode getVarnode()
    Many tokens directly represent a variable in the data-flow
    Returns:
      the variable (Varnode) associated with this token or null

  - ### getPcodeOp

    public PcodeOp getPcodeOp()
    Many tokens directly represent a pcode operator in the data-flow
    Returns:
      the operation (PcodeOp) associated with this token or null

  - ### getScalar

    public Scalar getScalar()
    If the token represents an underlying integer constant, return the constant as a Scalar. Otherwise return null.
    Returns:
      the Scalar that the token represents or null

  - ### iterator

    public Iterator<ClangToken> iterator(boolean forward)
    Get an iterator over tokens starting with this ClangToken. Tokens are returned in normal display order (forward=true) or in the reverse of normal display order (forward=false)
    Parameters:
      `forward` - is true for forward iterator, false for a backward iterator
    Returns:
      the Iterator object