@@ -18,6 +18,7 @@ let codeBlock = code => {
18
18
19
19
let showModuleTopLevel =
20
20
(
21
+ ~deprecated,
21
22
~docstring,
22
23
~name,
23
24
topLevel: list (SharedTypes . declared (SharedTypes . moduleItem )),
@@ -41,20 +42,27 @@ let showModuleTopLevel =
41
42
| None => ""
42
43
| Some (s ) => "\n " ++ s ++ "\n "
43
44
};
44
- Some (doc ++ codeBlock(full));
45
+ let depr =
46
+ switch (deprecated) {
47
+ | None => ""
48
+ | Some (s ) => "\n Deprecated: " ++ s ++ "\n "
49
+ };
50
+ Some (depr ++ doc ++ codeBlock(full));
45
51
};
46
52
47
53
let showModule =
48
54
(
55
+ ~deprecated,
49
56
~docstring,
50
57
~file: SharedTypes . file ,
51
58
~name,
52
59
declared: option (SharedTypes . declared (SharedTypes . moduleKind )),
53
60
) => {
54
61
switch (declared) {
55
- | None => showModuleTopLevel(~docstring, ~name, file. contents. topLevel)
62
+ | None =>
63
+ showModuleTopLevel(~deprecated, ~docstring, ~name, file. contents. topLevel)
56
64
| Some ({item: Structure ({topLevel})}) =>
57
- showModuleTopLevel(~docstring, ~name, topLevel)
65
+ showModuleTopLevel(~deprecated , ~ docstring, ~name, topLevel)
58
66
| Some ({item: Ident (_ )}) => Some ("Unable to resolve module reference" )
59
67
};
60
68
};
@@ -70,12 +78,12 @@ let newHover = (~rootUri, ~file: SharedTypes.file, ~getModule, loc) => {
70
78
let %opt md = Hashtbl.find_opt(file.stamps.modules, stamp);
71
79
let %opt (file, declared) =
72
80
References . resolveModuleReference (~file , ~getModule , md );
73
- let (name , docstring ) =
81
+ let (name , deprecated , docstring ) =
74
82
switch (declared) {
75
- | Some (d ) => (d. name. txt, d. docstring)
76
- | None => (file. moduleName, file. contents. docstring)
83
+ | Some (d ) => (d. name. txt, d. deprecated , d . docstring)
84
+ | None => (file. moduleName, None , file. contents. docstring)
77
85
};
78
- showModule(~docstring, ~name, ~file, declared);
86
+ showModule(~deprecated , ~ docstring, ~name, ~file, declared);
79
87
| LModule (GlobalReference (moduleName , path , tip )) =>
80
88
let %opt file = getModule(moduleName);
81
89
let env = Query . fileEnv(file);
@@ -84,16 +92,17 @@ let newHover = (~rootUri, ~file: SharedTypes.file, ~getModule, loc) => {
84
92
let %opt md = Hashtbl.find_opt(file.stamps.modules, stamp);
85
93
let %opt (file, declared) =
86
94
References . resolveModuleReference (~file , ~getModule , md );
87
- let (name , docstring ) =
95
+ let (name , deprecated , docstring ) =
88
96
switch (declared) {
89
- | Some (d ) => (d. name. txt, d. docstring)
90
- | None => (file. moduleName, file. contents. docstring)
97
+ | Some (d ) => (d. name. txt, d. deprecated , d . docstring)
98
+ | None => (file. moduleName, None , file. contents. docstring)
91
99
};
92
- showModule(~docstring, ~name, ~file, declared);
100
+ showModule(~deprecated , ~ docstring, ~name, ~file, declared);
93
101
| LModule (NotFound ) => None
94
102
| TopLevelModule (name ) =>
95
103
let %opt file = getModule(name);
96
104
showModule (
105
+ ~deprecated =None ,
97
106
~docstring =file .contents .docstring ,
98
107
~name =file .moduleName ,
99
108
~file ,
@@ -113,7 +122,7 @@ let newHover = (~rootUri, ~file: SharedTypes.file, ~getModule, loc) => {
113
122
},
114
123
)
115
124
| Typed (t , locKind ) =>
116
- let fromType = (~docstring, typ) => {
125
+ let fromType = (~deprecated , ~ docstring, typ) => {
117
126
let typeString = codeBlock(typ |> Shared . typeToString);
118
127
let extraTypeInfo = {
119
128
let env = Query . fileEnv(file);
@@ -125,35 +134,44 @@ let newHover = (~rootUri, ~file: SharedTypes.file, ~getModule, loc) => {
125
134
if (isUncurriedInternal) {
126
135
None ;
127
136
} else {
128
- Some ((decl |> Shared . declToString(txt), docstring));
137
+ Some ((decl |> Shared . declToString(txt), deprecated , docstring));
129
138
};
130
139
};
131
- let (typeString , docstring ) =
140
+ let (typeString , deprecated , docstring ) =
132
141
switch (extraTypeInfo) {
133
- | None => (typeString, docstring)
134
- | Some ((extra , extraDocstring )) => (
142
+ | None => (typeString, deprecated , docstring)
143
+ | Some ((extra , extraDeprecated , extraDocstring )) => (
135
144
typeString ++ "\n\n " ++ codeBlock(extra),
145
+ extraDeprecated,
136
146
extraDocstring,
137
147
)
138
148
};
139
- (Some (typeString), docstring);
149
+ let deprecatedMsg =
150
+ switch (deprecated) {
151
+ | None => None
152
+ | Some (s ) => Some ("Deprecated: " ++ s)
153
+ };
154
+ (Some (typeString), deprecatedMsg, docstring);
140
155
};
141
156
142
157
let parts =
143
158
switch (References . definedForLoc(~file, ~getModule, locKind)) {
144
159
| None =>
145
- let (typeString , docstring ) = t |> fromType(~docstring= None );
146
- [ typeString, docstring] ;
147
- | Some ((docstring , {uri}, res )) =>
160
+ let (typeString , deprecatedMsg , docstring ) =
161
+ t |> fromType(~deprecated= None , ~docstring= None );
162
+ [ typeString, deprecatedMsg, docstring] ;
163
+ | Some ((deprecated , docstring , {uri}, res )) =>
148
164
let pathFromRoot = uri |> Uri2 . pathFromRoot(~rootUri);
149
165
150
166
let parts =
151
167
switch (res) {
152
168
| ` Declared =>
153
- let (typeString , docstring ) = t |> fromType(~docstring);
154
- [ typeString, docstring] ;
169
+ let (typeString , deprecatedMsg , docstring ) =
170
+ t |> fromType(~deprecated, ~docstring);
171
+ [ typeString, deprecatedMsg, docstring] ;
155
172
| ` Constructor ({cname: {txt}, args}) =>
156
- let (typeString , docstring ) = t |> fromType(~docstring);
173
+ let (typeString , deprecatedMsg , docstring ) =
174
+ t |> fromType(~deprecated, ~docstring);
157
175
158
176
let argsString =
159
177
switch (args) {
@@ -165,10 +183,16 @@ let newHover = (~rootUri, ~file: SharedTypes.file, ~getModule, loc) => {
165
183
|> Printf . sprintf("(% s )" )
166
184
};
167
185
168
- [ typeString, Some (codeBlock(txt ++ argsString)), docstring] ;
186
+ [
187
+ typeString,
188
+ Some (codeBlock(txt ++ argsString)),
189
+ deprecatedMsg,
190
+ docstring,
191
+ ] ;
169
192
| ` Field ({typ}) =>
170
- let (typeString , docstring ) = typ |> fromType(~docstring);
171
- [ typeString, docstring] ;
193
+ let (typeString , deprecatedMsg , docstring ) =
194
+ typ |> fromType(~deprecated, ~docstring);
195
+ [ typeString, deprecatedMsg, docstring] ;
172
196
};
173
197
174
198
parts @ [ Some (pathFromRoot)] ;
0 commit comments