@@ -210,19 +210,16 @@ let localValueCompletions ~pos ~(env : ProcessCmt.queryEnv) suffix =
210
210
{(emptyDeclared c.cname.txt) with item = Constructor (c, t)}))
211
211
else results
212
212
in
213
- let results =
214
- if suffix = " " || not (isCapitalized suffix) then
215
- results
216
- @ completionForDeclareds ~pos env.qFile.stamps.values suffix (fun v ->
217
- Value v)
218
- @ completionForDeclareds ~pos env.qFile.stamps.types suffix (fun t ->
219
- Type t)
220
- @ (completionForFields env.qExported.types env.qFile.stamps.types suffix
221
- |> List. map (fun (f , t ) ->
222
- {(emptyDeclared f.fname.txt) with item = Field (f, t)}))
223
- else results
224
- in
225
- results |> List. map (fun x -> (env.qFile.uri, x))
213
+ if suffix = " " || not (isCapitalized suffix) then
214
+ results
215
+ @ completionForDeclareds ~pos env.qFile.stamps.values suffix (fun v ->
216
+ Value v)
217
+ @ completionForDeclareds ~pos env.qFile.stamps.types suffix (fun t ->
218
+ Type t)
219
+ @ (completionForFields env.qExported.types env.qFile.stamps.types suffix
220
+ |> List. map (fun (f , t ) ->
221
+ {(emptyDeclared f.fname.txt) with item = Field (f, t)}))
222
+ else results
226
223
227
224
let valueCompletions ~(env : ProcessCmt.queryEnv ) suffix =
228
225
Log. log (" - Completing in " ^ Uri2. toString env.qFile.uri);
@@ -247,22 +244,17 @@ let valueCompletions ~(env : ProcessCmt.queryEnv) suffix =
247
244
{(emptyDeclared c.cname.txt) with item = Constructor (c, t)})))
248
245
else results
249
246
in
250
- let results =
251
- if suffix = " " || not (isCapitalized suffix) then (
252
- Log. log " -- not capitalized" ;
253
- results
254
- @ completionForExporteds env.qExported.values env.qFile.stamps.values
255
- suffix (fun v -> Value v)
256
- @ completionForExporteds env.qExported.types env.qFile.stamps.types suffix
257
- (fun t -> Type t)
258
- @ (completionForFields env.qExported.types env.qFile.stamps.types suffix
259
- |> List. map (fun (f , t ) ->
260
- {(emptyDeclared f.fname.txt) with item = Field (f, t)})))
261
- else results
262
- in
263
- (* Log.log("Getting value completions " ++ env.file.uri);
264
- Log.log(String.concat(", ", results |. Belt.List.map(x => x.name.txt))); *)
265
- results |> List. map (fun x -> (env.qFile.uri, x))
247
+ if suffix = " " || not (isCapitalized suffix) then (
248
+ Log. log " -- not capitalized" ;
249
+ results
250
+ @ completionForExporteds env.qExported.values env.qFile.stamps.values suffix
251
+ (fun v -> Value v)
252
+ @ completionForExporteds env.qExported.types env.qFile.stamps.types suffix
253
+ (fun t -> Type t)
254
+ @ (completionForFields env.qExported.types env.qFile.stamps.types suffix
255
+ |> List. map (fun (f , t ) ->
256
+ {(emptyDeclared f.fname.txt) with item = Field (f, t)})))
257
+ else results
266
258
267
259
let attributeCompletions ~(env : ProcessCmt.queryEnv ) ~suffix =
268
260
let results = [] in
@@ -273,18 +265,15 @@ let attributeCompletions ~(env : ProcessCmt.queryEnv) ~suffix =
273
265
suffix (fun m -> Module m)
274
266
else results
275
267
in
276
- let results =
277
- if suffix = " " || not (isCapitalized suffix) then
278
- results
279
- @ completionForExporteds env.qExported.values env.qFile.stamps.values
280
- suffix (fun v -> Value v)
281
- (* completionForExporteds(env.exported.types, env.file.stamps.types, suffix, t => Type(t)) @ *)
282
- @ (completionForFields env.qExported.types env.qFile.stamps.types suffix
283
- |> List. map (fun (f , t ) ->
284
- {(emptyDeclared f.fname.txt) with item = Field (f, t)}))
285
- else results
286
- in
287
- results |> List. map (fun x -> (env.qFile.uri, x))
268
+ if suffix = " " || not (isCapitalized suffix) then
269
+ results
270
+ @ completionForExporteds env.qExported.values env.qFile.stamps.values suffix
271
+ (fun v -> Value v)
272
+ (* completionForExporteds(env.exported.types, env.file.stamps.types, suffix, t => Type(t)) @ *)
273
+ @ (completionForFields env.qExported.types env.qFile.stamps.types suffix
274
+ |> List. map (fun (f , t ) ->
275
+ {(emptyDeclared f.fname.txt) with item = Field (f, t)}))
276
+ else results
288
277
289
278
(* TODO filter out things that are defined after the current position *)
290
279
let resolveRawOpens ~env ~rawOpens ~package =
@@ -330,12 +319,12 @@ let getItems ~full ~package ~rawOpens ~allModules ~pos ~parts =
330
319
(fun results env ->
331
320
let completionsFromThisOpen = valueCompletions ~env suffix in
332
321
List. filter
333
- (fun (_uri , declared ) ->
334
- if not (Hashtbl. mem alreadyUsedIdentifiers declared.name.txt)
335
- then (
322
+ (fun declared ->
323
+ if Hashtbl. mem alreadyUsedIdentifiers declared.name.txt then
324
+ false
325
+ else (
336
326
Hashtbl. add alreadyUsedIdentifiers declared.name.txt true ;
337
- true )
338
- else false )
327
+ true ))
339
328
completionsFromThisOpen
340
329
@ results)
341
330
[]
@@ -344,14 +333,9 @@ let getItems ~full ~package ~rawOpens ~allModules ~pos ~parts =
344
333
let localModuleNames =
345
334
allModules
346
335
|> Utils. filterMap (fun name ->
347
- match
348
- Utils. startsWith name suffix && not (String. contains name '-' )
349
- with
350
- | true ->
351
- Some
352
- ( env.qFile.uri,
353
- {(emptyDeclared name) with item = FileModule name} )
354
- | false -> None )
336
+ if Utils. startsWith name suffix && not (String. contains name '-' )
337
+ then Some {(emptyDeclared name) with item = FileModule name}
338
+ else None )
355
339
in
356
340
locallyDefinedValues @ valuesFromOpens @ localModuleNames
357
341
| multiple -> (
@@ -404,18 +388,17 @@ let getItems ~full ~package ~rawOpens ~allModules ~pos ~parts =
404
388
(Some (env, typ))
405
389
with
406
390
| None -> []
407
- | Some (env , typ ) -> (
391
+ | Some (_env , typ ) -> (
408
392
match typ.item.kind with
409
393
| Record fields ->
410
394
fields
411
395
|> Utils. filterMap (fun f ->
412
396
if Utils. startsWith f.fname.txt suffix then
413
397
Some
414
- ( env.qFile.uri,
415
- {
416
- (emptyDeclared f.fname.txt) with
417
- item = Field (f, typ);
418
- } )
398
+ {
399
+ (emptyDeclared f.fname.txt) with
400
+ item = Field (f, typ);
401
+ }
419
402
else None )
420
403
| _ -> [] ))))))
421
404
| `AbsAttribute path -> (
@@ -426,13 +409,11 @@ let getItems ~full ~package ~rawOpens ~allModules ~pos ~parts =
426
409
@ List. concat
427
410
(opens |> List. map (fun env -> attributeCompletions ~env ~suffix ))))
428
411
429
- let mkItem ~name ~kind ~detail ~deprecated ~docstring ~ uri ~ pos_lnum =
412
+ let mkItem ~name ~kind ~detail ~deprecated ~docstring =
430
413
let valueMessage =
431
414
(match deprecated with None -> " " | Some s -> " Deprecated: " ^ s ^ " \n\n " )
432
- ^ (match docstring with
433
- | [] -> " "
434
- | _ :: _ -> (docstring |> String. concat " \n " ) ^ " \n\n " )
435
- ^ " \n " ^ Uri2. toString uri ^ " :" ^ string_of_int pos_lnum
415
+ ^
416
+ match docstring with [] -> " " | _ :: _ -> docstring |> String. concat " \n "
436
417
in
437
418
let tags =
438
419
match deprecated = None with true -> [] | false -> [1 (* deprecated *) ]
@@ -446,14 +427,14 @@ let mkItem ~name ~kind ~detail ~deprecated ~docstring ~uri ~pos_lnum =
446
427
documentation = {kind = " markdown" ; value = valueMessage};
447
428
}
448
429
449
- let processCompletable ~findItems ~full ~ package ~ pos ~rawOpens
430
+ let processCompletable ~findItems ~package ~rawOpens
450
431
(completable : PartialParser.completable ) =
451
432
match completable with
452
433
| Cjsx (componentPath , prefix ) ->
453
434
let items = findItems ~exact: true (componentPath @ [" make" ]) in
454
435
let labels =
455
436
match items with
456
- | ( _uri , {SharedTypes. item = Value typ } ) :: _ ->
437
+ | {SharedTypes. item = Value typ } :: _ ->
457
438
let rec getFields (texp : Types.type_expr ) =
458
439
match texp.desc with
459
440
| Tfield (name , _ , t1 , t2 ) ->
@@ -483,7 +464,6 @@ let processCompletable ~findItems ~full ~package ~pos ~rawOpens
483
464
in
484
465
let mkLabel_ name typString =
485
466
mkItem ~name ~kind: 4 ~deprecated: None ~detail: typString ~docstring: []
486
- ~uri: full.file.uri ~pos_lnum: (fst pos)
487
467
in
488
468
let mkLabel (name , typ ) = mkLabel_ name (typ |> Shared. typeToString) in
489
469
let keyLabel = mkLabel_ " key" " string" in
@@ -498,17 +478,9 @@ let processCompletable ~findItems ~full ~package ~pos ~rawOpens
498
478
(* TODO(#107): figure out why we're getting duplicates. *)
499
479
items |> Utils. dedup
500
480
|> List. map
501
- (fun
502
- ( uri ,
503
- {
504
- SharedTypes. name = {txt = name ; loc = {loc_start = {pos_lnum} } } ;
505
- deprecated;
506
- docstring;
507
- item;
508
- } )
509
- ->
481
+ (fun {SharedTypes. name = {txt = name } ; deprecated; docstring; item} ->
510
482
mkItem ~name ~kind: (kindToInt item) ~deprecated
511
- ~detail: (detail name item) ~docstring ~uri ~pos_lnum )
483
+ ~detail: (detail name item) ~docstring )
512
484
| Cpipe (pipe , partialName ) -> (
513
485
let arrayModulePath = [" Js" ; " Array2" ] in
514
486
let listModulePath = [" Belt" ; " List" ] in
@@ -530,7 +502,7 @@ let processCompletable ~findItems ~full ~package ~pos ~rawOpens
530
502
in
531
503
let getLhsPath ~pipeId ~partialName =
532
504
match [pipeId] |> findItems ~exact: true with
533
- | ( _uri , {SharedTypes. item = Value t } ) :: _ ->
505
+ | {SharedTypes. item = Value t } :: _ ->
534
506
let modulePath =
535
507
match t.desc with
536
508
| Tconstr (path , _ , _ ) -> getModulePath path
@@ -586,28 +558,18 @@ let processCompletable ~findItems ~full ~package ~pos ~rawOpens
586
558
let parts = modulePath @ [partialName] in
587
559
let items = parts |> findItems ~exact: false in
588
560
items
589
- |> List. filter (fun ( _ , {item} ) ->
561
+ |> List. filter (fun {item} ->
590
562
match item with Value _ -> true | _ -> false )
591
563
|> List. map
592
- (fun
593
- ( uri ,
594
- {
595
- SharedTypes. name =
596
- {txt = name ; loc = {loc_start = {pos_lnum} } } ;
597
- deprecated;
598
- docstring;
599
- item;
600
- } )
564
+ (fun {SharedTypes. name = {txt = name } ; deprecated; docstring; item}
601
565
->
602
566
mkItem ~name: (completionName name) ~kind: (kindToInt item)
603
- ~detail: (detail name item) ~deprecated ~docstring ~uri
604
- ~pos_lnum )
567
+ ~detail: (detail name item) ~deprecated ~docstring )
605
568
| _ -> [] )
606
569
| None -> [] )
607
570
| Cdecorator prefix ->
608
571
let mkDecorator name =
609
572
mkItem ~name ~kind: 4 ~deprecated: None ~detail: " " ~docstring: []
610
- ~uri: full.file.uri ~pos_lnum: (fst pos)
611
573
in
612
574
[
613
575
" as" ;
@@ -643,7 +605,7 @@ let processCompletable ~findItems ~full ~package ~pos ~rawOpens
643
605
| Clabel (funPath , prefix ) ->
644
606
let labels =
645
607
match funPath |> findItems ~exact: true with
646
- | ( _uri , {SharedTypes. item = Value typ } ) :: _ ->
608
+ | {SharedTypes. item = Value typ } :: _ ->
647
609
let rec getLabels (t : Types.type_expr ) =
648
610
match t.desc with
649
611
| Tlink t1 | Tsubst t1 -> getLabels t1
@@ -658,7 +620,7 @@ let processCompletable ~findItems ~full ~package ~pos ~rawOpens
658
620
let mkLabel (name , typ ) =
659
621
mkItem ~name ~kind: 4 ~deprecated: None
660
622
~detail: (typ |> Shared. typeToString)
661
- ~docstring: [] ~uri: full.file.uri ~pos_lnum: (fst pos)
623
+ ~docstring: []
662
624
in
663
625
labels
664
626
|> List. filter (fun (name , _t ) -> Utils. startsWith name prefix)
@@ -684,10 +646,7 @@ let computeCompletions ~full ~maybeText ~package ~pos =
684
646
in
685
647
match parts |> List. rev with
686
648
| last :: _ when exact ->
687
- items
688
- |> List. filter (fun (_uri , {SharedTypes. name = {txt} } ) ->
689
- txt = last)
649
+ items |> List. filter (fun {SharedTypes. name = {txt} } -> txt = last)
690
650
| _ -> items
691
651
in
692
- completable
693
- |> processCompletable ~find Items ~full ~package ~pos ~raw Opens))
652
+ completable |> processCompletable ~find Items ~package ~raw Opens))
0 commit comments