mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 17:59:46 +02:00
GP-5622 - Decompiler - Fixed namespace highlight bug
This commit is contained in:
parent
988660d862
commit
065581ad38
1 changed files with 27 additions and 1 deletions
|
@ -264,7 +264,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) {
|
||||
if (token instanceof ClangOpToken) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (token instanceof ClangSyntaxToken syntaxToken && !isNamespace(syntaxToken)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -273,6 +277,28 @@ public class DecompilerPanel extends JPanel implements FieldMouseListener, Field
|
|||
activeMiddleMouse = newMiddleMouse;
|
||||
}
|
||||
|
||||
private boolean isNamespace(ClangSyntaxToken token) {
|
||||
|
||||
String text = token.getText();
|
||||
if (text.length() <= 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// see if we have a '::' token trailing this token
|
||||
ClangLine line = token.getLineParent();
|
||||
int index = line.indexOfToken(token);
|
||||
for (int i = index + 1; i < line.getNumTokens(); i++) {
|
||||
ClangToken nextToken = line.getToken(i);
|
||||
String nextText = nextToken.getText();
|
||||
if (nextText.isBlank()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return nextText.equals("::");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void addHighlighterHighlights(ClangDecompilerHighlighter highlighter,
|
||||
Supplier<? extends Collection<ClangToken>> tokens, ColorProvider colorProvider) {
|
||||
highlightController.addHighlighterHighlights(highlighter, tokens, colorProvider);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue