-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1364 from ocaml/locate-state-reset
[locate] reset state from entry points
- Loading branch information
Showing
6 changed files
with
104 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains 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,33 @@ | ||
A test showing that we manage to get docstrings even when they are not kept as | ||
attributes on the AST. | ||
|
||
$ cat >test.ml <<EOF | ||
> let foo x y = (** incorrect doc for foo *) | ||
> x + y | ||
> | ||
> let bar = foo | ||
> EOF | ||
|
||
$ $MERLIN single document -position 4:13 -filename test.ml < test.ml | ||
{ | ||
"class": "return", | ||
"value": "incorrect doc for foo", | ||
"notifications": [] | ||
} | ||
|
||
And that it also works outside of the current buffer: | ||
|
||
$ $OCAMLC -c -bin-annot -w +50 test.ml | ||
File "test.ml", line 1, characters 14-42: | ||
1 | let foo x y = (** incorrect doc for foo *) | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
Warning 50 [unexpected-docstring]: unattached documentation comment (ignored) | ||
|
||
$ $MERLIN single document -position 1:18 -filename outside.ml << EOF | ||
> let bar = Test.foo | ||
> EOF | ||
{ | ||
"class": "return", | ||
"value": "incorrect doc for foo", | ||
"notifications": [] | ||
} |
65 changes: 65 additions & 0 deletions
65
tests/test-dirs/server-tests/locate-state/reset-file-switching.t
This file contains 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,65 @@ | ||
Reproduce [ocaml-lsp #344](https://github.com/ocaml/ocaml-lsp/issues/344): a symbol's | ||
documentation is some other random documentation from a library that was last pulled for | ||
completion. See the issue for details. The space is necessary for the position of | ||
documentation to be fetch-able. | ||
|
||
$ cat >lib_doc.ml <<EOF | ||
> | ||
> | ||
> | ||
> | ||
> | ||
> | ||
> | ||
> | ||
> | ||
> | ||
> | ||
> | ||
> | ||
> | ||
> | ||
> | ||
> | ||
> | ||
> | ||
> | ||
> | ||
> | ||
> let k = () | ||
> let m = List.map | ||
> EOF | ||
we need merlin to keep state between requests, so using server | ||
$ $MERLIN server stop-server | ||
see that there is no doc for k | ||
$ $MERLIN server document -position 23:5 < lib_doc.ml | jq '.value' | ||
"No documentation available" | ||
we trigger the bug | ||
$ $MERLIN server document -position 24:15 -filename lib_doc < lib_doc.ml | ||
{ | ||
"class": "return", | ||
"value": " [map f [a1; ...; an]] applies function [f] to [a1, ..., an], | ||
and builds the list [[f a1; ...; f an]] | ||
with the results returned by [f]. Not tail-recursive. | ||
", | ||
"notifications": [] | ||
} | ||
random documentation is fetched for the same `document` request as before | ||
$ $MERLIN server document -position 23:5 < lib_doc.ml | ||
{ | ||
"class": "return", | ||
"value": "No documentation available", | ||
"notifications": [] | ||
} | ||
stop server | ||
$ $MERLIN server stop-server |