Skip to content

Commit 704c5dc

Browse files
committed
wire up constructor docstrings (even though the parser doesnt handle docstrings on constructors yet)
1 parent 502c1df commit 704c5dc

File tree

5 files changed

+18
-3
lines changed

5 files changed

+18
-3
lines changed

analysis/src/CompletionBackEnd.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ let completionsForExportedConstructors ~(env : QueryEnv.t) ~prefix ~exact
598598
if not (Hashtbl.mem namesUsed name) then
599599
let () = Hashtbl.add namesUsed name () in
600600
Some
601-
(Completion.create ~name ~env
601+
(Completion.create ~name ~env ~docstring:c.docstring
602602
~kind:
603603
(Completion.Constructor
604604
(c, t.item.decl |> Shared.declToString t.name.txt))

analysis/src/Hover.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ let newHover ~full:{file; package} ~supportsMarkdownLinks locItem =
241241
| `Declared ->
242242
let typeString, docstring = t |> fromType ~docstring in
243243
typeString :: docstring
244-
| `Constructor {cname = {txt}; args} ->
244+
| `Constructor {cname = {txt}; args; docstring} ->
245245
let typeString, docstring = t |> fromType ~docstring in
246246
let argsString =
247247
match args with

analysis/src/ProcessCmt.ml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ let rec forTypeSignatureItem ~(env : SharedTypes.Env.t) ~(exported : Exported.t)
7676
| Cstr_record _ -> []);
7777
res = cd_res;
7878
typeDecl = (name, decl);
79+
docstring =
80+
(match
81+
ProcessAttributes.findDocAttribute
82+
cd_attributes
83+
with
84+
| None -> []
85+
| Some docstring -> [docstring]);
7986
}
8087
in
8188
let declared =
@@ -207,6 +214,12 @@ let forTypeDeclaration ~env ~(exported : Exported.t)
207214
| None -> None
208215
| Some t -> Some t.ctyp_type);
209216
typeDecl = (name.txt, typ_type);
217+
docstring =
218+
(match
219+
ProcessAttributes.findDocAttribute cd_attributes
220+
with
221+
| None -> []
222+
| Some docstring -> [docstring]);
210223
}
211224
in
212225
let declared =

analysis/src/References.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ let definedForLoc ~file ~package locKind =
169169
| Constructor name -> (
170170
match getConstructor file stamp name with
171171
| None -> None
172-
| Some constructor -> Some ([], `Constructor constructor))
172+
| Some constructor ->
173+
Some (constructor.docstring, `Constructor constructor))
173174
| Field name ->
174175
Some
175176
( (match getField file stamp name with

analysis/src/SharedTypes.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ module Constructor = struct
3939
args: (Types.type_expr * Location.t) list;
4040
res: Types.type_expr option;
4141
typeDecl: string * Types.type_declaration;
42+
docstring: string list;
4243
}
4344
end
4445

0 commit comments

Comments
 (0)