From a05176b8130a1346d9bad2c6f20f39a300dcf10a Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Mon, 16 May 2022 09:16:47 +0200 Subject: [PATCH 1/8] Add infra for adding docs for attributes. The docs show up in autocomplete and in hover. --- analysis/src/CompletionBackEnd.ml | 67 ++++++++++++----------- analysis/tests/src/Hover.res | 3 + analysis/tests/src/expected/Hover.res.txt | 6 ++ 3 files changed, 45 insertions(+), 31 deletions(-) diff --git a/analysis/src/CompletionBackEnd.ml b/analysis/src/CompletionBackEnd.ml index 5e8e78f7e..f6bea8335 100644 --- a/analysis/src/CompletionBackEnd.ml +++ b/analysis/src/CompletionBackEnd.ml @@ -727,6 +727,7 @@ let findAllCompletions ~(env : QueryEnv.t) ~prefix ~exact ~namesUsed module LocalTables = struct type 'a table = (string * (int * int), 'a Declared.t) Hashtbl.t + type namesUsed = (string, unit) Hashtbl.t type t = { @@ -1402,38 +1403,42 @@ let processCompletable ~debug ~package ~scope ~env ~pos ~forHover |> List.map mkLabel) @ keyLabels | Cdecorator prefix -> - let mkDecorator name = Completion.create ~name ~kind:(Label "") ~env in + let mkDecorator (name, doc) = + Completion.create ~name ~kind:(Label doc) ~env + in [ - "as"; - "deriving"; - "genType"; - "genType.as"; - "genType.import"; - "genType.opaque"; - "get"; - "get_index"; - "inline"; - "int"; - "meth"; - "module"; - "new"; - "obj"; - "react.component"; - "return"; - "scope"; - "send"; - "set"; - "set_index"; - "string"; - "this"; - "unboxed"; - "uncurry"; - "unwrap"; - "val"; - "variadic"; + ("as", ""); + ("dead", "...docs for dead..."); + ("deriving", ""); + ("genType", ""); + ("genType.as", ""); + ("genType.import", ""); + ("genType.opaque", ""); + ("get", ""); + ("get_index", ""); + ("inline", ""); + ("int", ""); + ("live", "...docs for live..."); + ("meth", ""); + ("module", ""); + ("new", ""); + ("obj", ""); + ("react.component", ""); + ("return", ""); + ("scope", ""); + ("send", ""); + ("set", ""); + ("set_index", ""); + ("string", ""); + ("this", ""); + ("unboxed", ""); + ("uncurry", ""); + ("unwrap", ""); + ("val", ""); + ("variadic", ""); ] - |> List.filter (fun decorator -> Utils.startsWith decorator prefix) - |> List.map (fun decorator -> + |> List.filter (fun (decorator, _) -> Utils.startsWith decorator prefix) + |> List.map (fun (decorator, doc) -> let parts = String.split_on_char '.' prefix in let len = String.length prefix in let dec2 = @@ -1441,7 +1446,7 @@ let processCompletable ~debug ~package ~scope ~env ~pos ~forHover String.sub decorator len (String.length decorator - len) else decorator in - dec2) + (dec2, doc)) |> List.map mkDecorator | CnamedArg (cp, prefix, identsSeen) -> let labels = diff --git a/analysis/tests/src/Hover.res b/analysis/tests/src/Hover.res index e0cbbf16a..8a4075084 100644 --- a/analysis/tests/src/Hover.res +++ b/analysis/tests/src/Hover.res @@ -109,3 +109,6 @@ let typeOk = funAlias let typeDuplicate = AA.fnnxx // ^hov + +@live let dd = 34 +// ^hov \ No newline at end of file diff --git a/analysis/tests/src/expected/Hover.res.txt b/analysis/tests/src/expected/Hover.res.txt index 1e7b5331d..7dc80cc79 100644 --- a/analysis/tests/src/expected/Hover.res.txt +++ b/analysis/tests/src/expected/Hover.res.txt @@ -64,3 +64,9 @@ Hover tests/src/Hover.res 106:16 Hover tests/src/Hover.res 109:25 {"contents": "```rescript\nAA.cond<[< #str(string)]> => AA.cond<[< #str(string)]>\n```"} +Hover tests/src/Hover.res 112:3 +Nothing at that position. Now trying to use completion. +Attribute id:live:[112:0->112:5] label:live +Completable: Cdecorator(live) +{"contents": "```rescript\n...docs for live...\n```"} + From cc0fc4655a333d1eef73cc59af1099d92a371960 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Mon, 16 May 2022 10:48:09 +0200 Subject: [PATCH 2/8] Clean up type vs docstring. --- analysis/src/Commands.ml | 8 ++- analysis/src/CompletionBackEnd.ml | 62 +++++++++++------------ analysis/tests/src/expected/Hover.res.txt | 2 +- 3 files changed, 38 insertions(+), 34 deletions(-) diff --git a/analysis/src/Commands.ml b/analysis/src/Commands.ml index 7dd62ce63..5ea11a58f 100644 --- a/analysis/src/Commands.ml +++ b/analysis/src/Commands.ml @@ -43,8 +43,12 @@ let hover ~path ~line ~col ~currentFile ~debug = ~forHover:true in match completions with - | {kind = Label typString} :: _ -> - Protocol.stringifyHover (Hover.codeBlock typString) + | {kind = Label typString; docstring} :: _ -> + let parts = + (if typString = "" then [] else [Hover.codeBlock typString]) + @ docstring + in + Protocol.stringifyHover (String.concat "\n\n" parts) | _ -> ( match CompletionBackEnd.completionsGetTypeEnv completions with | Some (typ, _env) -> diff --git a/analysis/src/CompletionBackEnd.ml b/analysis/src/CompletionBackEnd.ml index f6bea8335..92b985d42 100644 --- a/analysis/src/CompletionBackEnd.ml +++ b/analysis/src/CompletionBackEnd.ml @@ -1403,39 +1403,39 @@ let processCompletable ~debug ~package ~scope ~env ~pos ~forHover |> List.map mkLabel) @ keyLabels | Cdecorator prefix -> - let mkDecorator (name, doc) = - Completion.create ~name ~kind:(Label doc) ~env + let mkDecorator (name, docstring) = + {(Completion.create ~name ~kind:(Label "") ~env) with docstring} in [ - ("as", ""); - ("dead", "...docs for dead..."); - ("deriving", ""); - ("genType", ""); - ("genType.as", ""); - ("genType.import", ""); - ("genType.opaque", ""); - ("get", ""); - ("get_index", ""); - ("inline", ""); - ("int", ""); - ("live", "...docs for live..."); - ("meth", ""); - ("module", ""); - ("new", ""); - ("obj", ""); - ("react.component", ""); - ("return", ""); - ("scope", ""); - ("send", ""); - ("set", ""); - ("set_index", ""); - ("string", ""); - ("this", ""); - ("unboxed", ""); - ("uncurry", ""); - ("unwrap", ""); - ("val", ""); - ("variadic", ""); + ("as", []); + ("dead", ["...docs for dead..."]); + ("deriving", []); + ("genType", []); + ("genType.as", []); + ("genType.import", []); + ("genType.opaque", []); + ("get", []); + ("get_index", []); + ("inline", []); + ("int", []); + ("live", ["...docs for live..."]); + ("meth", []); + ("module", []); + ("new", []); + ("obj", []); + ("react.component", []); + ("return", []); + ("scope", []); + ("send", []); + ("set", []); + ("set_index", []); + ("string", []); + ("this", []); + ("unboxed", []); + ("uncurry", []); + ("unwrap", []); + ("val", []); + ("variadic", []); ] |> List.filter (fun (decorator, _) -> Utils.startsWith decorator prefix) |> List.map (fun (decorator, doc) -> diff --git a/analysis/tests/src/expected/Hover.res.txt b/analysis/tests/src/expected/Hover.res.txt index 7dc80cc79..a1ab69496 100644 --- a/analysis/tests/src/expected/Hover.res.txt +++ b/analysis/tests/src/expected/Hover.res.txt @@ -68,5 +68,5 @@ Hover tests/src/Hover.res 112:3 Nothing at that position. Now trying to use completion. Attribute id:live:[112:0->112:5] label:live Completable: Cdecorator(live) -{"contents": "```rescript\n...docs for live...\n```"} +{"contents": "...docs for live..."} From 8aa4df8f05498434c200f31387e9e25ee1f9f2cc Mon Sep 17 00:00:00 2001 From: Gabriel Nordeborn Date: Mon, 16 May 2022 12:29:22 +0200 Subject: [PATCH 3/8] add information from docs about attributes --- analysis/src/CompletionBackEnd.ml | 205 +++++++++++++++++++++++++----- 1 file changed, 175 insertions(+), 30 deletions(-) diff --git a/analysis/src/CompletionBackEnd.ml b/analysis/src/CompletionBackEnd.ml index 92b985d42..9ed6ca6b9 100644 --- a/analysis/src/CompletionBackEnd.ml +++ b/analysis/src/CompletionBackEnd.ml @@ -727,7 +727,6 @@ let findAllCompletions ~(env : QueryEnv.t) ~prefix ~exact ~namesUsed module LocalTables = struct type 'a table = (string * (int * int), 'a Declared.t) Hashtbl.t - type namesUsed = (string, unit) Hashtbl.t type t = { @@ -1407,35 +1406,181 @@ let processCompletable ~debug ~package ~scope ~env ~pos ~forHover {(Completion.create ~name ~kind:(Label "") ~env) with docstring} in [ - ("as", []); - ("dead", ["...docs for dead..."]); - ("deriving", []); - ("genType", []); - ("genType.as", []); - ("genType.import", []); - ("genType.opaque", []); - ("get", []); - ("get_index", []); - ("inline", []); - ("int", []); - ("live", ["...docs for live..."]); - ("meth", []); - ("module", []); - ("new", []); - ("obj", []); - ("react.component", []); - ("return", []); - ("scope", []); - ("send", []); - ("set", []); - ("set_index", []); - ("string", []); - ("this", []); - ("unboxed", []); - ("uncurry", []); - ("unwrap", []); - ("val", []); - ("variadic", []); + ( "as", + [ + {|The `@as` decorator is commonly used on record types to alias record field names to a different JavaScript attribute name. + +This is useful to map to JavaScript attribute names that cannot be expressed in ReScript (such as keywords). + +It is also possible to map a ReScript record to a JavaScript array by passing indices to the `@as` decorator. + +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#as-decorator).|}; + ] ); + ( "dead", + [ + {|The `@dead` decorator is for reanalyze, a static analysis tool for ReScript that can do dead code analysis. + +`@dead` suppresses reporting on the value/type, but can also be used to force the analysis to consider a value as dead. Typically used to acknowledge cases of dead code you are not planning to address right now, but can be searched easily later. + +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#dead-decorator).|}; + ] ); + ( "deriving", + [ + {|When the `@deriving` decorator is applied to a record type, it expands the type into a factory function plus a set of getter/setter functions for its fields. + +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#deriving-decorator).|}; + ] ); + ( "deprecated", + [ + {|The `@deprecated` decorator is used to add deprecation notes to types, values and submodules. The compiler and editor tooling will yield a warning whenever a deprecated entity is being used. + +Alternatively, use the `@@deprecated` decorator to add a deprecation warning to the file level. + +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#expression-deprecated-decorator).|}; + ] ); + ("genType", [""]); + ("genType.as", [""]); + ("genType.import", [""]); + ("genType.opaque", [""]); + ( "get", + [ + {|The `@get` decorator is used to bind to a property of an object. + +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#get-decorator).|}; + ] ); + ( "get_index", + [ + {|The `@get_index` decorator is used to access a dynamic property on an object, or an index of an array. + +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#get-index-decorator).|}; + ] ); + ( "inline", + [ + {|The `@inline` decorator tells the compiler to inline its value in every place the binding is being used, rather than use a variable. + +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#inline-decorator).|}; + ] ); + ( "int", + [ + {|The `@int` decorator can be used with polymorphic variants and the @as decorator on externals to modify the compiled JavaScript to use integers for the values instead of strings. + +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#int-decorator).|}; + ] ); + ( "live", + [ + {|The `@live` decorator is for reanalyze, a static analysis tool for ReScript that can do dead code analysis. + +`@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. + +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#live-decorator).|}; + ] ); + ( "meth", + [ + {|The `@meth` decorator is used to call a function on a JavaScript object, and avoid issues with currying. + +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#meth-decorator).|}; + ] ); + ( "module", + [ + {|The `@module` decorator is used to bind to a JavaScript module. + +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#module-decorator).|}; + ] ); + ( "new", + [ + {| +The `@new` decorator is used whenever you need to bind to a JavaScript class constructor that requires the new keword for instantiation.| + +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#new-decorator).|}; + ] ); + ( "obj", + [ + {|The `@obj` decorator is used to create functions that return JavaScript objects with properties that match the function's parameter labels. + +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#obj-decorator).|}; + ] ); + ( "react.component", + [ + {|The `@react.component` decorator is used to annotate functions that are RescriptReact components. + +You will need this decorator whenever you want to use a ReScript / React component in ReScript JSX expressions. + +Note: The `@react.component` decorator requires the react-jsx config to be set in your `bsconfig.json` to enable the required React transformations. + +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#react-component-decorator).|}; + ] ); + ( "return", + [ + {|The `@return` decorator is used to control how `null` and `undefined` values are converted to option types in ReScript. + +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#return-decorator).|}; + ] ); + ( "scope", + [ + {|The `@scope` decorator is used with other decorators such as `@val` and `@module` to declare a parent scope for the binding. + +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#scope-decorator).|}; + ] ); + ( "send", + [ + {|The `@send` decorator is used to bind to a method on an object or array. + +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#send-decorator).|}; + ] ); + ( "set", + [ + {|The `@set` decorator is used to set a property of an object. + +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#set-decorator).|}; + ] ); + ( "set_index", + [ + {|The `@set_index` decorator is used to set a dynamic property on an object, or an index of an array. + +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#set-index-decorator).|}; + ] ); + ( "string", + [ + {|The `@string` decorator can be used with polymorphic variants and the `@as` decorator on externals to modify the string values used for the variants in the compiled JavaScript. + +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#string-decorator).|}; + ] ); + ( "this", + [ + {|The `@this` decorator may be used to bind to an external callback function that require access to a this context. + +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#this-decorator).|}; + ] ); + ( "unboxed", + [ + {|The `@unboxed` decorator provides a way to unwrap variant constructors that have a single argument, or record objects that have a single field. + +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#unboxed-decorator).|}; + ] ); + ( "uncurry", + [ + {|The `@uncurry` decorator can be used to mark any callback argument within an external function as an uncurried function without the need for any explicit uncurried function syntax (`(.) => { ... }`). + +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#uncurry-decorator).|}; + ] ); + ( "unwrap", + [ + {|The `@unwrap` decorator may be used when binding to external functions that accept multiple types for an argument. + +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#unwrap-decorator).|}; + ] ); + ( "val", + [ + {|The `@val` decorator allows you to bind to JavaScript values that are on the global scope. + +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#val-decorator).|}; + ] ); + ( "variadic", + [ + {|The `@variadic` decorator is used to model JavaScript functions that take a variable number of arguments, where all arguments are of the same type. + +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#variadic-decorator).|}; + ] ); ] |> List.filter (fun (decorator, _) -> Utils.startsWith decorator prefix) |> List.map (fun (decorator, doc) -> From 2f3aa826c43f1ede03d57d0471c0349bbfa59122 Mon Sep 17 00:00:00 2001 From: Gabriel Nordeborn Date: Mon, 16 May 2022 12:30:31 +0200 Subject: [PATCH 4/8] update test files --- analysis/tests/src/expected/Completion.res.txt | 4 ++-- analysis/tests/src/expected/Hover.res.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/analysis/tests/src/expected/Completion.res.txt b/analysis/tests/src/expected/Completion.res.txt index ebe3d76aa..9f4127617 100644 --- a/analysis/tests/src/expected/Completion.res.txt +++ b/analysis/tests/src/expected/Completion.res.txt @@ -494,7 +494,7 @@ Completable: Cdecorator(reac) "kind": 4, "tags": [], "detail": "", - "documentation": null + "documentation": {"kind": "markdown", "value": "The `@react.component` decorator is used to annotate functions that are RescriptReact components.\n\nYou will need this decorator whenever you want to use a ReScript / React component in ReScript JSX expressions.\n\nNote: The `@react.component` decorator requires the react-jsx config to be set in your `bsconfig.json` to enable the required React transformations.\n\n[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#react-component-decorator)."} }] Complete tests/src/Completion.res 68:10 @@ -507,7 +507,7 @@ Completable: Cdecorator(react.) "kind": 4, "tags": [], "detail": "", - "documentation": null + "documentation": {"kind": "markdown", "value": "The `@react.component` decorator is used to annotate functions that are RescriptReact components.\n\nYou will need this decorator whenever you want to use a ReScript / React component in ReScript JSX expressions.\n\nNote: The `@react.component` decorator requires the react-jsx config to be set in your `bsconfig.json` to enable the required React transformations.\n\n[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#react-component-decorator)."} }] Complete tests/src/Completion.res 71:27 diff --git a/analysis/tests/src/expected/Hover.res.txt b/analysis/tests/src/expected/Hover.res.txt index a1ab69496..e956449de 100644 --- a/analysis/tests/src/expected/Hover.res.txt +++ b/analysis/tests/src/expected/Hover.res.txt @@ -68,5 +68,5 @@ Hover tests/src/Hover.res 112:3 Nothing at that position. Now trying to use completion. Attribute id:live:[112:0->112:5] label:live Completable: Cdecorator(live) -{"contents": "...docs for 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)."} From 7936860af6fa66c61b72d79fbd96c1f4ea68427d Mon Sep 17 00:00:00 2001 From: Gabriel Nordeborn Date: Mon, 16 May 2022 12:35:02 +0200 Subject: [PATCH 5/8] add gentype details --- analysis/src/CompletionBackEnd.ml | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/analysis/src/CompletionBackEnd.ml b/analysis/src/CompletionBackEnd.ml index 9ed6ca6b9..3a311550c 100644 --- a/analysis/src/CompletionBackEnd.ml +++ b/analysis/src/CompletionBackEnd.ml @@ -1438,10 +1438,30 @@ Alternatively, use the `@@deprecated` decorator to add a deprecation warning to [Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#expression-deprecated-decorator).|}; ] ); - ("genType", [""]); - ("genType.as", [""]); - ("genType.import", [""]); - ("genType.opaque", [""]); + ( "genType", + [ + {|The @genType decorator may be used to export ReScript values and types to JavaScript, and import JavaScript values and types into ReScript. It allows seamless integration of compiled ReScript modules in existing TypeScript, Flow, or plain JavaScript codebases, without loosing type information across different type systems. + +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#gentype-decorator).|}; + ] ); + ( "genType.as", + [ + {|The @genType decorator may be used to export ReScript values and types to JavaScript, and import JavaScript values and types into ReScript. It allows seamless integration of compiled ReScript modules in existing TypeScript, Flow, or plain JavaScript codebases, without loosing type information across different type systems. + +[Read more and see examples in the documentation](https://rescript-lang.org/docs/gentype/latest/usage).|}; + ] ); + ( "genType.import", + [ + {|The @genType decorator may be used to export ReScript values and types to JavaScript, and import JavaScript values and types into ReScript. It allows seamless integration of compiled ReScript modules in existing TypeScript, Flow, or plain JavaScript codebases, without loosing type information across different type systems. + +[Read more and see examples in the documentation](https://rescript-lang.org/docs/gentype/latest/usage).|}; + ] ); + ( "genType.opaque", + [ + {|The @genType decorator may be used to export ReScript values and types to JavaScript, and import JavaScript values and types into ReScript. It allows seamless integration of compiled ReScript modules in existing TypeScript, Flow, or plain JavaScript codebases, without loosing type information across different type systems. + +[Read more and see examples in the documentation](https://rescript-lang.org/docs/gentype/latest/usage).|}; + ] ); ( "get", [ {|The `@get` decorator is used to bind to a property of an object. From 77b634bac59b892e03d9fc6a3ea7d9616f94f761 Mon Sep 17 00:00:00 2001 From: Gabriel Nordeborn Date: Mon, 16 May 2022 15:35:05 +0200 Subject: [PATCH 6/8] add reanalyze note --- analysis/src/CompletionBackEnd.ml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/analysis/src/CompletionBackEnd.ml b/analysis/src/CompletionBackEnd.ml index 3a311550c..7cbcc2e36 100644 --- a/analysis/src/CompletionBackEnd.ml +++ b/analysis/src/CompletionBackEnd.ml @@ -1422,7 +1422,9 @@ It is also possible to map a ReScript record to a JavaScript array by passing in `@dead` suppresses reporting on the value/type, but can also be used to force the analysis to consider a value as dead. Typically used to acknowledge cases of dead code you are not planning to address right now, but can be searched easily later. -[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#dead-decorator).|}; +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#dead-decorator). + +> Hint: Did you know you can run an interactive dead code analysis in your project by running the command `> ReScript: Start dead code analysis.`? Try it!|}; ] ); ( "deriving", [ @@ -1492,7 +1494,9 @@ Alternatively, use the `@@deprecated` decorator to add a deprecation warning to `@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. -[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#live-decorator).|}; +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#live-decorator). + +Hint: Did you know you can run an interactive dead code analysis in your project by running the command `> ReScript: Start dead code analysis.`? Try it!|}; ] ); ( "meth", [ From 1114a3b27dd22153eaad9716fd0d2394b75de7de Mon Sep 17 00:00:00 2001 From: Gabriel Nordeborn Date: Mon, 16 May 2022 15:39:55 +0200 Subject: [PATCH 7/8] update test --- analysis/tests/src/expected/Hover.res.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/analysis/tests/src/expected/Hover.res.txt b/analysis/tests/src/expected/Hover.res.txt index e956449de..6dfef8f4a 100644 --- a/analysis/tests/src/expected/Hover.res.txt +++ b/analysis/tests/src/expected/Hover.res.txt @@ -68,5 +68,5 @@ Hover tests/src/Hover.res 112:3 Nothing at that position. Now trying to use completion. Attribute id:live:[112:0->112: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)."} +{"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 dead code analysis in your project by running the command `> ReScript: Start dead code analysis.`? Try it!"} From ab6856ce838962b88ac318563e86a5e72d888731 Mon Sep 17 00:00:00 2001 From: Gabriel Nordeborn Date: Mon, 16 May 2022 16:43:52 +0200 Subject: [PATCH 8/8] changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce5dc6df2..c1b31c716 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,10 @@ ## master + - Fix issue with autocompletion for constructors in switch statements. - Fix issue with autocompletion inside template expressions. - Fix handling of local opens. - Fix extension crash when renaming a file. +- Add hover information with links to documentation for decorators. ## 1.3.0