diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cab5f777..d3979e4e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ - Inlay Hints (experimetal). `rescript.settings.inlayHints.enable: true`. Turned off by default. https://github.com/rescript-lang/rescript-vscode/pull/453 - Code Lenses for functions (experimetal). `rescript.settings.codeLens: true`. Turned off by default. https://github.com/rescript-lang/rescript-vscode/pull/513 - Markdown code blocks tagged as `rescript` now get basic syntax highlighting. https://github.com/rescript-lang/rescript-vscode/pull/97 +- Hover support for doc comments on v10 compiler `/** this is a doc comment */` #### :bug: Bug Fix diff --git a/analysis/src/ProcessAttributes.ml b/analysis/src/ProcessAttributes.ml index 2b2f13c05..9a2272ebc 100644 --- a/analysis/src/ProcessAttributes.ml +++ b/analysis/src/ProcessAttributes.ml @@ -5,7 +5,7 @@ let rec findDocAttribute attributes = let open Parsetree in match attributes with | [] -> None - | ( {Asttypes.txt = "ocaml.doc"}, + | ( {Asttypes.txt = "ocaml.doc" | "ns.doc"}, PStr [ { diff --git a/analysis/tests/src/Hover.res b/analysis/tests/src/Hover.res index 2da1a17fd..be0fd1be9 100644 --- a/analysis/tests/src/Hover.res +++ b/analysis/tests/src/Hover.res @@ -83,10 +83,18 @@ module Comp = { module Comp1 = Comp -let _ =
+let _ = + +
+
+ // ^hov -let _ =
+let _ = + +
+
+ // ^hov type r<'a> = {i: 'a, f: float} @@ -130,3 +138,20 @@ let arity0d = (. ()) => { let f = () => 3 f } + +/**doc comment 1*/ +let docComment1 = 12 +// ^hov + +/** doc comment 2 */ +let docComment2 = 12 +// ^hov + +module ModWithDocComment = { + /*** module level doc comment 1 */ + + /** doc comment for x */ + let x = 44 + + /*** module level doc comment 2 */ +} diff --git a/analysis/tests/src/expected/Hover.res.txt b/analysis/tests/src/expected/Hover.res.txt index f1b882d13..91db38a50 100644 --- a/analysis/tests/src/expected/Hover.res.txt +++ b/analysis/tests/src/expected/Hover.res.txt @@ -56,45 +56,51 @@ Hover src/Hover.res 72:7 Hover src/Hover.res 75:7 {"contents": "```rescript\nmodule A = {\n let x: int\n}\n```"} -Hover src/Hover.res 85:10 -getLocItem #9: heuristic for JSX variadic, e.g. {x} {y} -heuristic for: [React.null, makeProps, make, createElementVariadic], give the loc of `make` -n1:null n2:makeProps n3:make n4:createElementVariadic -{"contents": "```rescript\nReact.component<{\"children\": React.element}>\n```\n\n```rescript\ntype component<'props> = componentLike<'props, element>\n```"} - -Hover src/Hover.res 88:10 -getLocItem #9: heuristic for JSX variadic, e.g. {x} {y} -heuristic for: [React.null, makeProps, make, createElementVariadic], give the loc of `make` -n1:null n2:makeProps n3:make n4:createElementVariadic -{"contents": "```rescript\nReact.component<{\"children\": React.element}>\n```\n\n```rescript\ntype component<'props> = componentLike<'props, element>\n```"} - -Hover src/Hover.res 93:25 +Hover src/Hover.res 89:10 +Nothing at that position. Now trying to use completion. +posCursor:[89:10] posNoWhite:[89:8] Found expr:[86:3->89:9] +JSX 86:7] > _children:86:7 +null + +Hover src/Hover.res 96:10 +Nothing at that position. Now trying to use completion. +posCursor:[96:10] posNoWhite:[96:9] Found expr:[93:3->96:10] +JSX 93:8] > _children:93:8 +null + +Hover src/Hover.res 101:25 {"contents": "```rescript\nfloat\n```"} -Hover src/Hover.res 96:21 +Hover src/Hover.res 104:21 {"contents": "```rescript\nint\n```"} -Hover src/Hover.res 106:16 +Hover src/Hover.res 114:16 {"contents": "```rescript\nAA.cond<[< #str(string)]> => AA.cond<[< #str(string)]>\n```"} -Hover src/Hover.res 109:25 +Hover src/Hover.res 117:25 {"contents": "```rescript\nAA.cond<[< #str(string)]> => AA.cond<[< #str(string)]>\n```"} -Hover src/Hover.res 112:3 +Hover src/Hover.res 120:3 Nothing at that position. Now trying to use completion. -Attribute id:live:[112:0->112:5] label:live +Attribute id:live:[120:0->120:5] label:live Completable: Cdecorator(live) {"contents": "The `@live` decorator is for reanalyze, a static analysis tool for ReScript that can do dead code analysis.\n\n`@live` tells the dead code analysis that the value should be considered live, even though it might appear to be dead. This is typically used in case of FFI where there are indirect ways to access values. It can be added to everything that could otherwise be considered unused by the dead code analysis - values, functions, arguments, records, individual record fields, and so on.\n\n[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#live-decorator).\n\nHint: Did you know you can run an interactive code analysis in your project by running the command `> ReScript: Start Code Analyzer`? Try it!"} -Hover src/Hover.res 115:4 +Hover src/Hover.res 123:4 {"contents": "```rescript\n(. ()) => unit => int\n```"} -Hover src/Hover.res 121:4 +Hover src/Hover.res 129:4 {"contents": "```rescript\n(. ()) => (. ()) => int\n```"} -Hover src/Hover.res 124:4 +Hover src/Hover.res 132:4 {"contents": "```rescript\n(. unit, unit) => int\n```"} -Hover src/Hover.res 127:5 +Hover src/Hover.res 135:5 {"contents": "```rescript\n(. ()) => unit => int\n```"} +Hover src/Hover.res 142:9 +{"contents": "```rescript\nint\n```\n\ndoc comment 1"} + +Hover src/Hover.res 146:6 +{"contents": "```rescript\nint\n```\n\n doc comment 2 "} +