Resolve different parser rules dependency. [message #1780821] |
Sun, 28 January 2018 16:52  |
Eclipse User |
|
|
|
I am new to xtext and need some help. I have a problem statement and don't know how to implement the same. Below is a small example:
//Xtext Grammar---------
Feature_decl: 'feature' name=ID;
Delta_decl: 'delta' name=ID;
Product_line_decl: 'productline' name=ID delta=[Delta_decl|ID] 'when' feature+=[Feature_decl|ID]* (',' feature+=[Feature_decl|ID]*) ';' ;
//Runtime Result----------
feature F1 //on hover or click show D1 and D2
feature F2 //on hover or click show D1 and D2
feature F3 //on hover or click show D2
delta D1 //on hover or click show F1 and F2
delta D2 //on hover or click show F1, F2 and F3
productline example1 D1 when F1,F2; // Establish the relationship between feature and delta
productline example2 D2 when F1,F2,F3;
Now,I want to acheive the relation between features and delta declaration. When I click/hover on any feature say 'F1' anywhere in the program it should show depenedent deltas 'D1' and 'D2'. Similarly, when I hover over a delta say 'D1', it should show list of features i.e. 'F1' and 'F2'.
|
|
|
|
|
|
|
|
|
|
Re: Resolve different parser rules dependency. [message #1781344 is a reply to message #1781330] |
Tue, 06 February 2018 04:25   |
Eclipse User |
|
|
|
Hello Christian,
(1a) for references: are these local references or not. if not have a look at IReferenceFinder.findReferences*
What do you mean by local references? Does it mean all the code is present in a single file?
Also, I am able to understand the method and its usage but I am not sure how to use it. I am creating a new class say A in the package 'org.xtext.xx.ui' which extends EcoreUtil2. Now I want to use 'getAllReferencedObjects' which take 2 parameters. I want to know how I can get these parameters value?
Also, do I need to override the default implementation of ''getAllReferencedObjects' if present and write my code there? Or creating a new class in package 'org.xtext.xx.ui' is correct?
(2) i dont understand
Below is my xtext grammar. The product_line_decl forms the relationship between the deltas and features described above.
//Xtext Grammar---------
Feature_decl: 'feature' name=ID;
Delta_decl: 'delta' name=ID;
Product_line_decl: 'productline' name=ID delta=[Delta_decl|ID] 'when' feature+=[Feature_decl|ID]* (',' feature+=[Feature_decl|ID]*) ';' ;
//Runtime Result----------
//-------------------Features
feature F1
feature F2
feature F3
//-----------------Deltas
delta D1
delta D2
productline example1 D1 when F1,,F2; // Establish the relationship between feature and delta
productline example2 D2 when F1,F2,F3;
When I override the 'compile' function present in 'org.xx.generator' (sorry I mentioned the wrong package), I was able to print
D1->F1,F2
D2->F1,F2,F3
(3) I dont understand. if you can print "hello world" you can print "your calculated stuff"
I am able to print custom messages in 'org.xtext.xx.ui.labeling' package and the compile function is present in the another package called the 'generator'. I am not able to use the text function present in the org.xtext.xx.ui.labeling in my generator class. Hope this helps. Sorry, I am new to xtext so I am not sure what I am doing is correct.
Many thanks for the help anyways.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Navigation on Hover. [message #1783301 is a reply to message #1783289] |
Sun, 11 March 2018 08:01   |
Eclipse User |
|
|
|
Hi Christian,
I have the following grammar
//Goal Main Model OR Starting Rule
DomainModel: Compilation_Unit;
//Compilation Unit
Compilation_Unit:{Compilation_Unit} (deltaDecl+=Delta_decl)* (productline_decl=Productline_decl)? ('root' feature_decl+=Feature_decl |'extension' fextension+=Fextension)*
Feature_decl: 'feature' name=ID;
Delta_decl: 'delta' name=ID;
Product_line_decl: 'productline' name=ID delta=[Delta_decl|ID] 'when' feature+=[Feature_decl|ID] (',' feature+=[Feature_decl|ID]) ';' ;
The productline has the reference of features and Deltas. The features ,deltas and productline are defined in different files. I have implemented IHyperlinkHelper to customize the hyperlinking of the elements. I need to show the list of all Features related to a particular delta whenever the user (Ctrl+F5) on delta name. We can get this delta-feature information from the productline which is present in different file. I only have the eObject of delta as the user will (Ctrl+F5) on it . I need to get the reference of this delta from productline.
//Runtime Result----------
//-------------------Features (Features.abs)
feature F1
feature F2
feature F3
//-----------------Deltas (Delta.abs)
delta D1
delta D2
//Productline (Productline.abs)
productline example1
D1 when F1,,F2; // Establish the relationship between feature and delta
D2 when F1,F2,F3;
When user Ctrl+F5, I need
D1->F1,F2
D2->F1,F2,F3
Currently, eObject.eContainer gives me Compilation_UnitImpl but I am not able to traverse the tree. I need to get the productline object from the delta eobject to show this linking. I am able to achieve it for a single file but for multiple file this is not working.
Thanks in adavnce.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|