diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/DecompilerPanel.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/DecompilerPanel.java index 9f8101bc2a..7fd06ccdc2 100644 --- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/DecompilerPanel.java +++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/DecompilerPanel.java @@ -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> tokens, ColorProvider colorProvider) { highlightController.addHighlighterHighlights(highlighter, tokens, colorProvider);