Content Assist Context [message #1698589] |
Tue, 16 June 2015 10:34  |
Eclipse User |
|
|
|
Hi guys,
I was checking the following slides from RepreZen
https://www.eclipsecon.org/na2015/sites/default/files/slides/RepreZen%20DSL%20Xtext%20Day%20(EclipseCon%20Website).pdf
And in the slide 63, they mentioned "hardcore code creating contexts", so I wanted to ask you if there is a recommendation to create custom content assist context or if it is considered a bad practice
For instance I have this grammar
MultipleKeyValuePairObj:
{MultipleKeyValuePairObj} "{" (elements+=ObjectElement ("," elements+=ObjectElement?)*)? "}";
I want to add some logic to emit comma no matter if the line ends with comma or not in order to add one additional content assist context to use my proposal providers with a valid model
Example:
Case 1
{
field1: @CursosHere@, // In this case the autocomplete works great
field2: data
}
Case 2
{
field1: @CursosHere@ // In this case the autocomplete does not work because there is not comma to split the fields
field2: data
}
My question is regarding how to enhance the content assist, I can try to create custom content assist context (Meaning in certain situations I can emit extra commas to simulate a well defined grammar)
Another option is to mark commas as optional and then add some validation
If you believe this is the best way to go: Do you know how can I validate the existence of comma? I can use NodeModelUtils but it seems to me it can be a little expensive so it should be another way.
Best regards,
Luis
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04050 seconds