Class ClangHighlightController
- java.lang.Object
-
- ghidra.app.decompiler.component.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 Summary
Fields Modifier and Type Field Description static java.awt.Color
DEFAULT_HIGHLIGHT_COLOR
protected java.awt.Color
defaultHighlightColor
protected java.awt.Color
defaultParenColor
-
Constructor Summary
Constructors Constructor Description ClangHighlightController()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addHighlightBrace(ClangSyntaxToken token, java.awt.Color highlightColor)
void
addListener(ClangHighlightListener listener)
protected void
addPrimaryHighlight(ClangToken token, java.awt.Color highlightColor)
void
addPrimaryHighlights(ClangNode parentNode, ghidra.app.plugin.core.decompile.actions.TokenHighlightColorProvider colorProvider)
void
addPrimaryHighlights(ClangNode parentNode, java.util.Set<PcodeOp> ops, java.awt.Color hlColor)
void
addPrimaryHighlights(java.util.function.Supplier<? extends java.util.Collection<ClangToken>> tokens, java.awt.Color hlColor)
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 matchvoid
addSecondaryHighlights(java.lang.String tokenText, java.util.function.Supplier<? extends java.util.Collection<ClangToken>> tokens)
void
addSecondaryHighlights(java.util.function.Supplier<? extends java.util.Collection<ClangToken>> tokens, java.awt.Color hlColor)
void
clearAllHighlights()
void
clearPrimaryHighlights()
static ClangHighlightController
dummyIfNull(ClangHighlightController c)
abstract void
fieldLocationChanged(FieldLocation location, Field field, EventTrigger trigger)
java.awt.Color
getCombinedColor(ClangToken t)
java.lang.String
getHighlightedText()
TokenHighlights
getPrimaryHighlightedTokens()
TokenHighlightColors
getSecondaryHighlightColors()
TokenHighlights
getSecondaryHighlightedTokens()
java.util.Set<HighlightToken>
getSecondaryHighlightsByFunction(Function f)
long
getUpdateId()
boolean
hasPrimaryHighlight(ClangToken token)
boolean
hasSecondaryHighlight(ClangToken token)
protected void
notifyListeners()
void
removeListener(ClangHighlightListener listener)
void
removeSecondaryHighlights(ClangToken token)
void
removeSecondaryHighlights(Function f)
void
removeSecondaryHighlights(java.util.function.Supplier<? extends java.util.Collection<ClangToken>> tokens)
void
togglePrimaryHighlights(java.awt.Color hlColor, java.util.function.Supplier<java.util.List<ClangToken>> tokens)
-
-
-
Method Detail
-
dummyIfNull
public static ClangHighlightController dummyIfNull(ClangHighlightController c)
-
fieldLocationChanged
public abstract void fieldLocationChanged(FieldLocation location, Field field, EventTrigger trigger)
-
getHighlightedText
public java.lang.String getHighlightedText()
-
getUpdateId
public long getUpdateId()
-
getSecondaryHighlightColors
public TokenHighlightColors getSecondaryHighlightColors()
-
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 tokenhighlightColor
- the highlight color- Returns:
- a list of all tokens that were highlighted.
-
addHighlightBrace
public void addHighlightBrace(ClangSyntaxToken token, java.awt.Color highlightColor)
-
addListener
public void addListener(ClangHighlightListener listener)
-
removeListener
public void removeListener(ClangHighlightListener listener)
-
notifyListeners
protected void notifyListeners()
-
-