-
Notifications
You must be signed in to change notification settings - Fork 57
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
Complete switch constructor #415
Changes from all commits
1b0b750
bea7472
9d5b17c
e53b51e
88cae89
9d59306
91f20b0
8eb112a
7a9b38a
74c5a7b
73bf47c
8ea472d
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 |
---|---|---|
|
@@ -1030,6 +1030,7 @@ Completable: Cpath Value[SomeLocal] | |
}] | ||
|
||
Complete tests/src/Completion.res 271:20 | ||
posCursor:[271:20] posNoWhite:[271:19] Found pattern:[271:7->274:3] | ||
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. This, and other similar lines indicate that this affects a bit existing test cases, but does not lead to a different outcome. |
||
posCursor:[271:20] posNoWhite:[271:19] Found type:[271:11->274:3] | ||
Ptyp_constr SomeLocal:[271:11->274:3] | ||
Completable: Cpath Type[SomeLocal] | ||
|
@@ -1313,6 +1314,7 @@ posCursor:[336:26] posNoWhite:[336:25] Found expr:[334:13->346:23] | |
posCursor:[336:26] posNoWhite:[336:25] Found expr:[334:13->338:6] | ||
posCursor:[336:26] posNoWhite:[336:25] Found expr:[335:6->338:5] | ||
posCursor:[336:26] posNoWhite:[336:25] Found expr:[336:16->338:5] | ||
posCursor:[336:26] posNoWhite:[336:25] Found pattern:[336:20->338:5] | ||
posCursor:[336:26] posNoWhite:[336:25] Found type:[336:23->338:5] | ||
Ptyp_constr Res:[336:23->338:5] | ||
Completable: Cpath Type[Res] | ||
|
@@ -1381,3 +1383,51 @@ posCursor:[355:23] posNoWhite:[355:22] Found expr:[0:-1->355:23] | |
posCursor:[355:23] posNoWhite:[355:22] Found expr:[355:12->355:23] | ||
[] | ||
|
||
Complete tests/src/Completion.res 362:8 | ||
posCursor:[362:8] posNoWhite:[362:7] Found expr:[360:8->365:3] | ||
posCursor:[362:8] posNoWhite:[362:7] Found expr:[361:2->365:3] | ||
posCursor:[362:8] posNoWhite:[362:7] Found pattern:[362:7->364:5] | ||
posCursor:[362:8] posNoWhite:[362:7] Found pattern:[362:7->362:8] | ||
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. From the location, this could be the pattern |
||
Ppat_construct T:[362:7->362:8] | ||
Completable: Cpath Value[T] | ||
[{ | ||
"label": "That", | ||
"kind": 4, | ||
"tags": [], | ||
"detail": "That\n\ntype v = This | That", | ||
"documentation": null | ||
}, { | ||
"label": "This", | ||
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.
|
||
"kind": 4, | ||
"tags": [], | ||
"detail": "This\n\ntype v = This | That", | ||
"documentation": null | ||
}, { | ||
"label": "TableclothMap", | ||
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. This is a module starting with 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 disagree with this, except in the rare case where the type of the switch variable is not known (because it might be used to disambiguate, as you suggested). That should only happen once, or in many cases never. My understanding is that once the type is known the compiler no longer needs disambiguation to find constructors. At that point seeing all scope modules in the autocomplete list is just noise. I'm about to start looking at how to remove modules from the autocomplete list in this scenario, but now I realise it was intentional... can we discuss whether removing them is a good idea? 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 think you're interested in type contexts, here: #494 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 am, but then I found this PR and it looked like completion in switch statements already included all the valid constructors. 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. This is an ongoing process. Not everything is at the level it could be. |
||
"kind": 9, | ||
"tags": [], | ||
"detail": "file module", | ||
"documentation": null | ||
}, { | ||
"label": "TypeDefinition", | ||
"kind": 9, | ||
"tags": [], | ||
"detail": "file module", | ||
"documentation": null | ||
}] | ||
|
||
Complete tests/src/Completion.res 373:21 | ||
posCursor:[373:21] posNoWhite:[373:20] Found expr:[371:8->376:3] | ||
posCursor:[373:21] posNoWhite:[373:20] Found expr:[372:2->376:3] | ||
posCursor:[373:21] posNoWhite:[373:20] Found pattern:[373:7->375:5] | ||
posCursor:[373:21] posNoWhite:[373:20] Found pattern:[373:7->373:21] | ||
Ppat_construct AndThatOther.T:[373:7->373:21] | ||
Completable: Cpath Value[AndThatOther, T] | ||
[{ | ||
"label": "ThatOther", | ||
"kind": 4, | ||
"tags": [], | ||
"detail": "ThatOther\n\ntype v = And | ThatOther", | ||
"documentation": null | ||
}] | ||
|
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.
Triggering completion as a
Value
. There's no need for specific completions forConstructor
because of the upper case. Lower-case ids are normal values, and upper-case values are constructors.