Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Multiple cross references with different options(Multiple cross references with different options)
Multiple cross references with different options [message #1481040] Thu, 20 November 2014 18:06 Go to next message
Lynn Lu is currently offline Lynn LuFriend
Messages: 3
Registered: November 2014
Junior Member
Hi,
I met a problem when using cross reference, here is the my rule definitions:

Model:
Struct | Enum
;

Enum:
'enum' name = ID '{'
fields += EnumField*
'}' ';'
;

EnumField:
name = ID ';'
;

Struct:
'struct' name = ID '{'
fields += StructField*
'}' ';'
;

StructField:
ref = [Struct] name = ID opt = StructFieldOpt? ';'
| ref = [Enum] name = ID opt = EnumFieldOpt? ';'
;

StructFieldOpt:
',' 'fixed'
;
EnumFieldOpt:
',' 'default' '=' value = INT
;

My goal is to support the following model. i.e. there are different options available for different cross reference.
enum myEnum {
enumField1;
enumField2;
}
struct myStruct1 {
};
struct myStruct2 {
myEnum theFirstEnum, default = 1;
myStruct1 theFirstStruct, fixed;
};

But the above syntax will not work, because the StructField rule is not valid, it has conflict between these two alternatives.

I can change the StructField as below, 'Model' is the superset of target referenced rule "Struct" and "Enum"
StructField:
ref = [Model] name = ID ....
;
But how can I define my options? can someone help? Thank you
Re: Multiple cross references with different options [message #1481593 is a reply to message #1481040] Fri, 21 November 2014 04:43 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi you have to be syntactically different Or have them generalized as well. You can always write a check to ensure consistency

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Multiple cross references with different options [message #1481683 is a reply to message #1481593] Fri, 21 November 2014 06:26 Go to previous messageGo to next message
Lynn Lu is currently offline Lynn LuFriend
Messages: 3
Registered: November 2014
Junior Member
Hi Christian,

Thank you for your response.
I'm new to this area, what does "check" mean here? validation?

Actually, what i think is to add a validation and customize the content assist as well.
I'm now working on the content assist part, but how can I filter out the unwanted options. e.g. get rid of "EnumFieldOpt" when the "ref" is "Struct"?

I didn't find an answer in eclipse xtext community, do you have an example?

Thanks
Lynn
Re: Multiple cross references with different options [message #1481685 is a reply to message #1481683] Fri, 21 November 2014 06:30 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
yes i mean a validation.

simply have a look at the different methods in the abstract content assist class.
use the debugger. set the breakpoint to CompletionProposalComputer.accept


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Multiple cross references with different options [message #1481690 is a reply to message #1481685] Fri, 21 November 2014 06:34 Go to previous message
Lynn Lu is currently offline Lynn LuFriend
Messages: 3
Registered: November 2014
Junior Member
Oh, that's good, thank you again, I will take a look.

Thanks
Lynn
Previous Topic:OutOfMemory Exception
Next Topic:problem in using another package
Goto Forum:
  


Current Time: Fri Apr 26 16:16:18 GMT 2024

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

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

Back to the top