@@ -4,14 +4,14 @@ let digConstructor ~env ~getModule path =
4
4
| `Stamp stamp -> (
5
5
match Hashtbl. find_opt env.file.stamps.types stamp with
6
6
| None -> None
7
- | Some t -> Some (env, t) )
7
+ | Some t -> Some (env, t))
8
8
| `Exported (env , name ) -> (
9
9
match Hashtbl. find_opt env.exported.types name with
10
10
| None -> None
11
11
| Some stamp -> (
12
12
match Hashtbl. find_opt env.file.stamps.types stamp with
13
13
| None -> None
14
- | Some t -> Some (env, t) ) )
14
+ | Some t -> Some (env, t)) )
15
15
| _ -> None
16
16
17
17
let codeBlock code = Printf. sprintf " ```rescript\n %s\n ```" code
@@ -21,22 +21,23 @@ let showModuleTopLevel ~docstring ~name
21
21
let contents =
22
22
topLevel
23
23
|> List. map (fun item ->
24
- match item.SharedTypes. item with
25
- (* TODO pretty print module contents *)
26
- | SharedTypes. MType ({decl} , recStatus ) ->
27
- " " ^ (decl |> Shared. declToString ~rec Status item.name.txt)
28
- | Module _ -> " module " ^ item.name.txt
29
- | MValue typ ->
30
- " let " ^ item.name.txt ^ " : " ^ (typ |> Shared. typeToString)) (* TODO indent *)
24
+ match item.SharedTypes. item with
25
+ (* TODO pretty print module contents *)
26
+ | SharedTypes. MType ({decl} , recStatus ) ->
27
+ " " ^ (decl |> Shared. declToString ~rec Status item.name.txt)
28
+ | Module _ -> " module " ^ item.name.txt
29
+ | MValue typ ->
30
+ " let " ^ item.name.txt ^ " : " ^ (typ |> Shared. typeToString))
31
+ (* TODO indent *)
31
32
|> String. concat " \n "
32
33
in
33
- let full = " module " ^ name ^ " = {" ^ " \n " ^ contents ^ " \n }" in
34
+ let full = codeBlock ( " module " ^ name ^ " = {" ^ " \n " ^ contents ^ " \n }" ) in
34
35
let doc =
35
36
match docstring with
36
37
| [] -> " "
37
38
| _ :: _ -> " \n " ^ (docstring |> String. concat " \n " ) ^ " \n "
38
39
in
39
- Some (doc ^ codeBlock full)
40
+ Some (doc ^ full)
40
41
41
42
let showModule ~docstring ~(file : SharedTypes.file ) ~name
42
43
(declared : SharedTypes.moduleKind SharedTypes.declared option ) =
@@ -65,7 +66,7 @@ let newHover ~(file : SharedTypes.file) ~getModule loc =
65
66
| Some d -> (d.name.txt, d.docstring)
66
67
| None -> (file.moduleName, file.contents.docstring)
67
68
in
68
- showModule ~docstring ~name ~file declared ) )
69
+ showModule ~docstring ~name ~file declared) )
69
70
| LModule (GlobalReference (moduleName , path , tip )) -> (
70
71
match getModule moduleName with
71
72
| None -> None
@@ -88,25 +89,26 @@ let newHover ~(file : SharedTypes.file) ~getModule loc =
88
89
| Some d -> (d.name.txt, d.docstring)
89
90
| None -> (file.moduleName, file.contents.docstring)
90
91
in
91
- showModule ~docstring ~name ~file declared ) ) ) ) )
92
+ showModule ~docstring ~name ~file declared)))) )
92
93
| LModule NotFound -> None
93
94
| TopLevelModule name -> (
94
95
match getModule name with
95
96
| None -> None
96
97
| Some file ->
97
98
showModule ~docstring: file.contents.docstring ~name: file.moduleName ~file
98
- None )
99
+ None )
99
100
| Typed (_ , Definition (_ , (Field _ | Constructor _ ))) -> None
100
101
| Constant t ->
101
102
Some
102
- ( match t with
103
- | Const_int _ -> " int"
104
- | Const_char _ -> " char"
105
- | Const_string _ -> " string"
106
- | Const_float _ -> " float"
107
- | Const_int32 _ -> " int32"
108
- | Const_int64 _ -> " int64"
109
- | Const_nativeint _ -> " int" )
103
+ (codeBlock
104
+ (match t with
105
+ | Const_int _ -> " int"
106
+ | Const_char _ -> " char"
107
+ | Const_string _ -> " string"
108
+ | Const_float _ -> " float"
109
+ | Const_int32 _ -> " int32"
110
+ | Const_int64 _ -> " int64"
111
+ | Const_nativeint _ -> " int" ))
110
112
| Typed (t , locKind ) ->
111
113
let fromType ~docstring typ =
112
114
let typeString = codeBlock (typ |> Shared. typeToString) in
@@ -122,7 +124,7 @@ let newHover ~(file : SharedTypes.file) ~getModule loc =
122
124
Utils. startsWith (Path. name path) " Js.Fn.arity"
123
125
in
124
126
if isUncurriedInternal then None
125
- else Some (decl |> Shared. declToString txt, docstring) )
127
+ else Some (decl |> Shared. declToString txt, docstring))
126
128
in
127
129
let typeString, docstring =
128
130
match extraTypeInfo with
@@ -155,6 +157,6 @@ let newHover ~(file : SharedTypes.file) ~getModule loc =
155
157
typeString :: codeBlock (txt ^ argsString) :: docstring
156
158
| `Field {typ} ->
157
159
let typeString, docstring = typ |> fromType ~docstring in
158
- typeString :: docstring )
160
+ typeString :: docstring)
159
161
in
160
162
Some (String. concat " \n\n " parts)
0 commit comments