@@ -220,11 +220,14 @@ let getEnvWithOpens =
220
220
| Tip (_ ) => None
221
221
| Nested (top , path ) =>
222
222
Log . log("Getting module " ++ top);
223
- let %opt file = getModule(top);
224
- Log . log ("got it" );
225
- let env = Query . fileEnv(file);
226
- Query . resolvePath(~env, ~getModule, ~path)
227
- |> Infix . logIfAbsent("Unable to resolve the path" );
223
+ switch (getModule(top)) {
224
+ | None => None
225
+ | Some (file ) =>
226
+ Log . log("got it" );
227
+ let env = Query . fileEnv(file);
228
+ Query . resolvePath(~env, ~getModule, ~path)
229
+ |> Infix . logIfAbsent("Unable to resolve the path" );
230
+ };
228
231
}
229
232
};
230
233
loop(opens);
@@ -519,44 +522,66 @@ let getItems =
519
522
| [] => None
520
523
| [ first , ... rest ] =>
521
524
Log . log("-------------- Looking for " ++ first);
522
- let %opt declared =
523
- Query . findInScope (pos , first , env .file .stamps .values );
524
- Log . log("Found it! " ++ declared. name. txt);
525
- let %opt path = declared.item |> Shared.digConstructor;
526
- let %opt (env, typ) = Hover.digConstructor(~env, ~getModule, path);
527
- let %opt (env, typ) =
528
- rest
529
- |> List . fold_left (
530
- (current , name ) => {
531
- let%opt (env, typ) = current;
532
- switch (typ.item.SharedTypes.Type.kind) {
533
- | Record(fields) =>
534
- let%opt attr =
535
- fields |> List.find_opt(f => f.fname.txt == name);
536
- Log.log("Found attr " ++ name);
537
- let%opt path = attr.typ |> Shared.digConstructor;
538
- Hover.digConstructor(~env, ~getModule, path);
539
- | _ => None
540
- };
541
- },
542
- Some ((env, typ)),
543
- );
544
- switch (typ. item. kind) {
545
- | Record (fields ) =>
546
- Some (
547
- fields
548
- |> Utils . filterMap(f =>
549
- if (Utils . startsWith(f. fname. txt, suffix)) {
550
- Some ((
551
- env. file. uri,
552
- {... emptyDeclared(f.fname.txt), item: Field (f, typ)},
553
- ));
554
- } else {
555
- None ;
556
- }
557
- ),
558
- )
559
- | _ => None
525
+ switch (Query . findInScope(pos, first, env. file. stamps. values)) {
526
+ | None => None
527
+ | Some (declared ) =>
528
+ Log . log("Found it! " ++ declared. name. txt);
529
+ switch (declared. item |> Shared . digConstructor) {
530
+ | None => None
531
+ | Some (path ) =>
532
+ switch (Hover . digConstructor(~env, ~getModule, path)) {
533
+ | None => None
534
+ | Some ((env , typ )) =>
535
+ switch (
536
+ rest
537
+ |> List . fold_left(
538
+ (current, name) =>
539
+ switch (current) {
540
+ | None => None
541
+ | Some ((env , typ )) =>
542
+ switch (typ. item. SharedTypes . Type . kind) {
543
+ | Record (fields ) =>
544
+ switch (
545
+ fields
546
+ |> List . find_opt(f => f. fname. txt == name)
547
+ ) {
548
+ | None => None
549
+ | Some (attr ) =>
550
+ Log . log("Found attr " ++ name);
551
+ switch (attr. typ |> Shared . digConstructor) {
552
+ | None => None
553
+ | Some (path ) =>
554
+ Hover . digConstructor(~env, ~getModule, path)
555
+ };
556
+ }
557
+ | _ => None
558
+ }
559
+ },
560
+ Some ((env, typ)),
561
+ )
562
+ ) {
563
+ | None => None
564
+ | Some ((env , typ )) =>
565
+ switch (typ. item. kind) {
566
+ | Record (fields ) =>
567
+ Some (
568
+ fields
569
+ |> Utils . filterMap(f =>
570
+ if (Utils . startsWith(f. fname. txt, suffix)) {
571
+ Some ((
572
+ env. file. uri,
573
+ {... emptyDeclared(f.fname.txt), item: Field (f, typ)},
574
+ ));
575
+ } else {
576
+ None ;
577
+ }
578
+ ),
579
+ )
580
+ | _ => None
581
+ }
582
+ }
583
+ }
584
+ };
560
585
};
561
586
};
562
587
}
0 commit comments