Skip to content

Commit 3b859f5

Browse files
committed
Make the analysis binary impersonate reanalyze.
e.g. `rescript-editor-analysis.exe reanalyze -dce`
1 parent a325333 commit 3b859f5

File tree

10 files changed

+20
-14
lines changed

10 files changed

+20
-14
lines changed

analysis/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ SHELL = /bin/bash
33
build-native:
44
rm -f rescript-editor-analysis.exe
55
dune build
6-
cp _build/install/default/bin/rescript-editor-analysis.exe rescript-editor-analysis.exe
6+
cp _build/install/default/bin/rescript-editor-analysis rescript-editor-analysis.exe
77

88
dce: build-native
99
opam exec reanalyze.exe -- -dce-cmt _build -suppress vendor

analysis/reanalyze/examples/deadcode/expected/deadcode.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
Scanning AutoAnnotate.cmt Source:AutoAnnotate.res
23
addVariantCaseDeclaration R AutoAnnotate.res:1:15 path:+AutoAnnotate.variant
34
addRecordLabelDeclaration variant AutoAnnotate.res:4:15 path:+AutoAnnotate.record

analysis/reanalyze/examples/deadcode/expected/exception.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
23
Exception Analysis
34
File "Exn.res", line 1, characters 5-11
45
raises might raise Not_found (Exn.res:1:19) and is not annotated with @raises(Not_found)

analysis/reanalyze/examples/deadcode/test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ else
66
exclude_dirs="src/exception"
77
suppress="src/ToSuppress.res"
88
fi
9-
dune exec -- reanalyze -config -debug -ci -exclude-paths $exclude_dirs -live-names globallyLive1 -live-names globallyLive2,globallyLive3 -suppress $suppress > $output
9+
dune exec rescript-editor-analysis -- reanalyze -config -debug -ci -exclude-paths $exclude_dirs -live-names globallyLive1 -live-names globallyLive2,globallyLive3 -suppress $suppress > $output
1010
# CI. We use LF, and the CI OCaml fork prints CRLF. Convert.
1111
if [ "$RUNNER_OS" == "Windows" ]; then
1212
perl -pi -e 's/\r\n/\n/g' -- $output
@@ -18,7 +18,7 @@ if [ "$RUNNER_OS" == "Windows" ]; then
1818
else
1919
unsuppress_dirs="src/exception"
2020
fi
21-
dune exec reanalyze -- -exception -ci -suppress src -unsuppress $unsuppress_dirs > $output
21+
dune exec rescript-editor-analysis -- reanalyze -exception -ci -suppress src -unsuppress $unsuppress_dirs > $output
2222
# CI. We use LF, and the CI OCaml fork prints CRLF. Convert.
2323
if [ "$RUNNER_OS" == "Windows" ]; then
2424
perl -pi -e 's/\r\n/\n/g' -- $output

analysis/reanalyze/examples/termination/expected/termination.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
Scanning TestCyberTruck.cmt Source:TestCyberTruck.res
23

34
Function Table

analysis/reanalyze/examples/termination/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
output="expected/termination.txt"
2-
dune exec reanalyze -- -config -ci -debug > $output
2+
dune exec rescript-editor-analysis -- reanalyze -config -ci -debug > $output
33
# CI. We use LF, and the CI OCaml fork prints CRLF. Convert.
44
if [ "$RUNNER_OS" == "Windows" ]; then
55
perl -pi -e 's/\r\n/\n/g' -- $output

analysis/reanalyze/src/Reanalyze.ml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,3 @@ let cli () =
210210
let cmtRoot = !cmtRootRef in
211211
runAnalysis ~cmtRoot ~ppf
212212
[@@raises exit]
213-
;;
214-
215-
cli () [@@raises exit]

analysis/reanalyze/src/dune

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
(executable
2-
(name Reanalyze)
3-
(public_name reanalyze)
4-
(modes byte exe)
1+
(library
2+
(name reanalyze)
53
(flags
64
(-w "-9")
75
(-open Compilerlibs406)

analysis/src/Cli.ml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ let main () =
8484
| [_; "codeAction"; path; line; col; currentFile] ->
8585
Commands.codeAction ~path ~line:(int_of_string line)
8686
~col:(int_of_string col) ~currentFile
87+
| _ :: "reanalyze" :: _ ->
88+
let len = Array.length Sys.argv in
89+
for i = 1 to len - 2 do
90+
Sys.argv.(i) <- Sys.argv.(i + 1)
91+
done;
92+
Sys.argv.(len - 1) <- "";
93+
Reanalyze.cli ()
8794
| [_; "references"; path; line; col] ->
8895
Commands.references ~path ~line:(int_of_string line)
8996
~col:(int_of_string col)

analysis/src/dune

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
(executable
2-
(public_name rescript-editor-analysis.exe)
2+
(public_name rescript-editor-analysis)
33
(modes byte exe)
44
; The main module that will become the binary.
55
(name Cli)
66
(flags
77
(-w "+26+27+32+33+39")
88
(-open Compilerlibs406)
99
(-open Jsonlib)
10-
(-open Outcomeprinter))
10+
(-open Outcomeprinter)
11+
(-open Reanalyze))
1112
; Depends on:
12-
(libraries unix str compilerlibs406 jsonlib outcomeprinter))
13+
(libraries unix str compilerlibs406 jsonlib outcomeprinter reanalyze))

0 commit comments

Comments
 (0)