Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Content assist behaves differently with similar grammar definition
Content assist behaves differently with similar grammar definition [message #560144] Tue, 21 September 2010 10:49 Go to next message
Sébastien  Gandon is currently offline Sébastien GandonFriend
Messages: 184
Registered: July 2009
Senior Member
Hello,
Sorry for being vague in the title but I did not know how to express my problem.
Here is the example with the grammar.
when I write this :
----------------------------XText grammar
MetadataType returns tFile::MetadataType:
'addSchema'
'{'
('TYPE:' ((connector='FLOW') | (connector='REJECT') | (connector='ONSUBJOBOK')))?
.....
----------------------------end of XText grammar

the content assist propose the different alternatives for the TYPE values.

but if I create a new rule like this:
----------------------------XText grammar
MetadataType returns tFile::MetadataType:
'addSchema'
'{'
('TYPE:' connector=MetadataTypeTypes)?
.....

MetadataTypeTypes returns ecore::EString:
'FLOW'| 'REJECT' | 'ONSUBJOBOK' ;
---------------------------end of XText grammar
the content assist does not propose anything at all, and I prefer the defiition because when many attributes use the same rules you do not have to copy and paste.

I must also say that I cannot use enum for this.

Anyone as an idea on how to solve the pb ?

Thanks.
Re: Content assist behaves differently with similar grammar definition [message #560153 is a reply to message #560144] Tue, 21 September 2010 11:16 Go to previous messageGo to next message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

in the first case you get automatic proposal for a keyword - in the second case you define a DataType rule. You have to overwrite the proposal rule (that may be empty) in your proposal provider and return the values you want to propose.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Content assist behaves differently with similar grammar definition [message #560164 is a reply to message #560153] Tue, 21 September 2010 12:17 Go to previous messageGo to next message
Sébastien  Gandon is currently offline Sébastien GandonFriend
Messages: 184
Registered: July 2009
Senior Member
thanks for the answer but I was expecting some other way of doing this, because what your are saying is that I should override the proposal provider for the Data type and return the values but the grammar already defines the value and the point is not to duplicate anything.

I was expecting one single place where you define the alternatives and ideally in the grammar definition.
Re: Content assist behaves differently with similar grammar definition [message #560166 is a reply to message #560164] Tue, 21 September 2010 12:22 Go to previous messageGo to next message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

then don't use a datatype rule Wink but a parser or enum rule.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Tue, 21 September 2010 12:23]

Report message to a moderator

Re: Content assist behaves differently with similar grammar definition [message #560182 is a reply to message #560164] Tue, 21 September 2010 12:49 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi,

feel free to use an enum rule to describe your types.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 21.09.10 14:17, schrieb seb.fr:
> thanks for the answer but I was expecting some other way of doing this,
> because what your are saying is that I should override the proposal
> provider for the Data type and return the values but the grammar already
> defines the value and the point is not to duplicate anything.
>
> I was expecting one single place where you define the alternatives and
> ideally in the grammar definition.
>
Re: Content assist behaves differently with similar grammar definition [message #560209 is a reply to message #560182] Tue, 21 September 2010 15:03 Go to previous messageGo to next message
Sébastien  Gandon is currently offline Sébastien GandonFriend
Messages: 184
Registered: July 2009
Senior Member
As I mentionned in my original post, I cannot use enums because I am creating model element of existing EMF model that do not have enum definition for this.
The attribute that I need to set is of type String and I cannot change it.

Christian, you mentionned parser rules, but I do not know what you meant but that. I have tried terminal rules :

terminal MetadataTypeType : 'FLOW' | 'REJECT' | 'ONSUBJOBOK' ;
with no luck
and this rule (i do not know the name)

MetadataTypeType : 'FLOW' | 'REJECT' | 'ONSUBJOBOK';
with no luck either.

Any more thoughts?
Re: Content assist behaves differently with similar grammar definition [message #560218 is a reply to message #560209] Tue, 21 September 2010 15:14 Go to previous message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

if you have an existing metamodel with an EString EAttribute you are stuck to a DataType / terminal rule and have to customize content assist.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Tue, 21 September 2010 15:15]

Report message to a moderator

Previous Topic:Performance issues when using actions in expressions
Next Topic:EMF cannot deal with XMI version 1.1 in generated MyDsl.xmi - since Xtext 1.0.1
Goto Forum:
  


Current Time: Thu Apr 25 16:38:23 GMT 2024

Powered by FUDForum. Page generated in 0.03510 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top