Skip to content

Commit 8883bfd

Browse files
committed
Also iter includes in findLocalCompletionsForValues
1 parent 88cd2bc commit 8883bfd

File tree

3 files changed

+90
-22
lines changed

3 files changed

+90
-22
lines changed

analysis/src/CompletionBackEnd.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,10 @@ let findLocalCompletionsForValues ~(localTables : LocalTables.t) ~env ~prefix
551551
scope
552552
|> Scope.iterModulesAfterFirstOpen
553553
(processLocalModule ~prefix ~exact ~env ~localTables);
554+
555+
scope
556+
|> Scope.iterIncludes (processLocalInclude ~prefix ~exact ~env ~localTables);
557+
554558
List.rev_append localTables.resultRev valuesFromOpens
555559

556560
let findLocalCompletionsForTypes ~(localTables : LocalTables.t) ~env ~prefix

tests/analysis_tests/tests/src/DotPipeCompleteFromCurrentModule.res

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ module SpriteComp = (
5151

5252
external k: Types.context = "k"
5353

54+
@send
55+
external add: (Types.context, array<Types.comp>) => 't = "add"
56+
5457
module Wall = {
5558
type t
5659

@@ -68,6 +71,14 @@ module Wall = {
6871
]
6972
}
7073

74+
let makeWith = (x) => {
75+
k->add([
76+
k->addPos(1.0, 2.0),
77+
// addP
78+
// ^com
79+
])
80+
}
81+
7182
module Poster = {
7283
type t
7384

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

Lines changed: 75 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ Path
3030
}]
3131
}]
3232

33-
Complete src/DotPipeCompleteFromCurrentModule.res 62:17
34-
posCursor:[62:17] posNoWhite:[62:16] Found expr:[60:15->68:5]
35-
posCursor:[62:17] posNoWhite:[62:16] Found expr:[61:8->67:9]
36-
posCursor:[62:17] posNoWhite:[62:16] Found expr:[62:15->62:17]
37-
Pexp_field [62:15->62:16] _:[67:8->62:17]
33+
Complete src/DotPipeCompleteFromCurrentModule.res 65:17
34+
posCursor:[65:17] posNoWhite:[65:16] Found expr:[63:15->71:5]
35+
posCursor:[65:17] posNoWhite:[65:16] Found expr:[64:8->70:9]
36+
posCursor:[65:17] posNoWhite:[65:16] Found expr:[65:15->65:17]
37+
Pexp_field [65:15->65:16] _:[70:8->65:17]
3838
Completable: Cpath Value[k].""
3939
Package opens Stdlib.place holder Pervasives.JsxModules.place holder
4040
Resolved opens 1 Stdlib
@@ -56,7 +56,19 @@ Path
5656
"sortText": "blah",
5757
"insertText": "->blah",
5858
"additionalTextEdits": [{
59-
"range": {"start": {"line": 62, "character": 16}, "end": {"line": 62, "character": 17}},
59+
"range": {"start": {"line": 65, "character": 16}, "end": {"line": 65, "character": 17}},
60+
"newText": ""
61+
}]
62+
}, {
63+
"label": "->add",
64+
"kind": 12,
65+
"tags": [],
66+
"detail": "(Types.context, array<Types.comp>) => 't",
67+
"documentation": null,
68+
"sortText": "add",
69+
"insertText": "->add",
70+
"additionalTextEdits": [{
71+
"range": {"start": {"line": 65, "character": 16}, "end": {"line": 65, "character": 17}},
6072
"newText": ""
6173
}]
6274
}, {
@@ -68,7 +80,7 @@ Path
6880
"sortText": "addPosFromVec2",
6981
"insertText": "->addPosFromVec2",
7082
"additionalTextEdits": [{
71-
"range": {"start": {"line": 62, "character": 16}, "end": {"line": 62, "character": 17}},
83+
"range": {"start": {"line": 65, "character": 16}, "end": {"line": 65, "character": 17}},
7284
"newText": ""
7385
}]
7486
}, {
@@ -80,21 +92,50 @@ Path
8092
"sortText": "addPos",
8193
"insertText": "->addPos",
8294
"additionalTextEdits": [{
83-
"range": {"start": {"line": 62, "character": 16}, "end": {"line": 62, "character": 17}},
95+
"range": {"start": {"line": 65, "character": 16}, "end": {"line": 65, "character": 17}},
8496
"newText": ""
8597
}]
8698
}]
8799

88-
Complete src/DotPipeCompleteFromCurrentModule.res 65:18
89-
posCursor:[65:18] posNoWhite:[65:17] Found expr:[60:15->68:5]
90-
posCursor:[65:18] posNoWhite:[65:17] Found expr:[61:8->67:9]
91-
posCursor:[65:18] posNoWhite:[65:17] Found expr:[65:15->65:18]
92-
Pexp_ident add:[65:15->65:18]
100+
Complete src/DotPipeCompleteFromCurrentModule.res 68:18
101+
posCursor:[68:18] posNoWhite:[68:17] Found expr:[63:15->71:5]
102+
posCursor:[68:18] posNoWhite:[68:17] Found expr:[64:8->70:9]
103+
posCursor:[68:18] posNoWhite:[68:17] Found expr:[68:15->68:18]
104+
Pexp_ident add:[68:15->68:18]
93105
Completable: Cpath Value[add]
94106
Package opens Stdlib.place holder Pervasives.JsxModules.place holder
95107
Resolved opens 1 Stdlib
96108
ContextPath Value[add]
97109
Path add
110+
[{
111+
"label": "add",
112+
"kind": 12,
113+
"tags": [],
114+
"detail": "(Types.context, array<Types.comp>) => 't",
115+
"documentation": null
116+
}, {
117+
"label": "addPosFromVec2",
118+
"kind": 12,
119+
"tags": [],
120+
"detail": "(Types.context, Types.vec2) => Types.comp",
121+
"documentation": null
122+
}, {
123+
"label": "addPos",
124+
"kind": 12,
125+
"tags": [],
126+
"detail": "(Types.context, float, float) => Types.comp",
127+
"documentation": null
128+
}]
129+
130+
Complete src/DotPipeCompleteFromCurrentModule.res 76:19
131+
posCursor:[76:19] posNoWhite:[76:18] Found expr:[73:19->79:5]
132+
posCursor:[76:19] posNoWhite:[76:18] Found expr:[74:8->78:10]
133+
Completable: Cexpression CArgument Value[add]($1)=addP->array
134+
Package opens Stdlib.place holder Pervasives.JsxModules.place holder
135+
Resolved opens 1 Stdlib
136+
ContextPath CArgument Value[add]($1)
137+
ContextPath Value[add]
138+
Path add
98139
[{
99140
"label": "addPosFromVec2",
100141
"kind": 12,
@@ -109,11 +150,11 @@ Path add
109150
"documentation": null
110151
}]
111152

112-
Complete src/DotPipeCompleteFromCurrentModule.res 77:21
113-
posCursor:[77:21] posNoWhite:[77:20] Found expr:[75:19->80:9]
114-
posCursor:[77:21] posNoWhite:[77:20] Found expr:[76:12->79:13]
115-
posCursor:[77:21] posNoWhite:[77:20] Found expr:[77:19->77:21]
116-
Pexp_field [77:19->77:20] _:[79:12->77:21]
153+
Complete src/DotPipeCompleteFromCurrentModule.res 88:21
154+
posCursor:[88:21] posNoWhite:[88:20] Found expr:[86:19->91:9]
155+
posCursor:[88:21] posNoWhite:[88:20] Found expr:[87:12->90:13]
156+
posCursor:[88:21] posNoWhite:[88:20] Found expr:[88:19->88:21]
157+
Pexp_field [88:19->88:20] _:[90:12->88:21]
117158
Completable: Cpath Value[k].""
118159
Package opens Stdlib.place holder Pervasives.JsxModules.place holder
119160
Resolved opens 1 Stdlib
@@ -135,7 +176,19 @@ Path
135176
"sortText": "blah",
136177
"insertText": "->blah",
137178
"additionalTextEdits": [{
138-
"range": {"start": {"line": 77, "character": 20}, "end": {"line": 77, "character": 21}},
179+
"range": {"start": {"line": 88, "character": 20}, "end": {"line": 88, "character": 21}},
180+
"newText": ""
181+
}]
182+
}, {
183+
"label": "->add",
184+
"kind": 12,
185+
"tags": [],
186+
"detail": "(Types.context, array<Types.comp>) => 't",
187+
"documentation": null,
188+
"sortText": "add",
189+
"insertText": "->add",
190+
"additionalTextEdits": [{
191+
"range": {"start": {"line": 88, "character": 20}, "end": {"line": 88, "character": 21}},
139192
"newText": ""
140193
}]
141194
}, {
@@ -147,7 +200,7 @@ Path
147200
"sortText": "addSprite",
148201
"insertText": "->addSprite",
149202
"additionalTextEdits": [{
150-
"range": {"start": {"line": 77, "character": 20}, "end": {"line": 77, "character": 21}},
203+
"range": {"start": {"line": 88, "character": 20}, "end": {"line": 88, "character": 21}},
151204
"newText": ""
152205
}]
153206
}, {
@@ -159,7 +212,7 @@ Path
159212
"sortText": "addPosFromVec2",
160213
"insertText": "->addPosFromVec2",
161214
"additionalTextEdits": [{
162-
"range": {"start": {"line": 77, "character": 20}, "end": {"line": 77, "character": 21}},
215+
"range": {"start": {"line": 88, "character": 20}, "end": {"line": 88, "character": 21}},
163216
"newText": ""
164217
}]
165218
}, {
@@ -171,7 +224,7 @@ Path
171224
"sortText": "addPos",
172225
"insertText": "->addPos",
173226
"additionalTextEdits": [{
174-
"range": {"start": {"line": 77, "character": 20}, "end": {"line": 77, "character": 21}},
227+
"range": {"start": {"line": 88, "character": 20}, "end": {"line": 88, "character": 21}},
175228
"newText": ""
176229
}]
177230
}]

0 commit comments

Comments
 (0)