Skip to content
This repository was archived by the owner on Apr 24, 2021. It is now read-only.

Commit ae9c086

Browse files
committed
Autocomplete for id of string type.
1 parent 0d20542 commit ae9c086

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

examples/example-project/src/ZZ.res

+2
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,5 @@ let comp = <O.Comp key="12" second="abcc" v=12 />
136136

137137
let lll = List.make(3, 4)
138138

139+
let abc = "abc"
140+

src/NewCompletions.ml

+5-2
Original file line numberDiff line numberDiff line change
@@ -513,14 +513,17 @@ let processCompletable ~findItems ~full ~package ~pos ~rawOpens
513513
mkItem ~name ~kind:(kindToInt item) ~deprecated
514514
~detail:(detail name item) ~docstring ~uri ~pos_lnum)
515515
| Cpipe (pipe, partialName) -> (
516+
let stringModulePath = ["Js"; "String2"] in
516517
let getModulePath path =
517518
let rec loop (path : Path.t) =
518519
match path with
519520
| Pident id -> [Ident.name id]
520521
| Pdot (p, s, _) -> s :: loop p
521522
| Papply _ -> []
522523
in
523-
match loop path with _ :: rest -> List.rev rest | [] -> []
524+
match path with
525+
| Path.Pident id when Ident.name id = "string" -> stringModulePath
526+
| _ -> ( match loop path with _ :: rest -> List.rev rest | [] -> [])
524527
in
525528
let getLhsPath ~pipeId ~partialName =
526529
match [pipeId] |> findItems ~exact:true with
@@ -537,7 +540,7 @@ let processCompletable ~findItems ~full ~package ~pos ~rawOpens
537540
let lhsPath =
538541
match pipe with
539542
| PipeId pipeId -> getLhsPath ~pipeId ~partialName
540-
| PipeString -> Some (["Js"; "String2"], partialName)
543+
| PipeString -> Some (stringModulePath, partialName)
541544
in
542545
let removePackageOpens modulePath =
543546
match modulePath with

0 commit comments

Comments
 (0)