Skip to content

Commit 5f045f1

Browse files
committed
restore old behavior when config is not activated
1 parent 0e6ac53 commit 5f045f1

File tree

5 files changed

+41
-13
lines changed

5 files changed

+41
-13
lines changed

analysis/src/ProcessExtra.ml

+8-4
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,8 @@ let pat ~(file : File.t) ~env ~extra (iter : Tast_iterator.iterator)
374374
(match pattern.pat_desc with
375375
| Tpat_record (items, _) ->
376376
addForRecord ~env ~extra ~recordType:pattern.pat_type items;
377-
addLocItem extra pattern.pat_loc (OtherPattern pattern.pat_type)
377+
if !Cfg.useRevampedCompletion then
378+
addLocItem extra pattern.pat_loc (OtherPattern pattern.pat_type)
378379
| Tpat_construct (lident, constructor, _) ->
379380
addForConstructor ~env ~extra pattern.pat_type lident constructor
380381
| Tpat_alias (_inner, ident, name) ->
@@ -384,7 +385,9 @@ let pat ~(file : File.t) ~env ~extra (iter : Tast_iterator.iterator)
384385
(* Log.log("Pattern " ++ name.txt); *)
385386
let stamp = Ident.binding_time ident in
386387
addForPattern stamp name
387-
| _ -> addLocItem extra pattern.pat_loc (OtherPattern pattern.pat_type));
388+
| _ ->
389+
if !Cfg.useRevampedCompletion then
390+
addLocItem extra pattern.pat_loc (OtherPattern pattern.pat_type));
388391
Tast_iterator.default_iterator.pat iter pattern
389392

390393
let expr ~env ~(extra : extra) (iter : Tast_iterator.iterator)
@@ -399,7 +402,8 @@ let expr ~env ~(extra : extra) (iter : Tast_iterator.iterator)
399402
match item with
400403
| Typedtree.Overridden (loc, _) -> Some (loc, desc, (), opt)
401404
| _ -> None));
402-
addLocItem extra expression.exp_loc (OtherExpression expression.exp_type)
405+
if !Cfg.useRevampedCompletion then
406+
addLocItem extra expression.exp_loc (OtherExpression expression.exp_type)
403407
| Texp_constant constant ->
404408
addLocItem extra expression.exp_loc (Constant constant)
405409
(* Skip unit and list literals *)
@@ -411,7 +415,7 @@ let expr ~env ~(extra : extra) (iter : Tast_iterator.iterator)
411415
| Texp_field (inner, lident, _label_description) ->
412416
addForField ~env ~extra ~recordType:inner.exp_type
413417
~fieldType:expression.exp_type lident
414-
| Texp_apply {funct; args} ->
418+
| Texp_apply {funct; args} when !Cfg.useRevampedCompletion ->
415419
args
416420
|> List.iter (fun (label, _) ->
417421
match label with

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ heuristic for: [makeProps, make, createElement], give the loc of `make`
1919
{"contents": {"kind": "markdown", "value": "```rescript\nint\n```"}}
2020

2121
Hover src/Hover.res 33:4
22-
{"contents": {"kind": "markdown", "value": "```rescript\nunit => int\n```"}}
22+
{"contents": {"kind": "markdown", "value": "```rescript\nunit => int\n```\n---\nDoc comment for functionWithTypeAnnotation"}}
2323

2424
Hover src/Hover.res 37:13
2525
{"contents": {"kind": "markdown", "value": "```rescript\nstring\n```"}}
@@ -99,10 +99,10 @@ Hover src/Hover.res 148:6
9999
{"contents": {"kind": "markdown", "value": "```rescript\nint\n```\n---\n doc comment 2 "}}
100100

101101
Hover src/Hover.res 165:23
102-
{"contents": {"kind": "markdown", "value": "```rescript\nfoo<bar>\n```"}}
102+
{"contents": {"kind": "markdown", "value": "```rescript\nfoo<bar>\n```\n\n---\n\n```\n \n```\n```rescript\ntype foo<'a> = {content: 'a, zzz: string}\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22Hover.res%22%2C161%2C2%5D)\n\n\n---\n\n```\n \n```\n```rescript\ntype bar = {age: int}\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22Hover.res%22%2C162%2C2%5D)\n"}}
103103

104104
Hover src/Hover.res 167:22
105-
{"contents": {"kind": "markdown", "value": "```rescript\nfoobar\n```"}}
105+
{"contents": {"kind": "markdown", "value": "```rescript\nfoobar\n```\n\n---\n\n```\n \n```\n```rescript\ntype foobar = foo<bar>\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22Hover.res%22%2C163%2C2%5D)\n"}}
106106

107107
Complete src/Hover.res 170:16
108108
posCursor:[170:16] posNoWhite:[170:15] Found expr:[170:5->170:16]
@@ -244,7 +244,7 @@ Hover src/Hover.res 197:4
244244
{"contents": {"kind": "markdown", "value": "```rescript\nCompV4.props<int, string> => React.element\n```\n\n---\n\n```\n \n```\n```rescript\ntype CompV4.props<'n, 's> = {n?: 'n, s: 's}\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22Hover.res%22%2C190%2C2%5D)\n\n\n---\n\n```\n \n```\n```rescript\ntype React.element = Jsx.element\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22React.res%22%2C0%2C0%5D)\n"}}
245245

246246
Hover src/Hover.res 202:16
247-
{"contents": {"kind": "markdown", "value": "```rescript\nuseR\n```"}}
247+
{"contents": {"kind": "markdown", "value": "```rescript\nuseR\n```\n\n---\n\n```\n \n```\n```rescript\ntype useR = {x: int, y: list<option<r<float>>>}\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22Hover.res%22%2C200%2C0%5D)\n\n\n---\n\n```\n \n```\n```rescript\ntype r<'a> = {i: 'a, f: float}\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22Hover.res%22%2C101%2C0%5D)\n"}}
248248

249249
Hover src/Hover.res 210:13
250250
Nothing at that position. Now trying to use completion.

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

+24
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,34 @@
11
Inlay Hint src/InlayHint.res 1:34
22
[{
3+
"position": {"line": 33, "character": 14},
4+
"label": ": int",
5+
"kind": 1,
6+
"paddingLeft": true,
7+
"paddingRight": false
8+
}, {
9+
"position": {"line": 33, "character": 9},
10+
"label": ": string",
11+
"kind": 1,
12+
"paddingLeft": true,
13+
"paddingRight": false
14+
}, {
315
"position": {"line": 28, "character": 9},
416
"label": ": foo",
517
"kind": 1,
618
"paddingLeft": true,
719
"paddingRight": false
20+
}, {
21+
"position": {"line": 26, "character": 23},
22+
"label": ": (string, string)",
23+
"kind": 1,
24+
"paddingLeft": true,
25+
"paddingRight": false
26+
}, {
27+
"position": {"line": 18, "character": 9},
28+
"label": ": string",
29+
"kind": 1,
30+
"paddingLeft": true,
31+
"paddingRight": false
832
}, {
933
"position": {"line": 16, "character": 9},
1034
"label": ": (string, string)",

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ Hover src/NestedRecordsHover.res 8:7
22
{"contents": {"kind": "markdown", "value": "```rescript\noptions\n```\n\n---\n\n```\n \n```\n```rescript\ntype options = {\n extra?: {\n name: string,\n superExtra?: {age: int},\n otherExtra: option<\n {\n test: bool,\n anotherInlined: {record: bool},\n },\n >,\n },\n}\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22NestedRecordsHover.res%22%2C0%2C0%5D)\n\n\n---\n\n```\n \n```\n```rescript\ntype options.extra = {\n name: string,\n superExtra?: {age: int},\n otherExtra: option<\n {\n test: bool,\n anotherInlined: {record: bool},\n },\n >,\n}\n```\n"}}
33

44
Hover src/NestedRecordsHover.res 11:6
5-
{"contents": {"kind": "markdown", "value": "```rescript\n\\\"options.extra\"\n```"}}
5+
{"contents": {"kind": "markdown", "value": "```rescript\ntype options.extra = {\n name: string,\n superExtra?: {age: int},\n otherExtra: option<\n {\n test: bool,\n anotherInlined: {record: bool},\n },\n >,\n}\n```"}}
66

77
Hover src/NestedRecordsHover.res 14:8
8-
{"contents": {"kind": "markdown", "value": "```rescript\n\\\"options.extra.superExtra\"\n```"}}
8+
{"contents": {"kind": "markdown", "value": "```rescript\ntype options.extra.superExtra = {age: int}\n```"}}
99

1010
Hover src/NestedRecordsHover.res 18:9
11-
{"contents": {"kind": "markdown", "value": "```rescript\n\\\"options.extra.otherExtra\"\n```"}}
11+
{"contents": {"kind": "markdown", "value": "```rescript\ntype options.extra.otherExtra = {\n test: bool,\n anotherInlined: {record: bool},\n}\n```"}}
1212

1313
Hover src/NestedRecordsHover.res 21:11
14-
{"contents": {"kind": "markdown", "value": "```rescript\n\\\"options.extra.otherExtra.anotherInlined\"\n```"}}
14+
{"contents": {"kind": "markdown", "value": "```rescript\ntype options.extra.otherExtra.anotherInlined = {\n record: bool,\n}\n```"}}
1515

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ TypeDefinition src/TypeDefinition.res 8:4
88
{"uri": "TypeDefinition.res", "range": {"start": {"line": 2, "character": 0}, "end": {"line": 2, "character": 28}}}
99

1010
TypeDefinition src/TypeDefinition.res 13:4
11-
null
11+
{"uri": "TypeDefinition.res", "range": {"start": {"line": 11, "character": 0}, "end": {"line": 11, "character": 26}}}
1212

1313
TypeDefinition src/TypeDefinition.res 16:13
1414
{"uri": "TypeDefinition.res", "range": {"start": {"line": 2, "character": 0}, "end": {"line": 2, "character": 28}}}

0 commit comments

Comments
 (0)