|
|
|
|
|
|
|
Re: Resolve different parser rules dependency. [message #1781330 is a reply to message #1781310] |
Tue, 06 February 2018 07:15 |
|
Hi,
i still can follow you since your questions are all theoretically.
(1a) for references: are these local references or not. if not have a look at IReferenceFinder.findReferences*
(1b) if yes: use IReferenceFinder or search for YourModelRoot with EcoreUtil2.getContainerOfType. Traverse the ast and search the features and deltas. filter for the ones you want.
(1c) getAllReferencedObjects is looking forn outgoing references, not to find inverses
(1d) You get a MyDslPackage.Literals constants interface that has a YOURCLASS_YOURREFERENCE
(2) i dont understand
(3) i dont understand. if you can print "hello world" you can print "your calculated stuff"
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Re: Resolve different parser rules dependency. [message #1781344 is a reply to message #1781330] |
Tue, 06 February 2018 09:25 |
Mohd Danish Messages: 49 Registered: October 2017 |
Member |
|
|
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: Resolve different parser rules dependency. [message #1781351 is a reply to message #1781344] |
Tue, 06 February 2018 10:27 |
|
Quote:What do you mean by local references? Does it mean all the code is present in a single file?
yes
i dont think getallReferencedObjects is what you are looking for. have a look at IReferenceFinder
(2) i dont understand what you want to achieve
(3) then you need to put your logic to a common place and use it from generator and label provider
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
|
Navigation on Hover. [message #1781694 is a reply to message #1781356] |
Mon, 12 February 2018 10:04 |
Mohd Danish Messages: 49 Registered: October 2017 |
Member |
|
|
Hello Christian,
Now. I am able to customize the hover and establish the relation between feature and deltas as per my requirements. When I hover over let say D1 it popups the dependent Features F1, F2, F3 and similarly when I hover on D2 it popup F4,F2.
Is it possible to define the navigation functionality like when I click on F1in the label text it will direct to its definition where F1 is declared i.e. how can I give cross-references in xtext label?
[Updated on: Mon, 12 February 2018 10:10] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Navigation on Hover. [message #1782098 is a reply to message #1781732] |
Sat, 17 February 2018 14:48 |
Mohd Danish Messages: 49 Registered: October 2017 |
Member |
|
|
Hello,
As you suggested in this link
https://www.eclipse.org/forums/index.php?t=msg&th=337562/
to do the following
@Override
public Class<? extends IHyperlinkHelper> bindIHyperlinkHelper() {
return MyDslHyperlinkHelper.class;
}
I am also facing the same problem. However, I am not sure where to put this dependency "public Class<? extends IHyperlinkHelper> bindIHyperlinkHelper() { return MyCustomHyperlinkHelper.class; }". These dependencies are present in "src-gen" folder and get override when I run mwe engine. I have found a xtend file where I think I can put these dependencies but I am not sure how to include them or how to write them in xtend . Please help.
[Updated on: Sat, 17 February 2018 14:52] Report message to a moderator
|
|
|
|
|
Re: Navigation on Hover. [message #1782112 is a reply to message #1782111] |
Sun, 18 February 2018 12:28 |
|
I Dont understand.
simply create as many hyperlinks as you wish
the helper calls org.eclipse.xtext.ui.editor.hyperlinking.HyperlinkHelper.createHyperlinksTo(XtextResource, Region, EObject, IHyperlinkAcceptor)
simply create different hyperlinks to different targets ?!?
regarding your second question
yes and no
everythings is customizable
but you need to do it.
i cannot tell you how since i dont know
you need to read the code
read existing cxustomizations
etc
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
[Updated on: Sun, 18 February 2018 12:30] Report message to a moderator
|
|
|
|
|
|
Re: Navigation on Hover. [message #1783301 is a reply to message #1783289] |
Sun, 11 March 2018 12:01 |
Mohd Danish Messages: 49 Registered: October 2017 |
Member |
|
|
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.
|
|
|
|
|
|
|
|
|
|
|
Re: Navigation on Hover. [message #1783353 is a reply to message #1783352] |
Mon, 12 March 2018 10:56 |
|
You can use resourceset.getEObject
You can obtain the resourceset by asking your context eobject for it's resource and the resource for it's object.
The main problem is that what you do is totally unusual
And I have no idea what the actual idea behind it is
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
|
|
|
|
|