-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhance variant constructor payload completion (#946)
* enhance variant constructor payload completion * changelog * fix * fix * fix tests
- Loading branch information
Showing
20 changed files
with
212 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
analysis/tests-generic-jsx-transform/src/GenericJsxCompletion.res
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
// <div | ||
// <div | ||
// ^com | ||
|
||
// <div testing={} | ||
// <div testing={} | ||
// ^com | ||
|
||
module SomeComponent = { | ||
@jsx.component | ||
let make = (~someProp) => { | ||
let someString = "" | ||
let someString = "" | ||
let someInt = 12 | ||
let someArr = [GenericJsx.null] | ||
ignore(someInt) | ||
ignore(someArr) | ||
// someString->st | ||
// ^com | ||
open GenericJsx | ||
open GenericJsx | ||
<div> | ||
{GenericJsx.string(someProp)} | ||
{GenericJsx.string(someProp ++ someString)} | ||
<div> {GenericJsx.null} </div> | ||
// {someString->st} | ||
// ^com | ||
</div> | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
SHELL = /bin/bash | ||
|
||
node_modules/.bin/rescript: | ||
npm install | ||
|
||
build: node_modules/.bin/rescript | ||
node_modules/.bin/rescript > /dev/null || true | ||
|
||
test: build | ||
./test.sh | ||
|
||
clean: | ||
rm -r node_modules lib | ||
|
||
.DEFAULT_GOAL := test | ||
|
||
.PHONY: clean test |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"scripts": { | ||
"build": "rescript", | ||
"clean": "rescript clean -with-deps" | ||
}, | ||
"private": true, | ||
"dependencies": { | ||
"rescript": "11.1.0-rc.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "test-generic-jsx-transform", | ||
"sources": [ | ||
{ | ||
"dir": "src", | ||
"subdirs": true | ||
} | ||
], | ||
"bsc-flags": ["-w -33-44-8"], | ||
"jsx": { "module": "GenericJsx" } | ||
} |
2 changes: 2 additions & 0 deletions
2
analysis/tests-incremental-typechecking/src/ConstructorCompletion__Json.res
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
let x = Js.Json.Array() | ||
// ^com |
6 changes: 6 additions & 0 deletions
6
analysis/tests-incremental-typechecking/src/ConstructorCompletion__Own.res
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module WithVariant = { | ||
type t = One({miss: bool}) | Two(bool) | ||
} | ||
|
||
let x = WithVariant.One() | ||
// ^com |
20 changes: 20 additions & 0 deletions
20
analysis/tests-incremental-typechecking/src/expected/ConstructorCompletion__Json.res.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Complete src/ConstructorCompletion__Json.res 0:22 | ||
posCursor:[0:22] posNoWhite:[0:21] Found expr:[0:8->0:23] | ||
Pexp_construct Js | ||
Json | ||
Array:[0:8->0:21] [0:21->0:23] | ||
Completable: Cexpression CTypeAtPos()->variantPayload::Array($0) | ||
Package opens Pervasives.JsxModules.place holder | ||
Resolved opens 1 pervasives | ||
ContextPath CTypeAtPos() | ||
[{ | ||
"label": "[]", | ||
"kind": 12, | ||
"tags": [], | ||
"detail": "t", | ||
"documentation": null, | ||
"sortText": "A", | ||
"insertText": "[$0]", | ||
"insertTextFormat": 2 | ||
}] | ||
|
19 changes: 19 additions & 0 deletions
19
analysis/tests-incremental-typechecking/src/expected/ConstructorCompletion__Own.res.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Complete src/ConstructorCompletion__Own.res 4:24 | ||
posCursor:[4:24] posNoWhite:[4:23] Found expr:[4:8->4:25] | ||
Pexp_construct WithVariant | ||
One:[4:8->4:23] [4:23->4:25] | ||
Completable: Cexpression CTypeAtPos()->variantPayload::One($0) | ||
Package opens Pervasives.JsxModules.place holder | ||
Resolved opens 1 pervasives | ||
ContextPath CTypeAtPos() | ||
[{ | ||
"label": "{}", | ||
"kind": 4, | ||
"tags": [], | ||
"detail": "Inline record", | ||
"documentation": null, | ||
"sortText": "A", | ||
"insertText": "{$0}", | ||
"insertTextFormat": 2 | ||
}] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
for file in src/*.res; do | ||
output="$(dirname $file)/expected/$(basename $file).txt" | ||
../../rescript-editor-analysis.exe test $file &> $output | ||
# CI. We use LF, and the CI OCaml fork prints CRLF. Convert. | ||
if [ "$RUNNER_OS" == "Windows" ]; then | ||
perl -pi -e 's/\r\n/\n/g' -- $output | ||
fi | ||
done | ||
|
||
warningYellow='\033[0;33m' | ||
successGreen='\033[0;32m' | ||
reset='\033[0m' | ||
|
||
diff=$(git ls-files --modified 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 src/expected | ||
exit 1 | ||
fi |
Oops, something went wrong.