GP-5622 - Decompiler - Fixed namespace highlight bug

This commit is contained in:
dragonmacher 2025-05-19 17:47:33 -04:00
parent 988660d862
commit 065581ad38

View file

@ -264,7 +264,11 @@ public class DecompilerPanel extends JPanel implements FieldMouseListener, Field
} }
// exclude tokens that users do not want to highlight // 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; return;
} }
@ -273,6 +277,28 @@ public class DecompilerPanel extends JPanel implements FieldMouseListener, Field
activeMiddleMouse = newMiddleMouse; 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, void addHighlighterHighlights(ClangDecompilerHighlighter highlighter,
Supplier<? extends Collection<ClangToken>> tokens, ColorProvider colorProvider) { Supplier<? extends Collection<ClangToken>> tokens, ColorProvider colorProvider) {
highlightController.addHighlighterHighlights(highlighter, tokens, colorProvider); highlightController.addHighlighterHighlights(highlighter, tokens, colorProvider);