From 724c6e7225f5c0e0c1fa9df7089fe53cc29291a4 Mon Sep 17 00:00:00 2001 From: Cheng Lou Date: Tue, 27 Apr 2021 22:32:40 -0700 Subject: [PATCH 01/14] Reactivate CI `make test` for windows --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6aa9230a4..f26704195 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: artifact-folder: linux - os: windows-latest # CI windows running the binary somehow stucks. Not sure why. Disable for now. - build: "cd analysis && & $env:CYGWIN_ROOT\\bin\\ocaml-env exec -- make" + build: "cd analysis && & $env:CYGWIN_ROOT\\bin\\ocaml-env exec -- make test" artifact-folder: win32 runs-on: ${{matrix.os}} From 334efa5b0557eeb5be30e698ed2ab925c43893f7 Mon Sep 17 00:00:00 2001 From: Cheng Lou Date: Tue, 27 Apr 2021 22:38:18 -0700 Subject: [PATCH 02/14] Use dos2unix --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f26704195..c011de40e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: artifact-folder: linux - os: windows-latest # CI windows running the binary somehow stucks. Not sure why. Disable for now. - build: "cd analysis && & $env:CYGWIN_ROOT\\bin\\ocaml-env exec -- make test" + build: "cd analysis && dos2unix test.sh && & $env:CYGWIN_ROOT\\bin\\ocaml-env exec -- make test" artifact-folder: win32 runs-on: ${{matrix.os}} From b024492aa5580cbde5129db7a5acad0cb1e7e825 Mon Sep 17 00:00:00 2001 From: Cheng Lou Date: Tue, 27 Apr 2021 22:56:57 -0700 Subject: [PATCH 03/14] debug hover --- analysis/src/Commands.ml | 4 ++-- analysis/src/Protocol.ml | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/analysis/src/Commands.ml b/analysis/src/Commands.ml index 40dbac7d3..1d9951a3c 100644 --- a/analysis/src/Commands.ml +++ b/analysis/src/Commands.ml @@ -71,11 +71,11 @@ let hover ~file ~line ~col ~extra ~package = (* Skip if range is all zero, unless it's a module *) (not isModule) && posIsZero loc.loc_start && posIsZero loc.loc_end in - if skipZero then Protocol.null + if skipZero then Protocol.null2 else let hoverText = Hover.newHover ~file ~package locItem in match hoverText with - | None -> Protocol.null + | None -> Protocol.null3 | Some s -> Protocol.stringifyHover {contents = s}) let hover ~path ~line ~col = diff --git a/analysis/src/Protocol.ml b/analysis/src/Protocol.ml index 021ca46b7..ca0adfa46 100644 --- a/analysis/src/Protocol.ml +++ b/analysis/src/Protocol.ml @@ -19,6 +19,8 @@ type location = {uri : string; range : range} type documentSymbolItem = {name : string; kind : int; location : location} let null = "null" +let null2 = "null2" +let null3 = "null3" let array l = "[" ^ String.concat ", " l ^ "]" From ac8cb8055af2870cc97b7ec92d701566eb908a5c Mon Sep 17 00:00:00 2001 From: Cheng Lou Date: Tue, 27 Apr 2021 23:18:42 -0700 Subject: [PATCH 04/14] null -> null1 --- analysis/src/Commands.ml | 2 +- analysis/src/Protocol.ml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/analysis/src/Commands.ml b/analysis/src/Commands.ml index 1d9951a3c..db1308fea 100644 --- a/analysis/src/Commands.ml +++ b/analysis/src/Commands.ml @@ -52,7 +52,7 @@ let completion ~path ~line ~col ~currentFile = let hover ~file ~line ~col ~extra ~package = let pos = Utils.protocolLineColToCmtLoc ~line ~col in match References.locItemForPos ~extra pos with - | None -> Protocol.null + | None -> Protocol.null1 | Some locItem -> ( let isModule = match locItem.locType with diff --git a/analysis/src/Protocol.ml b/analysis/src/Protocol.ml index ca0adfa46..d5c253144 100644 --- a/analysis/src/Protocol.ml +++ b/analysis/src/Protocol.ml @@ -19,6 +19,7 @@ type location = {uri : string; range : range} type documentSymbolItem = {name : string; kind : int; location : location} let null = "null" +let null1 = "null1" let null2 = "null2" let null3 = "null3" From ddb553f9b5e7df915159a148d9ea8d8a5efc8ed6 Mon Sep 17 00:00:00 2001 From: Cheng Lou Date: Tue, 27 Apr 2021 23:20:21 -0700 Subject: [PATCH 05/14] What about trying hover directly instead of test --- analysis/test.sh | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/analysis/test.sh b/analysis/test.sh index 6ba881f21..7fbcb5623 100755 --- a/analysis/test.sh +++ b/analysis/test.sh @@ -1,20 +1,22 @@ -function exp { - echo "$(dirname $1)/expected/$(basename $1).txt" -} +# function exp { +# echo "$(dirname $1)/expected/$(basename $1).txt" +# } -for file in tests/src/*.{res,resi}; do - ./rescript-editor-analysis.exe test $file &> $(exp $file) -done +# for file in tests/src/*.{res,resi}; do +# ./rescript-editor-analysis.exe test $file &> $(exp $file) +# done -warningYellow='\033[0;33m' -successGreen='\033[0;32m' -reset='\033[0m' +# warningYellow='\033[0;33m' +# successGreen='\033[0;32m' +# reset='\033[0m' -diff=$(git ls-files --modified tests/src/expected) -if [[ $diff = "" ]]; then - printf "${successGreen}✅ No unstaged tests difference.${reset}\n" -else - printf "${warningYellow}⚠️ There are unstaged differences in tests/! Did you break a test?\n${diff}\n${reset}" - git --no-pager diff tests/src/expected - exit 1 -fi +# diff=$(git ls-files --modified tests/src/expected) +# if [[ $diff = "" ]]; then +# printf "${successGreen}✅ No unstaged tests difference.${reset}\n" +# else +# printf "${warningYellow}⚠️ There are unstaged differences in tests/! Did you break a test?\n${diff}\n${reset}" +# git --no-pager diff tests/src/expected +# exit 1 +# fi + +./rescript-editor-analysis.exe hover tests/src/Auto.res 2 15 From cfe849201989b0ddb9dc2f5f5ff00339b942651e Mon Sep 17 00:00:00 2001 From: Cheng Lou Date: Tue, 27 Apr 2021 23:29:06 -0700 Subject: [PATCH 06/14] print some stuff --- analysis/src/Commands.ml | 4 ++++ analysis/src/References.ml | 2 ++ 2 files changed, 6 insertions(+) diff --git a/analysis/src/Commands.ml b/analysis/src/Commands.ml index db1308fea..9a74210b3 100644 --- a/analysis/src/Commands.ml +++ b/analysis/src/Commands.ml @@ -51,6 +51,10 @@ let completion ~path ~line ~col ~currentFile = let hover ~file ~line ~col ~extra ~package = let pos = Utils.protocolLineColToCmtLoc ~line ~col in + print_endline "Commands.hover pos:"; + let (a, b) = pos in + print_endline (string_of_int a); + print_endline (string_of_int b); match References.locItemForPos ~extra pos with | None -> Protocol.null1 | Some locItem -> ( diff --git a/analysis/src/References.ml b/analysis/src/References.ml index a92bdd6ac..c010881b3 100644 --- a/analysis/src/References.ml +++ b/analysis/src/References.ml @@ -15,6 +15,8 @@ let checkPos (line, char) else true let locItemsForPos ~extra pos = + print_endline "References.locItemsForPos extra.locItems length:"; + print_endline (string_of_int (List.length extra.locItems)); extra.locItems |> List.filter (fun {loc; locType = _} -> checkPos pos loc) let locItemForPos ~extra pos = From fb134803656e8ea1c1f0184fc2f23054587a6d14 Mon Sep 17 00:00:00 2001 From: Cheng Lou Date: Tue, 27 Apr 2021 23:32:13 -0700 Subject: [PATCH 07/14] print loc --- analysis/src/References.ml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/analysis/src/References.ml b/analysis/src/References.ml index c010881b3..34039ce5e 100644 --- a/analysis/src/References.ml +++ b/analysis/src/References.ml @@ -6,6 +6,14 @@ let maybeLog m = if !debugReferences then Log.log ("[ref] " ^ m) let checkPos (line, char) {Location.loc_start = {pos_lnum; pos_bol; pos_cnum}; loc_end} = + print_endline "References.checkPos loc_start pos_lnum, pos_bol, pos_cnum:"; + print_endline (string_of_int pos_lnum); + print_endline (string_of_int pos_bol); + print_endline (string_of_int pos_cnum); + print_endline "References.checkPos loc_end pos_lnum, pos_bol, pos_cnum:"; + print_endline (string_of_int loc_end.pos_lnum); + print_endline (string_of_int loc_end.pos_bol); + print_endline (string_of_int loc_end.pos_cnum); if line < pos_lnum || (line = pos_lnum && char < pos_cnum - pos_bol) then false else if From dac3988c00b93aeb60ffcf3ae282f632608ef2b6 Mon Sep 17 00:00:00 2001 From: Cheng Lou Date: Wed, 28 Apr 2021 00:07:14 -0700 Subject: [PATCH 08/14] dos2unix Auto.res --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c011de40e..64a80e8f1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: artifact-folder: linux - os: windows-latest # CI windows running the binary somehow stucks. Not sure why. Disable for now. - build: "cd analysis && dos2unix test.sh && & $env:CYGWIN_ROOT\\bin\\ocaml-env exec -- make test" + build: "cd analysis && dos2unix test.sh && dos2unix tests/src/Auto.res && & $env:CYGWIN_ROOT\\bin\\ocaml-env exec -- make test" artifact-folder: win32 runs-on: ${{matrix.os}} From 0986a9718dcfe83ae8a85c3826fa17f1fe00b217 Mon Sep 17 00:00:00 2001 From: Cheng Lou Date: Wed, 28 Apr 2021 00:18:08 -0700 Subject: [PATCH 09/14] dos2unix all --- .github/workflows/ci.yml | 5 ++++- analysis/test.sh | 36 +++++++++++++++++------------------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 64a80e8f1..61847f07d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,10 @@ jobs: artifact-folder: linux - os: windows-latest # CI windows running the binary somehow stucks. Not sure why. Disable for now. - build: "cd analysis && dos2unix test.sh && dos2unix tests/src/Auto.res && & $env:CYGWIN_ROOT\\bin\\ocaml-env exec -- make test" + build: | + cd analysis + dos2unix test.sh tests/src/*.res tests/src/*.resi + "& $env:CYGWIN_ROOT\\bin\\ocaml-env exec -- make test" artifact-folder: win32 runs-on: ${{matrix.os}} diff --git a/analysis/test.sh b/analysis/test.sh index 7fbcb5623..6ba881f21 100755 --- a/analysis/test.sh +++ b/analysis/test.sh @@ -1,22 +1,20 @@ -# function exp { -# echo "$(dirname $1)/expected/$(basename $1).txt" -# } +function exp { + echo "$(dirname $1)/expected/$(basename $1).txt" +} -# for file in tests/src/*.{res,resi}; do -# ./rescript-editor-analysis.exe test $file &> $(exp $file) -# done +for file in tests/src/*.{res,resi}; do + ./rescript-editor-analysis.exe test $file &> $(exp $file) +done -# warningYellow='\033[0;33m' -# successGreen='\033[0;32m' -# reset='\033[0m' +warningYellow='\033[0;33m' +successGreen='\033[0;32m' +reset='\033[0m' -# diff=$(git ls-files --modified tests/src/expected) -# if [[ $diff = "" ]]; then -# printf "${successGreen}✅ No unstaged tests difference.${reset}\n" -# else -# printf "${warningYellow}⚠️ There are unstaged differences in tests/! Did you break a test?\n${diff}\n${reset}" -# git --no-pager diff tests/src/expected -# exit 1 -# fi - -./rescript-editor-analysis.exe hover tests/src/Auto.res 2 15 +diff=$(git ls-files --modified tests/src/expected) +if [[ $diff = "" ]]; then + printf "${successGreen}✅ No unstaged tests difference.${reset}\n" +else + printf "${warningYellow}⚠️ There are unstaged differences in tests/! Did you break a test?\n${diff}\n${reset}" + git --no-pager diff tests/src/expected + exit 1 +fi From 4a065e3abff4e70f21f943d69b72c4dc777e7465 Mon Sep 17 00:00:00 2001 From: Cheng Lou Date: Wed, 28 Apr 2021 00:29:44 -0700 Subject: [PATCH 10/14] Remove prints --- analysis/src/Commands.ml | 10 +++------- analysis/src/Protocol.ml | 3 --- analysis/src/References.ml | 10 ---------- 3 files changed, 3 insertions(+), 20 deletions(-) diff --git a/analysis/src/Commands.ml b/analysis/src/Commands.ml index 9a74210b3..40dbac7d3 100644 --- a/analysis/src/Commands.ml +++ b/analysis/src/Commands.ml @@ -51,12 +51,8 @@ let completion ~path ~line ~col ~currentFile = let hover ~file ~line ~col ~extra ~package = let pos = Utils.protocolLineColToCmtLoc ~line ~col in - print_endline "Commands.hover pos:"; - let (a, b) = pos in - print_endline (string_of_int a); - print_endline (string_of_int b); match References.locItemForPos ~extra pos with - | None -> Protocol.null1 + | None -> Protocol.null | Some locItem -> ( let isModule = match locItem.locType with @@ -75,11 +71,11 @@ let hover ~file ~line ~col ~extra ~package = (* Skip if range is all zero, unless it's a module *) (not isModule) && posIsZero loc.loc_start && posIsZero loc.loc_end in - if skipZero then Protocol.null2 + if skipZero then Protocol.null else let hoverText = Hover.newHover ~file ~package locItem in match hoverText with - | None -> Protocol.null3 + | None -> Protocol.null | Some s -> Protocol.stringifyHover {contents = s}) let hover ~path ~line ~col = diff --git a/analysis/src/Protocol.ml b/analysis/src/Protocol.ml index d5c253144..021ca46b7 100644 --- a/analysis/src/Protocol.ml +++ b/analysis/src/Protocol.ml @@ -19,9 +19,6 @@ type location = {uri : string; range : range} type documentSymbolItem = {name : string; kind : int; location : location} let null = "null" -let null1 = "null1" -let null2 = "null2" -let null3 = "null3" let array l = "[" ^ String.concat ", " l ^ "]" diff --git a/analysis/src/References.ml b/analysis/src/References.ml index 34039ce5e..a92bdd6ac 100644 --- a/analysis/src/References.ml +++ b/analysis/src/References.ml @@ -6,14 +6,6 @@ let maybeLog m = if !debugReferences then Log.log ("[ref] " ^ m) let checkPos (line, char) {Location.loc_start = {pos_lnum; pos_bol; pos_cnum}; loc_end} = - print_endline "References.checkPos loc_start pos_lnum, pos_bol, pos_cnum:"; - print_endline (string_of_int pos_lnum); - print_endline (string_of_int pos_bol); - print_endline (string_of_int pos_cnum); - print_endline "References.checkPos loc_end pos_lnum, pos_bol, pos_cnum:"; - print_endline (string_of_int loc_end.pos_lnum); - print_endline (string_of_int loc_end.pos_bol); - print_endline (string_of_int loc_end.pos_cnum); if line < pos_lnum || (line = pos_lnum && char < pos_cnum - pos_bol) then false else if @@ -23,8 +15,6 @@ let checkPos (line, char) else true let locItemsForPos ~extra pos = - print_endline "References.locItemsForPos extra.locItems length:"; - print_endline (string_of_int (List.length extra.locItems)); extra.locItems |> List.filter (fun {loc; locType = _} -> checkPos pos loc) let locItemForPos ~extra pos = From 57fe422b91fda064dfdf81a0d24f48c48a37c6eb Mon Sep 17 00:00:00 2001 From: Cheng Lou Date: Wed, 28 Apr 2021 00:37:37 -0700 Subject: [PATCH 11/14] Just make --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 61847f07d..e9e09bfca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: build: | cd analysis dos2unix test.sh tests/src/*.res tests/src/*.resi - "& $env:CYGWIN_ROOT\\bin\\ocaml-env exec -- make test" + "& $env:CYGWIN_ROOT\\bin\\ocaml-env exec -- make" artifact-folder: win32 runs-on: ${{matrix.os}} From 3128450e6b3cc743215545f8dacd736b6aa4f5c8 Mon Sep 17 00:00:00 2001 From: Cheng Lou Date: Wed, 28 Apr 2021 00:42:45 -0700 Subject: [PATCH 12/14] Single line --- .github/workflows/ci.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e9e09bfca..a2897d510 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,10 +23,7 @@ jobs: artifact-folder: linux - os: windows-latest # CI windows running the binary somehow stucks. Not sure why. Disable for now. - build: | - cd analysis - dos2unix test.sh tests/src/*.res tests/src/*.resi - "& $env:CYGWIN_ROOT\\bin\\ocaml-env exec -- make" + build: "cd analysis && dos2unix test.sh tests/src/*.res tests/src/*.resi && & $env:CYGWIN_ROOT\\bin\\ocaml-env exec -- make" artifact-folder: win32 runs-on: ${{matrix.os}} From ea865f3b9533eee77b655c28e8c8c686f643bd4d Mon Sep 17 00:00:00 2001 From: Cheng Lou Date: Wed, 28 Apr 2021 00:48:32 -0700 Subject: [PATCH 13/14] Try multiline again? --- .github/workflows/ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a2897d510..0f68b01f8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,10 @@ jobs: artifact-folder: linux - os: windows-latest # CI windows running the binary somehow stucks. Not sure why. Disable for now. - build: "cd analysis && dos2unix test.sh tests/src/*.res tests/src/*.resi && & $env:CYGWIN_ROOT\\bin\\ocaml-env exec -- make" + build: | + cd analysis + dos2unix test.sh tests/src/*.res tests/src/*.resi + & $env:CYGWIN_ROOT\\bin\\ocaml-env exec -- make artifact-folder: win32 runs-on: ${{matrix.os}} From b12d34dd4df045fc22e441ebf1b602278c86a5f6 Mon Sep 17 00:00:00 2001 From: Cheng Lou Date: Wed, 28 Apr 2021 00:54:39 -0700 Subject: [PATCH 14/14] Add comment --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0f68b01f8..1fd04799f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,9 +22,9 @@ jobs: build: eval $(opam env) && cd analysis && make test artifact-folder: linux - os: windows-latest - # CI windows running the binary somehow stucks. Not sure why. Disable for now. build: | cd analysis + # git checkout converted these to windows newline. Convert back to unix newline here dos2unix test.sh tests/src/*.res tests/src/*.resi & $env:CYGWIN_ROOT\\bin\\ocaml-env exec -- make artifact-folder: win32