Skip to content

Commit c96a2d2

Browse files
committed
consolidate some of the logic around checking if a file is a res file or not
1 parent 3b4c0a8 commit c96a2d2

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

analysis/src/Files.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,5 @@ let rec collect ?(checkDir = fun _ -> true) path test =
9595
|> List.concat
9696
else []
9797
| _ -> if test path then [path] else []
98+
99+
let isResFile path = exists path && Filename.check_suffix path ".res"

analysis/src/Hint.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ let inlay ~path ~pos ~maxLength ~debug =
8989
Ast_iterator.default_iterator.value_binding iterator vb
9090
in
9191
let iterator = {Ast_iterator.default_iterator with value_binding} in
92-
(if Files.exists path && Filename.check_suffix path ".res" then
92+
(if Files.isResFile path then
9393
let parser =
9494
Res_driver.parsingEngine.parseImplementation ~forPrinter:false
9595
in
@@ -150,7 +150,7 @@ let codeLens ~path ~debug =
150150
let iterator = {Ast_iterator.default_iterator with value_binding} in
151151
(* We only print code lenses in implementation files. This is because they'd be redundant in interface files,
152152
where the definition itself will be the same thing as what would've been printed in the code lens. *)
153-
(if Files.exists path && Filename.check_suffix path ".res" then
153+
(if Files.isResFile path then
154154
let parser =
155155
Res_driver.parsingEngine.parseImplementation ~forPrinter:false
156156
in

analysis/src/SemanticTokens.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ let command ~debug ~emitter ~path =
431431
}
432432
in
433433

434-
if Filename.check_suffix path ".res" then (
434+
if Files.isResFile path then (
435435
let parser =
436436
Res_driver.parsingEngine.parseImplementation ~forPrinter:false
437437
in

analysis/src/Xform.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ let parse ~filename =
302302

303303
let extractCodeActions ~path ~pos ~currentFile ~debug =
304304
match Cmt.fullFromPath ~path with
305-
| Some full when Filename.check_suffix currentFile ".res" ->
305+
| Some full when Files.isResFile currentFile ->
306306
let structure, printExpr, printStructureItem =
307307
parse ~filename:currentFile
308308
in

0 commit comments

Comments
 (0)