Class ClangHighlightController

  • Direct Known Subclasses:
    LocationClangHighlightController, NullClangHighlightController

    public abstract class ClangHighlightController
    extends java.lang.Object
    Class to handle highlights for a decompiled function.

    This class does not painting directly. Rather, this class tracks the currently highlighted tokens and then sets the highlight color on the token when it is highlighted and clears the highlight color when the highlight is removed.

    This class maintains the notion of 'primary' highlights and 'secondary' highlights. Primary highlights are considered transient and get cleared whenever the location changes. Secondary highlights will stay until they are manually cleared by a user action. Primary highlights happen when the user clicks around the Decompiler. They show state such as the current field, impact of a variable (via a slicing action), or related syntax (such as matching braces). Secondary highlights are triggered by the user to show all occurrences of a particular variable. Further, the user can apply multiple secondary highlights at the same time, with different colors for each highlight.

    • Field Detail

      • DEFAULT_HIGHLIGHT_COLOR

        public static java.awt.Color DEFAULT_HIGHLIGHT_COLOR
      • defaultHighlightColor

        protected java.awt.Color defaultHighlightColor
      • defaultParenColor

        protected java.awt.Color defaultParenColor
    • Constructor Detail

      • ClangHighlightController

        public ClangHighlightController()
    • Method Detail

      • getHighlightedText

        public java.lang.String getHighlightedText()
      • getUpdateId

        public long getUpdateId()
      • getPrimaryHighlightedTokens

        public TokenHighlights getPrimaryHighlightedTokens()
      • getSecondaryHighlightedTokens

        public TokenHighlights getSecondaryHighlightedTokens()
      • clearPrimaryHighlights

        public void clearPrimaryHighlights()
      • clearAllHighlights

        public void clearAllHighlights()
      • togglePrimaryHighlights

        public void togglePrimaryHighlights​(java.awt.Color hlColor,
                                            java.util.function.Supplier<java.util.List<ClangToken>> tokens)
      • hasPrimaryHighlight

        public boolean hasPrimaryHighlight​(ClangToken token)
      • hasSecondaryHighlight

        public boolean hasSecondaryHighlight​(ClangToken token)
      • getSecondaryHighlightsByFunction

        public java.util.Set<HighlightToken> getSecondaryHighlightsByFunction​(Function f)
      • removeSecondaryHighlights

        public void removeSecondaryHighlights​(Function f)
      • removeSecondaryHighlights

        public void removeSecondaryHighlights​(ClangToken token)
      • removeSecondaryHighlights

        public void removeSecondaryHighlights​(java.util.function.Supplier<? extends java.util.Collection<ClangToken>> tokens)
      • addSecondaryHighlights

        public void addSecondaryHighlights​(java.lang.String tokenText,
                                           java.util.function.Supplier<? extends java.util.Collection<ClangToken>> tokens)
      • addSecondaryHighlights

        public void addSecondaryHighlights​(java.util.function.Supplier<? extends java.util.Collection<ClangToken>> tokens,
                                           java.awt.Color hlColor)
      • addPrimaryHighlights

        public void addPrimaryHighlights​(java.util.function.Supplier<? extends java.util.Collection<ClangToken>> tokens,
                                         java.awt.Color hlColor)
      • addPrimaryHighlights

        public void addPrimaryHighlights​(ClangNode parentNode,
                                         ghidra.app.plugin.core.decompile.actions.TokenHighlightColorProvider colorProvider)
      • addPrimaryHighlights

        public void addPrimaryHighlights​(ClangNode parentNode,
                                         java.util.Set<PcodeOp> ops,
                                         java.awt.Color hlColor)
      • addPrimaryHighlight

        protected void addPrimaryHighlight​(ClangToken token,
                                           java.awt.Color highlightColor)
      • getCombinedColor

        public java.awt.Color getCombinedColor​(ClangToken t)
      • addPrimaryHighlightToTokensForParenthesis

        protected java.util.List<ClangToken> addPrimaryHighlightToTokensForParenthesis​(ClangSyntaxToken tok,
                                                                                       java.awt.Color highlightColor)
        If input token is a parenthesis, highlight all tokens between it and its match
        Parameters:
        tok - potential parenthesis token
        highlightColor - the highlight color
        Returns:
        a list of all tokens that were highlighted.
      • addHighlightBrace

        public void addHighlightBrace​(ClangSyntaxToken token,
                                      java.awt.Color highlightColor)
      • notifyListeners

        protected void notifyListeners()