-
Notifications
You must be signed in to change notification settings - Fork 144
Make code-lens for toplevel let binding configurable
#1567
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
Merged
voodoos
merged 7 commits into
ocaml:master
from
Tim-ats-d:configurable-internal-code-lens
Oct 23, 2025
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
cfe0f89
Add a setting to enable CodeLens only for toplevel let binding.
Tim-ats-d 0d47e2a
Add tests.
Tim-ats-d d326ce0
Use JSON to compare code lens test output.
Tim-ats-d fd4dda3
Take Xavier's comments into account.
Tim-ats-d 28c7a8f
Fix config infos.
Tim-ats-d 4ad23cd
Better definition of option semantics.
Tim-ats-d 5ef8c8a
Update changes.md.
Tim-ats-d File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,9 @@ | ||
| # Unreleased | ||
|
|
||
| ## Fixes | ||
|
|
||
| - Make `code-lens` for toplevel let binding configurable (#1567) | ||
|
|
||
| # 1.24.0 | ||
|
|
||
| ## Features | ||
|
|
||
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| open Test.Import | ||
|
|
||
| let change_config client params = Client.notification client (ChangeConfiguration params) | ||
|
|
||
| let codelens client textDocument = | ||
| Client.request | ||
| client | ||
| (TextDocumentCodeLens | ||
| { textDocument; workDoneToken = None; partialResultToken = None }) | ||
| ;; | ||
|
|
||
| let json_of_codelens cs = `List (List.map ~f:CodeLens.yojson_of_t cs) | ||
|
|
||
| let%expect_test "enable only codelens for toplevel let binding 1" = | ||
| let source = | ||
| {ocaml| | ||
| let toplevel = "Hello" | ||
|
|
||
| let func x = x | ||
|
|
||
| let f x = | ||
| let y = 10 in | ||
| let z = 3 in | ||
| x + y + z | ||
| |ocaml} | ||
| in | ||
| let req client = | ||
| let text_document = TextDocumentIdentifier.create ~uri:Helpers.uri in | ||
| let* () = | ||
| change_config | ||
| client | ||
| (DidChangeConfigurationParams.create | ||
| ~settings:(`Assoc [ "codelens", `Assoc [ "only_toplevel", `Bool true ] ])) | ||
| in | ||
| let* resp_codelens_toplevel = codelens client text_document in | ||
| Test.print_result (json_of_codelens resp_codelens_toplevel); | ||
| Fiber.return () | ||
| in | ||
| Helpers.test source req; | ||
| [%expect {| | ||
| [ | ||
| { | ||
| "command": { "command": "", "title": "int -> int" }, | ||
| "range": { | ||
| "end": { "character": 11, "line": 8 }, | ||
| "start": { "character": 0, "line": 5 } | ||
| } | ||
| }, | ||
| { | ||
| "command": { "command": "", "title": "'a -> 'a" }, | ||
| "range": { | ||
| "end": { "character": 14, "line": 3 }, | ||
| "start": { "character": 0, "line": 3 } | ||
| } | ||
| }, | ||
| { | ||
| "command": { "command": "", "title": "string" }, | ||
| "range": { | ||
| "end": { "character": 22, "line": 1 }, | ||
| "start": { "character": 0, "line": 1 } | ||
| } | ||
| } | ||
| ] | ||
| |}] | ||
| ;; | ||
|
|
||
| let%expect_test "enable only codelens for toplevel let binding 2" = | ||
| let source = | ||
| {ocaml| | ||
| let x = | ||
| let y = 10 in | ||
| "Hello" | ||
|
|
||
| let () = () | ||
| |ocaml} | ||
| in | ||
| let req client = | ||
| let text_document = TextDocumentIdentifier.create ~uri:Helpers.uri in | ||
| let* () = | ||
| change_config | ||
| client | ||
| (DidChangeConfigurationParams.create | ||
| ~settings:(`Assoc [ "codelens", `Assoc [ "only_toplevel", `Bool true ] ])) | ||
| in | ||
| let* resp_codelens_toplevel = codelens client text_document in | ||
| Test.print_result (json_of_codelens resp_codelens_toplevel); | ||
| Fiber.return () | ||
| in | ||
| Helpers.test source req; | ||
| [%expect {| | ||
| [ | ||
| { | ||
| "command": { "command": "", "title": "string" }, | ||
| "range": { | ||
| "end": { "character": 9, "line": 3 }, | ||
| "start": { "character": 0, "line": 1 } | ||
| } | ||
| } | ||
| ] | ||
| |}] | ||
| ;; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,6 +44,7 @@ | |
| action_inline | ||
| action_mark_remove | ||
| code_actions | ||
| code_lens | ||
| completion | ||
| completions | ||
| construct | ||
|
|
||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.