mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-06-01 00:45:43 +08:00
GP-5414 - Decompiler - Updated highlighting to ignore syntax tokens
This commit is contained in:
+5
@@ -262,6 +262,11 @@ public class DecompilerPanel extends JPanel implements FieldMouseListener, Field
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// exclude tokens that users do not want to highlight
|
||||||
|
if (token instanceof ClangSyntaxToken || token instanceof ClangOpToken) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ActiveMiddleMouse newMiddleMouse = new ActiveMiddleMouse(token.getText());
|
ActiveMiddleMouse newMiddleMouse = new ActiveMiddleMouse(token.getText());
|
||||||
newMiddleMouse.apply();
|
newMiddleMouse.apply();
|
||||||
activeMiddleMouse = newMiddleMouse;
|
activeMiddleMouse = newMiddleMouse;
|
||||||
|
|||||||
+15
-3
@@ -20,8 +20,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import docking.widgets.EventTrigger;
|
import docking.widgets.EventTrigger;
|
||||||
import docking.widgets.fieldpanel.field.Field;
|
import docking.widgets.fieldpanel.field.Field;
|
||||||
import docking.widgets.fieldpanel.support.FieldLocation;
|
import docking.widgets.fieldpanel.support.FieldLocation;
|
||||||
import ghidra.app.decompiler.ClangSyntaxToken;
|
import ghidra.app.decompiler.*;
|
||||||
import ghidra.app.decompiler.ClangToken;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to handle location based highlights for a decompiled function.
|
* Class to handle location based highlights for a decompiled function.
|
||||||
@@ -47,10 +46,23 @@ public class LocationClangHighlightController extends ClangHighlightController {
|
|||||||
return; // do not highlight whitespace
|
return; // do not highlight whitespace
|
||||||
}
|
}
|
||||||
|
|
||||||
addPrimaryHighlight(tok, defaultHighlightColor);
|
if (tok instanceof ClangOpToken) { // e.g., '='
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (tok instanceof ClangSyntaxToken) {
|
if (tok instanceof ClangSyntaxToken) {
|
||||||
|
|
||||||
|
int type = tok.getSyntaxType();
|
||||||
|
if (type == ClangToken.GLOBAL_COLOR) {
|
||||||
|
// namespaces can fit this case sometimes
|
||||||
|
addPrimaryHighlight(tok, defaultHighlightColor);
|
||||||
|
}
|
||||||
|
|
||||||
addPrimaryHighlightToTokensForParenthesis((ClangSyntaxToken) tok, defaultParenColor);
|
addPrimaryHighlightToTokensForParenthesis((ClangSyntaxToken) tok, defaultParenColor);
|
||||||
addPrimaryHighlightToTokensForBrace((ClangSyntaxToken) tok, defaultParenColor);
|
addPrimaryHighlightToTokensForBrace((ClangSyntaxToken) tok, defaultParenColor);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
addPrimaryHighlight(tok, defaultHighlightColor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user