Skip to content

Commit f3fe0d4

Browse files
committed
change classification strategy to something harder to accidentally skip
1 parent 953698c commit f3fe0d4

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

analysis/src/Files.ml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,9 @@ let rec collect ?(checkDir = fun _ -> true) path test =
9696
else []
9797
| _ -> if test path then [path] else []
9898
99-
let isResFile path = Filename.check_suffix path ".res" && exists path
99+
type classifiedFile = Res | Resi | Other
100+
101+
let classifyFile path =
102+
if Filename.check_suffix path ".res" && exists path then Res
103+
else if Filename.check_suffix path ".resi" && exists path then Resi
104+
else Other

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.isResFile path then
92+
(if Files.classifyFile path = Res 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.isResFile path then
153+
(if Files.classifyFile path = Res 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 Files.isResFile path then (
434+
if Files.classifyFile path = Res 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 Files.isResFile currentFile ->
305+
| Some full when Files.classifyFile currentFile = Res ->
306306
let structure, printExpr, printStructureItem =
307307
parse ~filename:currentFile
308308
in

0 commit comments

Comments
 (0)