-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
[WIP] A working prototype for a suggestions helper #4557
base: dev
Are you sure you want to change the base?
Conversation
Thanks for the making this happen! I played around with the test cases a bit. Here is a test case that does not currently work as I'd expect:
Edit: In a previous version of this comment, I had the expected cases mixed up. |
I made some changes, can you retry ? |
The suggested tokens for the test case look good now! Regarding the single parser context for all suggested tokens, I'm a bit puzzled why that works. Is this really always the case, or is the java grammar maybe deliberately written to avoid ambiguities where different parser contexts could occur? So far, with the java grammar, I did not come up with a test case that demonstrates a clear need for different contexts. I'll have to try either with a toy grammar or with our internal grammar and see what happens there. |
TBH the expected tokens relate to a I'll be replicating the java code to JS/TS so you can play with it in your exact situation. |
Signed-off-by: Eric Vergnaud <[email protected]>
Signed-off-by: Eric Vergnaud <[email protected]>
Signed-off-by: Eric Vergnaud <[email protected]>
@seb314 I've replicated the Java code to JS/TS. Example usage is in runtime/JavaScript/spec/suggestions/SuggestionHelperSpec.js I haven't tried TypeScript. Feel free to yell if it's not working. |
This reverts commit e1e753c.
This reverts commit 0f32816.
Signed-off-by: Eric Vergnaud <[email protected]>
This reverts commit c609a7e.
Signed-off-by: Eric Vergnaud <[email protected]>
Signed-off-by: Eric Vergnaud <[email protected]>
I tried to come up with an example where more than one parser context is consistent with the same input & cursor position: Thanks for the JS version! I'll try that with our real grammar and see if I can find real-world examples. EDIT: updated link to commit with fixed typo in commit message |
Signed-off-by: Eric Vergnaud <[email protected]>
Signed-off-by: Eric Vergnaud <[email protected]>
Signed-off-by: Eric Vergnaud <[email protected]>
Signed-off-by: Eric Vergnaud <[email protected]>
The TS build is broken, but has been for a couple of weeks... I'm looking into it, I don't think it relates to this change |
As long as the js is runnable I'll probably be able to just suppress the tsc warnings for initial testing |
…on-helper Signed-off-by: Eric Vergnaud <[email protected]>
Signed-off-by: Eric Vergnaud <[email protected]>
Signed-off-by: Eric Vergnaud <[email protected]>
It's fixed now |
Signed-off-by: Eric Vergnaud <[email protected]>
I mean now 🤣 (previous commit undid all the changes ...) |
I've now tried the js version with our regular test cases a bit. The suggested tokens look mostly good already (modulo a few unwanted suggestions that look like they are plausibly due to the different handling of semantic predicates. Those could probably be filtered out individually, if necessary). What I'm not sure about at the moment: |
so you'd want to associate each suggested token with the resulting context if that token were appended ? What might be possible is to provide the rule that the parser would enter. That's something the parser knows of without instantiating anything. |
@ericvergnaud thanks for the clarification! I'll try the approach with separate parsing and then report back (might take a couple of days until I have time to test this) (Knowing the rule instead of the context should be sufficient to classify the suggestions. I'm not sure yet if it would also be sufficient for finding out the corresponding range of the input that gets replaced if the user accepts the corresponding suggestion, but maybe there is a way) |
This is an (experimental at this point) implementation of a generic suggestions helper.
Given a parsed input and a caret position, it returns a leaf context and expected tokens.
The intent is to make this available in Java and Typescript to start with.
Other implementations may follow if there is demand.