fix(semantic highlighting): use preprocessed source to highlight long identifiers#1049
Merged
rgrinberg merged 3 commits intoocaml:masterfrom Mar 23, 2023
Merged
fix(semantic highlighting): use preprocessed source to highlight long identifiers#1049rgrinberg merged 3 commits intoocaml:masterfrom
rgrinberg merged 3 commits intoocaml:masterfrom
Conversation
ulugbekna
approved these changes
Mar 21, 2023
Collaborator
ulugbekna
left a comment
There was a problem hiding this comment.
This makes sense.
Possibly, it also makes sense to ignore AST nodes, for which ghost_loc is true
Contributor
Author
|
Thank you for your feedback, in the latest commit I've added the modification you suggested that ignores semantic tokens at locations for which |
ulugbekna
approved these changes
Mar 22, 2023
Collaborator
|
Thanks heaps for investigation and the PR! :-) |
Contributor
Author
|
(don't hesitate to tell me if I have to perform other actions/commits, I'm not familiar with this workflow) |
Member
|
Thanks. Could you add a CHANGES entry? |
rgrinberg
added a commit
to rgrinberg/opam-repository
that referenced
this pull request
Jun 18, 2023
CHANGES: ## Fixes - Disable code lens by default. The support can be re-enabled by explicitly setting it in the configuration. (ocaml/ocaml-lsp#1134) - Fix initilization of `ocamlformat-rpc` in some edge cases when ocamlformat is initialized concurrently (ocaml/ocaml-lsp#1132) - Kill unnecessary `$ dune ocaml-merlin` with SIGTERM rather than SIGKILL (ocaml/ocaml-lsp#1124) - Refactor comment parsing to use `odoc-parser` and `cmarkit` instead of `octavius` and `omd` (ocaml/ocaml-lsp#1088) This allows users who migrated to omd 2.X to install ocaml-lsp-server in the same opam switch. We also slightly improved markdown generation support and fixed a couple in the generation of inline heading and module types. - Allow opening documents that were already open. This is a workaround for neovim's lsp client (ocaml/ocaml-lsp#1067) - Disable type annotation for functions (ocaml/ocaml-lsp#1054) - Respect codeActionLiteralSupport capability (ocaml/ocaml-lsp#1046) - Fix a document syncing issue when utf-16 is the position encoding (ocaml/ocaml-lsp#1004) - Disable "Type-annotate" action for code that is already annotated. ([ocaml/ocaml-lsp#1037](ocaml/ocaml-lsp#1037)), fixes [ocaml/ocaml-lsp#1036](ocaml/ocaml-lsp#1036) - Fix semantic highlighting of long identifiers when using preprocessors ([ocaml/ocaml-lsp#1049](ocaml/ocaml-lsp#1049), fixes [ocaml/ocaml-lsp#1034](ocaml/ocaml-lsp#1034)) - Fix the type of DocumentSelector in cram document registration (ocaml/ocaml-lsp#1068) - Accept the `--clientProcessId` command line argument. (ocaml/ocaml-lsp#1074) - Accept `--port` as a synonym for `--socket`. (ocaml/ocaml-lsp#1075) - Fix connecting to dune rpc on Windows. (ocaml/ocaml-lsp#1080) ## Features - Add "Remove type annotation" code action. (ocaml/ocaml-lsp#1039) - Support settings through `didChangeConfiguration` notification (ocaml/ocaml-lsp#1103) - Add "Extract local" and "Extract function" code actions. (ocaml/ocaml-lsp#870) - Depend directly on `merlin-lib` 4.9 (ocaml/ocaml-lsp#1070)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello,
This PR follows up and solves issue #1034 where usage of preprocessors breaks semantic highlighting.
After a few minutes of investigation with @thierry-martinez we saw that, in order to parse long identifiers (e.g.
Foo.Bar.x), ocaml-lsp reads again the source pre-preprocessor (raw_source) to semantic highlight the tokens in long identifiers (following PR #932).The problem is that locations in the AST do not correspond to the ones in
raw_source, but to the ones insource.I'm not sure this modification could cause issues, but this source is only used to retrieve the source code of long identifiers. All tests still pass.