Skip to content

Commit fa55ece

Browse files
committed
IncludePstr_include( Pmod_ident)
1 parent feb9b1e commit fa55ece

File tree

7 files changed

+353
-278
lines changed

7 files changed

+353
-278
lines changed

analysis/src/CompletionBackEnd.ml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,22 @@ let processLocalInclude includePath _loc ~prefix ~exact ~(env : QueryEnv.t)
458458
|> Hashtbl.iter (fun (name, _) (declared : Types.type_expr Declared.t) ->
459459
(* We check all the values if their origin is the same as the include path. *)
460460
match declared.modulePath with
461-
| SharedTypes.ModulePath.IncludedModule (source, _) ->
461+
| ModulePath.ExportedModule {name = exportedName}
462+
when exportedName = includePath ->
463+
if Utils.checkName name ~prefix ~exact then
464+
if not (Hashtbl.mem localTables.namesUsed name) then (
465+
Hashtbl.add localTables.namesUsed name ();
466+
localTables.resultRev <-
467+
{
468+
(Completion.create declared.name.txt ~env
469+
~kind:(Value declared.item))
470+
with
471+
deprecated = declared.deprecated;
472+
docstring = declared.docstring;
473+
synthetic = true;
474+
}
475+
:: localTables.resultRev)
476+
| ModulePath.IncludedModule (source, _) ->
462477
let source_module_path =
463478
match Path.flatten source with
464479
| `Contains_apply -> ""

analysis/src/CompletionFrontEnd.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,7 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor
745745
processed := true
746746
| Pstr_include {pincl_mod = {pmod_desc = med}} -> (
747747
match med with
748+
| Pmod_ident {txt = lid; loc}
748749
| Pmod_apply ({pmod_desc = Pmod_ident {txt = lid; loc}}, _) ->
749750
let module_name = Longident.flatten lid |> String.concat "." in
750751
scope := !scope |> Scope.addInclude ~name:module_name ~loc

analysis/src/Completions.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ let getCompletions ~debug ~path ~pos ~currentFile ~forHover =
99
with
1010
| None -> None
1111
| Some (completable, scope) -> (
12-
if debug then (
12+
(* uncomment when debugging *)
13+
if false then (
1314
Printf.printf "\nScope from frontend:\n";
1415
List.iter
1516
(fun item ->

tests/analysis_tests/tests/src/DotPipeCompleteFromCurrentModule.res

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -15,80 +15,3 @@ module Y = {
1515

1616
let b = (x:t) => 4
1717
}
18-
19-
20-
module Types = {
21-
type comp
22-
type context
23-
type vec2
24-
}
25-
26-
module PosComp = (
27-
T: {
28-
type t
29-
},
30-
) => {
31-
open Types
32-
33-
@send
34-
external addPos: (context, float, float) => comp = "pos"
35-
36-
@send
37-
external addPosFromVec2: (context, vec2) => comp = "pos"
38-
}
39-
40-
module SpriteComp = (
41-
T: {
42-
type t
43-
}
44-
)
45-
=> {
46-
open Types
47-
48-
@send
49-
external addSprite: (context, string) => comp = "sprite"
50-
}
51-
52-
external k: Types.context = "k"
53-
54-
@send
55-
external add: (Types.context, array<Types.comp>) => 't = "add"
56-
57-
module Wall = {
58-
type t
59-
60-
include PosComp({ type t = t })
61-
62-
let blah = (k: Types.context) => ""
63-
64-
let make = () => {
65-
[
66-
// k.
67-
// ^com
68-
69-
// add
70-
// ^com
71-
]
72-
}
73-
74-
let makeWith = (x) => {
75-
k->add([
76-
k->addPos(1.0, 2.0),
77-
// addP
78-
// ^com
79-
])
80-
}
81-
82-
module Poster = {
83-
type t
84-
85-
include SpriteComp({ type t = t })
86-
87-
let make = () => {
88-
[
89-
// k.
90-
// ^com
91-
]
92-
}
93-
}
94-
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
module Types = {
2+
type comp
3+
4+
type context
5+
6+
type vec2
7+
}
8+
9+
module PosComp = (
10+
T: {
11+
type t
12+
},
13+
) => {
14+
open Types
15+
16+
@send
17+
external addPos: (context, float, float) => comp = "pos"
18+
19+
@send
20+
external addPosFromVec2: (context, vec2) => comp = "pos"
21+
}
22+
23+
module SpriteComp = (
24+
T: {
25+
type t
26+
},
27+
) => {
28+
open Types
29+
30+
@send
31+
external addSprite: (context, string) => comp = "sprite"
32+
}
33+
34+
external k: Types.context = "k"
35+
36+
@send
37+
external add: (Types.context, array<Types.comp>) => 't = "add"
38+
39+
module Wall = {
40+
type t
41+
42+
include PosComp({type t = t})
43+
44+
let blah = (k: Types.context) => ""
45+
46+
let make = () => {
47+
[
48+
// k.
49+
// ^com
50+
// add
51+
// ^com
52+
]
53+
}
54+
55+
let makeWith = x => {
56+
k->add([
57+
k->addPos(1.0, 2.0),
58+
59+
// addP
60+
// ^com
61+
])
62+
}
63+
64+
module Poster = {
65+
type t
66+
67+
include SpriteComp({type t = t})
68+
69+
let make = () => {
70+
[
71+
// k.
72+
// ^com
73+
]
74+
}
75+
}
76+
}
77+
78+
module M = {
79+
let lex = (a: int) => "foo"
80+
}
81+
82+
module N = {
83+
include M
84+
85+
let a = 4
86+
// let o = a.l
87+
// ^com
88+
89+
// let _ = l
90+
// ^com
91+
}

0 commit comments

Comments
 (0)