-
Notifications
You must be signed in to change notification settings - Fork 59
Explore type based autocomplete #493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
7db9012
4362bdf
87508b3
5ed8bb4
d121e73
57e7cce
b125207
431ab48
bdd2e11
bea78fe
5ebe602
b85c4ae
dd8333e
ffa06f4
37e4f9b
c2e2adf
d1d86e8
90ccf19
d54b562
2b29291
27532b0
e87ad5a
f79a38d
b260d38
54e596c
8c49fa5
c8f112a
49e45d8
7c8a1ad
b34c35d
7b1b8cd
f79f21b
0df2b0c
33cd645
f21a06e
44698e4
48b7bec
295be6b
5a2097e
da23ca8
39a35ec
f9515d1
a268d24
9f511cd
ef427d2
555110f
cf8b472
3a6a6e5
339417c
928e84e
d134b8b
0d06fc6
d2ef230
013680e
303eb57
858be8f
d5ced33
1679769
f262a50
28dddca
8a98793
5647a1e
2c1b721
5d69adb
f061119
82796f9
6a0a884
f98db04
5558995
5320d9e
36832cc
eb3eb80
859c3fd
e67f63c
64f4f77
40e3ec1
e330b68
fc48ca8
cd2161a
0522d01
16a6f0f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
type someVariant = One | Two | Three | Four | ||
|
||
let someVariantToString = (~someVariant) => | ||
switch someVariant { | ||
| One => "One" | ||
| Two => "Two" | ||
| Three => "Three" | ||
| Four => "Four" | ||
} | ||
|
||
module SomeComponent = { | ||
@react.component | ||
let make = (~whatever) => { | ||
someVariantToString(~someVariant=whatever)->React.string | ||
} | ||
} | ||
|
||
// let x = someVariantToString(~someVaria | ||
// ^com | ||
|
||
// let x = someVariantToString(~someVariant= | ||
// ^com | ||
|
||
// let x = someVariantToString(~someVariant= | ||
// ^com | ||
|
||
// let x = someVariantToString(~someVariant=T | ||
// ^com | ||
|
||
// let x = someVariantToString(~someVariant=t | ||
// ^com | ||
|
||
// let jsx = <SomeComponent whatever= | ||
// ^com |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
DCE src/Dce.res | ||
issues:235 | ||
issues:241 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I should get rid of these differences. This is testing several things at once and it's not necessary. |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
Complete src/TypeContextCompletion.res 17:41 | ||
posCursor:[17:41] posNoWhite:[17:40] Found expr:[17:11->17:41] | ||
Pexp_apply ...[17:11->17:30] (~someVaria17:32->17:41=...[17:32->17:41]) | ||
Completable: CnamedArg(Value[someVariantToString], someVaria, [someVaria]) | ||
Found type for function (~someVariant: someVariant) => string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to check where this is coming from: presumably named arg completion finding the type of the function. |
||
[{ | ||
"label": "someVariant", | ||
"kind": 4, | ||
"tags": [], | ||
"detail": "someVariant", | ||
"documentation": null | ||
}] | ||
|
||
Complete src/TypeContextCompletion.res 20:44 | ||
posCursor:[20:44] posNoWhite:[20:43] Found expr:[20:11->20:44] | ||
Pexp_apply ...[20:11->20:30] (~someVariant20:32->20:43=...__ghost__[0:-1->0:-1]) | ||
found typed context | ||
Completable: CtypedContext(Value[someVariantToString]) | ||
[] | ||
|
||
Complete src/TypeContextCompletion.res 23:45 | ||
posCursor:[23:45] posNoWhite:[23:43] Found expr:[23:11->23:44] | ||
Pexp_apply ...[23:11->23:30] (~someVariant23:32->23:43=...__ghost__[0:-1->0:-1]) | ||
found typed context | ||
Completable: CtypedContext(Value[someVariantToString]) | ||
[] | ||
|
||
Complete src/TypeContextCompletion.res 26:45 | ||
posCursor:[26:45] posNoWhite:[26:44] Found expr:[26:11->26:45] | ||
Pexp_apply ...[26:11->26:30] (~someVariant26:32->26:43=...[26:44->26:45]) | ||
found typed context | ||
Completable: CtypedContext(Value[someVariantToString]) | ||
[] | ||
|
||
Complete src/TypeContextCompletion.res 29:45 | ||
posCursor:[29:45] posNoWhite:[29:44] Found expr:[29:11->29:45] | ||
Pexp_apply ...[29:11->29:30] (~someVariant29:32->29:43=...[29:44->29:45]) | ||
found typed context | ||
Completable: CtypedContext(Value[someVariantToString]) | ||
[] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As predicted, no result. |
||
|
||
Complete src/TypeContextCompletion.res 32:37 | ||
posCursor:[32:37] posNoWhite:[32:36] Found expr:[32:14->32:37] | ||
JSX <SomeComponent:[32:14->32:27] whatever[32:28->32:36]=...__ghost__[0:-1->0:-1]> _children:None | ||
[] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you start adding comments to Cpath and contextPath?
There's the question of whether there should be an entirely different case of type t, or whether typed context info should be integrated into the existing ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind helping me out with adding comments to those that exist already? I have a hard time parsing what they are/mean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cpath
is for complex expressionsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CPString
is for string constants, used in pipe expressions34 -> ...
CPArray
is for arrays used in pipe expressions[] -> ....
CPApply of contextPath * Asttypes.arg_label list
is application with a list of labelsCPId of string list * completionContext
is for a pathA.
orA.B.C.
and the rhs is the rest to be completedCPField of contextPath * string
is the.z
of record accessexpr.z
CPObj of contextPath * string
is the["hello"]
of object accessexpr["hello"]
CPPipe of contextPath * string
isexpr->foo
wherefoo
is the function whose first argument isexpr
.