Merge remote-tracking branch 'origin/GP-5662-dragonmacher-namespace-hl'

This commit is contained in:
Ryan Kurtz
2025-05-20 17:35:11 -04:00

View File

@@ -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);