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 NEW

        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 NEW

        public long getUpdateId()
      • getPrimaryHighlightedTokens NEW

        public TokenHighlights getPrimaryHighlightedTokens()
      • getSecondaryHighlightedTokens NEW

        public TokenHighlights getSecondaryHighlightedTokens()
      • clearPrimaryHighlights NEW

        public void clearPrimaryHighlights()
      • clearAllHighlights NEW

        public void clearAllHighlights()
      • togglePrimaryHighlights

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

        public boolean hasPrimaryHighlight​(ClangToken token)
      • hasSecondaryHighlight NEW

        public boolean hasSecondaryHighlight​(ClangToken token)
      • getSecondaryHighlightsByFunction NEW

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

        public void removeSecondaryHighlights​(Function f)
      • removeSecondaryHighlights NEW

        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 NEW

        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 NEW

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

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

        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)
      • addListener MODIFIED

        return type: boolean → void
        -boolean addListener(ghidra.app.decompiler.component.ClangHighlightListener listener)
        +void addListener(ghidra.app.decompiler.component.ClangHighlightListener listener)
        public void addListener​(ClangHighlightListener listener)
      • removeListener MODIFIED

        return type: boolean → void
        -boolean removeListener(ghidra.app.decompiler.component.ClangHighlightListener listener)
        +void removeListener(ghidra.app.decompiler.component.ClangHighlightListener listener)
        public void removeListener​(ClangHighlightListener listener)
      • notifyListeners

        protected void notifyListeners()