This repository was archived by the owner on Apr 24, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +24
-44
lines changed Expand file tree Collapse file tree 3 files changed +24
-44
lines changed Original file line number Diff line number Diff line change @@ -25,15 +25,13 @@ let newBsPackage rootPath =
25
25
match FindFiles. findDependencyFiles ~debug: true rootPath config with
26
26
| Error e -> Error e
27
27
| Ok (dependencyDirectories , dependencyModules ) -> (
28
- match
29
- compiledBase
30
- |> RResult. orError
31
- " You need to run bsb first so that rescript-editor-support can \
32
- access the compiled artifacts.\n \
33
- Once you've run bsb, restart the language server."
34
- with
35
- | Error e -> Error e
36
- | Ok compiledBase ->
28
+ match compiledBase with
29
+ | None ->
30
+ Error
31
+ " You need to run bsb first so that rescript-editor-support can \
32
+ access the compiled artifacts.\n \
33
+ Once you've run bsb, restart the language server."
34
+ | Some compiledBase ->
37
35
Ok
38
36
(let namespace = FindFiles. getNamespace config in
39
37
let localSourceDirs =
@@ -118,12 +116,9 @@ let getPackage ~uri state =
118
116
if Hashtbl. mem state.rootForUri uri then
119
117
Ok (Hashtbl. find state.packagesByRoot (Hashtbl. find state.rootForUri uri))
120
118
else
121
- match
122
- findRoot ~uri state.packagesByRoot
123
- |> RResult. orError " No root directory found"
124
- with
125
- | Error e -> Error e
126
- | Ok root -> (
119
+ match findRoot ~uri state.packagesByRoot with
120
+ | None -> Error " No root directory found"
121
+ | Some root -> (
127
122
match
128
123
match root with
129
124
| `Root rootPath ->
Original file line number Diff line number Diff line change 1
- let resultOfOption err v = match v with Some v -> Ok v | None -> Error err
2
-
3
- let orError = resultOfOption
4
-
5
1
let toOptionAndLog err =
6
2
match err with
7
3
| Error e ->
Original file line number Diff line number Diff line change @@ -66,33 +66,22 @@ let definedForLoc ~file ~getModule locKind =
66
66
inner ~file stamp tip
67
67
| GlobalReference (moduleName , path , tip ) ->
68
68
(maybeLog (" Getting global " ^ moduleName);
69
- match
70
- getModule moduleName
71
- |> RResult. orError (" Cannot get module " ^ moduleName)
72
- with
73
- | Error e -> Error e
74
- | Ok file -> (
69
+ match getModule moduleName with
70
+ | None -> Error (" Cannot get module " ^ moduleName)
71
+ | Some file -> (
75
72
let env = Query. fileEnv file in
76
- match
77
- Query. resolvePath ~env ~path ~get Module
78
- |> RResult. orError (" Cannot resolve path " ^ pathToString path)
79
- with
80
- | Error e -> Error e
81
- | Ok (env , name ) -> (
82
- match
83
- Query. exportedForTip ~env name tip
84
- |> RResult. orError
85
- (" Exported not found for tip " ^ name ^ " > " ^ tipToString tip)
86
- with
87
- | Error e -> Error e
88
- | Ok stamp -> (
73
+ match Query. resolvePath ~env ~path ~get Module with
74
+ | None -> Error (" Cannot resolve path " ^ pathToString path)
75
+ | Some (env , name ) -> (
76
+ match Query. exportedForTip ~env name tip with
77
+ | None ->
78
+ Error (" Exported not found for tip " ^ name ^ " > " ^ tipToString tip)
79
+ | Some stamp -> (
89
80
maybeLog (" Getting for " ^ string_of_int stamp ^ " in " ^ name);
90
- match
91
- inner ~file: env.file stamp tip
92
- |> RResult. orError " could not get defined"
93
- with
94
- | Error e -> Error e
95
- | Ok res ->
81
+
82
+ match inner ~file: env.file stamp tip with
83
+ | None -> Error " could not get defined"
84
+ | Some res ->
96
85
maybeLog " Yes!! got it" ;
97
86
Ok res))))
98
87
|> RResult. toOptionAndLog
You can’t perform that action at this time.
0 commit comments