mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-28 12:45:32 +08:00
GP-5622 - Decompiler - Fixed namespace highlight bug
This commit is contained in:
+27
-1
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user