- when the diagnostic has an explicit range, we prefer that
- if the diagnostic has a fixit, its RemoveRange is our next choice
- otherwise we try to expand the diagnostic location into a whole token. (inspired by VSCode, which does this client-side when given an empty range)
- if all else fails, we return the zero-width range as now. (clients react in different ways to this, highlighting a token or a char)
- this includes the off-by-one fix from D40860, and borrows heavily from it
Details
Details
- Reviewers
rwols hokein ilya-biryukov - Commits
- rG8111d3b89ccd: [clangd] Emit ranges for clangd diagnostics, and fix off-by-one positions
rL320555: [clangd] Emit ranges for clangd diagnostics, and fix off-by-one positions
rCTE320555: [clangd] Emit ranges for clangd diagnostics, and fix off-by-one positions
Diff Detail
Diff Detail
- Repository
- rCTE Clang Tools Extra
Event Timeline
Comment Actions
LGTM, you can go ahead and land this, I'll drop D40860. I'm happy we got to the bottom of this :)
test/clangd/diagnostics.test | ||
---|---|---|
10 | Maybe the current tests are enough. Do we want to add a test where the diagnostic location is at the end of the line? f() // ^ missing ";" f(); |
test/clangd/diagnostics.test | ||
---|---|---|
10 | Good point - the current tests only incidentally cover much of the diagnostics functionality. |
Maybe the current tests are enough. Do we want to add a test where the diagnostic location is at the end of the line?