@@ -481,25 +481,26 @@ let completionWithParser ~debug ~path ~posCursor ~currentFile ~text =
481
481
match expr.pexp_desc with
482
482
| Pexp_constant _ -> setResult Cnone
483
483
| Pexp_ident lid ->
484
+ let lidPath = flattenLidCheckDot lid in
484
485
if debug then
485
486
Printf. printf " Pexp_ident %s:%s\n "
486
- (Utils. flattenLongIdent lid.txt |> String. concat " ." )
487
+ (lidPath |> String. concat " ." )
487
488
(Loc. toString lid.loc);
488
489
if lid.loc |> Loc. hasPos ~pos: posBeforeCursor then
489
- let path = flattenLidCheckDot lid in
490
- setResult (Cpath (CPId (path, Value )))
490
+ setResult (Cpath (CPId (lidPath, Value )))
491
491
| Pexp_construct (lid , eOpt ) ->
492
+ let lidPath = flattenLidCheckDot lid in
492
493
if debug then
493
494
Printf. printf " Pexp_construct %s:%s %s\n "
494
- (Utils. flattenLongIdent lid.txt |> String. concat " \n " )
495
+ (lidPath |> String. concat " \n " )
495
496
(Loc. toString lid.loc)
496
497
(match eOpt with
497
498
| None -> " None"
498
499
| Some e -> Loc. toString e.pexp_loc);
499
500
if
500
501
eOpt = None && (not lid.loc.loc_ghost)
501
502
&& lid.loc |> Loc. hasPos ~pos: posBeforeCursor
502
- then setResult (Cpath (CPId (flattenLidCheckDot lid , Value )))
503
+ then setResult (Cpath (CPId (lidPath , Value )))
503
504
| Pexp_field (e , fieldName ) -> (
504
505
if debug then
505
506
Printf. printf " Pexp_field %s %s:%s\n " (Loc. toString e.pexp_loc)
@@ -532,11 +533,10 @@ let completionWithParser ~debug ~path ~posCursor ~currentFile ~text =
532
533
| Pexp_apply ({pexp_desc = Pexp_ident compName}, args)
533
534
when Res_parsetree_viewer. isJsxExpression expr ->
534
535
let jsxProps = extractJsxProps ~comp Name ~args in
536
+ let compNamePath = flattenLidCheckDot ~jsx: true compName in
535
537
if debug then
536
538
Printf. printf " JSX <%s:%s %s> _children:%s\n "
537
- (jsxProps.compName.txt
538
- |> Utils. flattenLongIdent ~jsx: true
539
- |> String. concat " ." )
539
+ (compNamePath |> String. concat " ." )
540
540
(Loc. toString compName.loc)
541
541
(jsxProps.props
542
542
|> List. map (fun {name; posStart; posEnd; exp} ->
@@ -553,8 +553,7 @@ let completionWithParser ~debug ~path ~posCursor ~currentFile ~text =
553
553
in
554
554
if jsxCompletable <> None then setResultOpt jsxCompletable
555
555
else if compName.loc |> Loc. hasPos ~pos: posBeforeCursor then
556
- setResult
557
- (Cpath (CPId (flattenLidCheckDot ~jsx: true compName, Module )))
556
+ setResult (Cpath (CPId (compNamePath, Module )))
558
557
| Pexp_apply
559
558
( {pexp_desc = Pexp_ident {txt = Lident " |." }},
560
559
[
@@ -646,38 +645,41 @@ let completionWithParser ~debug ~path ~posCursor ~currentFile ~text =
646
645
(Loc. toString core_type.ptyp_loc);
647
646
match core_type.ptyp_desc with
648
647
| Ptyp_constr (lid , _args ) ->
648
+ let lidPath = flattenLidCheckDot lid in
649
649
if debug then
650
650
Printf. printf " Ptyp_constr %s:%s\n "
651
- (Utils. flattenLongIdent lid.txt |> String. concat " ." )
651
+ (lidPath |> String. concat " ." )
652
652
(Loc. toString lid.loc);
653
653
if lid.loc |> Loc. hasPos ~pos: posBeforeCursor then
654
- setResult (Cpath (CPId (flattenLidCheckDot lid , Type )))
654
+ setResult (Cpath (CPId (lidPath , Type )))
655
655
| _ -> () );
656
656
Ast_iterator. default_iterator.typ iterator core_type
657
657
in
658
658
let module_expr (iterator : Ast_iterator.iterator )
659
659
(me : Parsetree.module_expr ) =
660
660
(match me.pmod_desc with
661
661
| Pmod_ident lid when lid.loc |> Loc. hasPos ~pos: posBeforeCursor ->
662
+ let lidPath = flattenLidCheckDot lid in
662
663
if debug then
663
664
Printf. printf " Pmod_ident %s:%s\n "
664
- (Utils. flattenLongIdent lid.txt |> String. concat " ." )
665
+ (lidPath |> String. concat " ." )
665
666
(Loc. toString lid.loc);
666
667
found := true ;
667
- setResult (Cpath (CPId (flattenLidCheckDot lid , Module )))
668
+ setResult (Cpath (CPId (lidPath , Module )))
668
669
| _ -> () );
669
670
Ast_iterator. default_iterator.module_expr iterator me
670
671
in
671
672
let module_type (iterator : Ast_iterator.iterator )
672
673
(mt : Parsetree.module_type ) =
673
674
(match mt.pmty_desc with
674
675
| Pmty_ident lid when lid.loc |> Loc. hasPos ~pos: posBeforeCursor ->
676
+ let lidPath = flattenLidCheckDot lid in
675
677
if debug then
676
678
Printf. printf " Pmty_ident %s:%s\n "
677
- (Utils. flattenLongIdent lid.txt |> String. concat " ." )
679
+ (lidPath |> String. concat " ." )
678
680
(Loc. toString lid.loc);
679
681
found := true ;
680
- setResult (Cpath (CPId (flattenLidCheckDot lid , Module )))
682
+ setResult (Cpath (CPId (lidPath , Module )))
681
683
| _ -> () );
682
684
Ast_iterator. default_iterator.module_type iterator mt
683
685
in
0 commit comments