Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Content assist - how to use CA dependent on a previous assignment(CA dependent on a previous assignment)
Content assist - how to use CA dependent on a previous assignment [message #1059328] Fri, 17 May 2013 14:12 Go to next message
Edwin Tuzar is currently offline Edwin TuzarFriend
Messages: 33
Registered: April 2013
Location: Kaiserslautern
Member

Hello everyone,
I have two questions for you guys.
1. How can I use the CA(content assistant) to be dependent on a previous variable
example:
rule: keyword "id" "text"

For "id" I already have a CA with some suggestions, lets say that they are: "id", "id2"
Now I want for the "text" based on id field to be different. So if I have "id" the CA should show: "text", "text1" and when I have "id2" I will like to have "red" "blue"
Is this possible?

2.If I have a rule X that I'm using it in two places, can I make the CA customizable based on the place where it is used?
example:
rule Y
x= rule X
rule Z
x= rule X
Now I want when I'm using the X in the editor under Z the CA to show me some suggestions "have a nice day", "thanks"
and when I use X under Y to show me "it's summer in Germany"
How can I do that?

Thanks in advance!
Edwin W.T.


Edwin W.T.
Re: Content assist - how to use CA dependent on a previous assignment [message #1059339 is a reply to message #1059328] Fri, 17 May 2013 14:53 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

1: your rule would more likely look something like
Rule: "Keyword" id=STRING text=STRING;

Now, if you have a look at the propsal methods, they have a context object. That is, when calculating the proposals for text, you can access the object's id and evaluate it.

2:
RuleY: x=RuleX;
RuleZ: x=RuleX;

There will be two distinct completion methods for feature x in type RuleY and feature x in type RuleZ. So simply by implementing those two methods differently, you get the desired outcome.

Please have a look at the documentation. (Note that the grammar rule RuleY causes an object of type RuleY to be created, this has a feature x of type RuleX)

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: Content assist - how to use CA dependent on a previous assignment [message #1059343 is a reply to message #1059339] Fri, 17 May 2013 15:15 Go to previous messageGo to next message
Edwin Tuzar is currently offline Edwin TuzarFriend
Messages: 33
Registered: April 2013
Location: Kaiserslautern
Member

For answer #1 I didn't get what you mean ...currently I'm override the proposal methods in {myLang}ProposalProvider. There I have a context, but doesn't have an ID for all the objects. I saw something that I can retrieve the rootmodel ...is this the right way to go?
And #2 I don't want completions for x in
RuleY: x=RuleX;
RuleZ: x=RuleX;
I want completion for RuleX.


Book:
	'book' name=ID
	(book=Name)

;
Car:
        'car' name=ID
	(car=Name)

;
Name:
	'name' name=STRING
;

so now if I'm doing something in completeBook_Name or completeCar_Name the auto completion will work on the 'book' or 'car', but I want the auto completion to work on 'name' from Name
Example:
'car' audi
'name' red (suggestions: red|blue)
and
'book' FunwithXtext
'name' Fun (suggestions: fun|funfun)
Hope now is clear and thanks for the quick answer!


Edwin W.T.
Re: Content assist - how to use CA dependent on a previous assignment [message #1059360 is a reply to message #1059343] Fri, 17 May 2013 16:20 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi you can Ask an Ebject for its econtainer and then downcast to the specific Type
(Or call ecoreutil2.getcontaineroftype))


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Maven-Tycho + Xtend Sample
Next Topic:The scope for name uniqueness
Goto Forum:
  


Current Time: Fri Apr 26 15:03:08 GMT 2024

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

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

Back to the top