-
Notifications
You must be signed in to change notification settings - Fork 363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Highlighting error for concatenated strings on multiple lines #1468
Comments
@jhoussay this is an known issue. Problem is the two step mechanism to parse the code. First step is the preprocessor doing the string concatenation (intermediate result) and in a second step the C++ parser is parsing and creating the syntax highlighting. Good ideas/solutions are welcome. |
Fix highlighting issue SonarOpenCommunity#1468 * `JoinStringsPreprocessor` replaces adjacent string Tokens with a single concatenated one * Previously the original Tokens were lost and proper highligting for multiline adjacent string literals were impossible * Solution: a) store original Tokens as Trivia b) if such trivia was found during highlighting: highlight preserved Tokens * ALSO minor refactoring and simplification of `JoinStringsPreprocessor`
Fix highlighting issue SonarOpenCommunity#1468 * `JoinStringsPreprocessor` replaces adjacent string Tokens with a single concatenated one * Previously the original Tokens were lost and proper highligting for multiline adjacent string literals were impossible * Solution: a) store original Tokens as Trivia b) if such trivia was found during highlighting: highlight preserved Tokens * ALSO minor refactoring and simplification of `JoinStringsPreprocessor`
Hi @guwirth, although my change (#1480) is consistent with the previous highlighting logic (comments and preprocessed preprocessor statements are also stored in Usually AST is not required for highlighting at all, only lexer is used. So maybe the long-term (?) solution is to split our parser or/and put highlighting between the lexer and later parsing steps (e.g. preprocessor etc)? |
closed with #1480 |
Description
For concatenated strings declared on multiple lines, an highlighting error occurs.
This is quite a minor issue as it does not prevent defect detection in the rest of the source file, it only generates invalid highlighting in the source file and pollutes sonar-scanner outputs with warnings.
Sample code to reproduce the problem
sonar-scanner warning
WARN: Highligthing error in file '.../Test.cpp' at line:7, column:19
Source visualization in SonarQube
As expected with the warning, highlighting fails on the second string declaration.
However, highlighting is also incorrect for the last two characters on the first string declaration.
The text was updated successfully, but these errors were encountered: