Skip to content

Commit e5aad23

Browse files
committed
also change decl printing to get rid of Stdlib prefix
1 parent 488c30f commit e5aad23

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

analysis/src/PrintType.ml

+7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ let printExpr ?(lineWidth = 60) typ =
66

77
let printDecl ?printNameAsIs ~recStatus name decl =
88
Printtyp.reset_names ();
9+
let name =
10+
if
11+
String.starts_with ~prefix:"Stdlib_" name
12+
|| String.starts_with ~prefix:"Stdlib." name
13+
then String.sub name 7 (String.length name - 7)
14+
else name
15+
in
916
Res_doc.to_string ~width:60
1017
(Res_outcome_printer.print_out_sig_item_doc ?print_name_as_is:printNameAsIs
1118
(Printtyp.tree_of_type_declaration (Ident.create name) decl recStatus))
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
Hover src/Auto.res 2:13
2-
{"contents": {"kind": "markdown", "value": "```rescript\n('a => 'b, List.t<'a>) => List.t<'b>\n```\n\n---\n\n```\n \n```\n```rescript\ntype Stdlib.List.t<'a> = list<'a>\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22Stdlib_List.resi%22%2C34%2C0%5D)\n"}}
2+
{"contents": {"kind": "markdown", "value": "```rescript\n('a => 'b, List.t<'a>) => List.t<'b>\n```\n\n---\n\n```\n \n```\n```rescript\ntype List.t<'a> = list<'a>\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22Stdlib_List.resi%22%2C34%2C0%5D)\n"}}
33

tests/analysis_tests/tests/src/expected/Definition.res.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ Definition src/Definition.res 10:23
55
{"uri": "Definition.res", "range": {"start": {"line": 6, "character": 7}, "end": {"line": 6, "character": 13}}}
66

77
Hover src/Definition.res 14:14
8-
{"contents": {"kind": "markdown", "value": "```rescript\n(List.t<'a>, 'a => 'b) => List.t<'b>\n```\n\n---\n\n```\n \n```\n```rescript\ntype Stdlib.List.t<'a> = list<'a>\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22Stdlib_List.resi%22%2C34%2C0%5D)\n\n---\n\n`map(list, f)` returns a new list with `f` applied to each element of `list`.\n\n## Examples\n\n```rescript\nlist{1, 2}->List.map(x => x + 1) // list{3, 4}\n```\n"}}
8+
{"contents": {"kind": "markdown", "value": "```rescript\n(List.t<'a>, 'a => 'b) => List.t<'b>\n```\n\n---\n\n```\n \n```\n```rescript\ntype List.t<'a> = list<'a>\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22Stdlib_List.resi%22%2C34%2C0%5D)\n\n---\n\n`map(list, f)` returns a new list with `f` applied to each element of `list`.\n\n## Examples\n\n```rescript\nlist{1, 2}->List.map(x => x + 1) // list{3, 4}\n```\n"}}
99

1010
Hover src/Definition.res 18:14
11-
{"contents": {"kind": "markdown", "value": "```rescript\n('a => 'b, List.t<'a>) => List.t<'b>\n```\n\n---\n\n```\n \n```\n```rescript\ntype Stdlib.List.t<'a> = list<'a>\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22Stdlib_List.resi%22%2C34%2C0%5D)\n"}}
11+
{"contents": {"kind": "markdown", "value": "```rescript\n('a => 'b, List.t<'a>) => List.t<'b>\n```\n\n---\n\n```\n \n```\n```rescript\ntype List.t<'a> = list<'a>\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22Stdlib_List.resi%22%2C34%2C0%5D)\n"}}
1212

1313
Hover src/Definition.res 23:3
1414
{"contents": {"kind": "markdown", "value": "```rescript\n(int, int) => int\n```"}}

0 commit comments

Comments
 (0)