Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Issue with cross-referencing elements of other EMF model
icon5.gif  Issue with cross-referencing elements of other EMF model [message #1116385] Wed, 25 September 2013 10:55 Go to next message
Nieves Salor is currently offline Nieves SalorFriend
Messages: 19
Registered: September 2013
Junior Member
Hello,
I am trying to create a grammar in XText based in an ANTLR one I had previously created. Also I have a EMF model containing information that is referred in this grammar, so I though to create the grammar directly in XText importing the ecore file of the existing model.
As I am doing little by little I have detected the issue at the beginning and I want to know if there is a solution before I continue as the grammar is huge.
The first grammar rules which are being problematic are:

EventDeclaration:
'<EVENT>' spaceSysObjName = ID ('<DESCRIPTION>' eventDescr = STRING '</DESCRIPTION>')? '</EVENT>';
Wait_statement:
'<WAIT>' '<EVENT>' event=[EventDeclaration] '<EVENT>'(saveContextStmt = SaveContext)? (timeout = Timeout)? '</WAIT>';


In this case when I am running the project, the cross reference is not verified and the validator raises the following issue:
Couldn't resolve reference to EventDeclaration 'event0'. with the example
<DECLARE><EVENT>event0</EVENT></DECLARE><PRECONDITIONS><WAIT><EVENT>event0<EVENT></WAIT></PRECONDITIONS>

However if instead of putting 'spaceSysObjName' I set 'name' as the name of the feature it works as expected. Why is that??

------------------------------------
My second problem, which for me it is more critical is that if I import an external EMF ecore file created from a parsin of a XSD file automatically and which works perfectly via the import mechanism (import "platform:/resource/SSMModel/model/ssm.ecore" as ssm), setting the reference in the StandaloneSetup (registerGeneratedEPackage = "ssm.model.ssm.ssmPackage"
registerGenModelFile = "platform:/resource/SSMModel/model/ssm_schema.genmodel"
) and in the buildpath the reference to the plugin project containng the ecore; I can compile without issues but when I try to open the editor it gives an error because of classNotFound related with the injector of the generated grammar.
Failed to create injector for com.vitrocisetbelgium.compiler.Pluto ExtensionFactory: compiler.ui.PlutoExecutableExtensionFactory
due to not finding the class of the imported EMF model
Error injecting method, java.lang.NoClassDefFoundError: ssm/model/ssm/ssmPackage

Can someone help me with this?? Because I have tried all methods and I am desperate...
Thanks in advance
Nieves
Re: Issue with cross-referencing elements of other EMF model [message #1116480 is a reply to message #1116385] Wed, 25 September 2013 14:05 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

did you add a dependency (manifest.mf) to the plugin that contains ssmPackage (Sure it is a lower case s???)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Issue with cross-referencing elements of other EMF model [message #1116485 is a reply to message #1116480] Wed, 25 September 2013 14:09 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
and to your first question: if you dont have an attribute with name "name" (a convention) you have to customize IQualifiedNameProvider (subclassing DefaultDeclarativeQualifiedNameProvider)

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Issue with cross-referencing elements of other EMF model [message #1117293 is a reply to message #1116485] Thu, 26 September 2013 09:29 Go to previous messageGo to next message
Nieves Salor is currently offline Nieves SalorFriend
Messages: 19
Registered: September 2013
Junior Member
Hi Christian,
Thanks a lot for your answer Very Happy I added the dependency and also the plugin as external jar and re-create the artifacts launching it selecting the emf plugin to be loaded and now it does not result in any error.
However, sorry if it sounds dumb but another question for the future... I assume that for the references to be found I have to load (in this case a ssm) data resource (e.g. xmi one) in the same runtime application I launch when I execute the xtext editor. Where I should define this resource?? Am I mistaken or should be in the PlutoStandaloneSetupGenerated class?? There is no way to leave it configurable? As the idea is to be able to associate different reference SSM models depending to the PLUTO grammar example.

Regarding the name, many thanks I will test it now Very Happy
Re: Issue with cross-referencing elements of other EMF model [message #1117317 is a reply to message #1117293] Thu, 26 September 2013 09:59 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Sry dont get this

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Issue with cross-referencing elements of other EMF model [message #1151468 is a reply to message #1117317] Wed, 23 October 2013 11:18 Go to previous messageGo to next message
Nieves Salor is currently offline Nieves SalorFriend
Messages: 19
Registered: September 2013
Junior Member
Hi Christian,
Sorry for my late reply but I was trying to implement and play a little before making more questions and I finally solved the issues of the outline view, the formatting, templates, internal cross-references and semantic checks.
However now I want to integrate my dsl project with an external EMF project(not XTEXT) which has elements which can be referenced within the grammar (i.e. activity ids, function names, variables...).
In the grammar I use the import of the ecore file of the EMF project and I have added de dependency in the plugin, so compiling speaking everything works. However at runtime the references are not found.
My deployment is: I run the editor plugin generated by the EMF project (adding the dependencies to the Xtext Project) and after I have openned the ssm file (xmi resource) correctly, I open a pluto file (xtext resource) also correctly with all features working (i.e. content-assist, formatting, syntax highlinghting, even validation after a customisation). However, the references are not found..
Can you tell me if I need to do some extra binding between the projects??
Re: Issue with cross-referencing elements of other EMF model [message #1151922 is a reply to message #1151468] Wed, 23 October 2013 17:54 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
If you want to reference non Xtext things from your .mydsl you need
to provide an iresourceserviceprovider for the non Xtext stuff

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Issue with cross-referencing elements of other EMF model [message #1153067 is a reply to message #1151922] Thu, 24 October 2013 11:05 Go to previous messageGo to next message
Nieves Salor is currently offline Nieves SalorFriend
Messages: 19
Registered: September 2013
Junior Member
Hi again
I have implemented my custom IResourceServiceProvider extending the DefaultResourceServiceProvider with the following method

public boolean canHandle(URI uri) {
		if(uri!=null){
		    String extension = uri.fileExtension();
		    if(extension!=null && extension.equalsIgnoreCase("ssm")){
		    	return true;
		    }else{
		    	return false;
		    }
		}else{
			return false;
		}
	  }


where ssm is the extension of my EMF model files (no Xtext ones) and later binding the ServiceProvider into the PlutoRuntimeModule class.

However it still does not work as if I try to open a ssm file with the compiler plugin running, it opens the pluto file correctly but the ssm one like a text file. However if I launch my editor plugin it opens both files correctly, however references still do not work. Through debugging, the only file that enters into my resourceserviceprovider is the pluto file and never the ssm one.
Am I missing something? Maybe I have to register the provider explicitly in the StandAloneSetupGenerated class? Although this class is in the src-gen so I should not touch it..I believe
Some help is appreciated as I am becomming crazy with this issue.
Thanks in advance
Re: Issue with cross-referencing elements of other EMF model [message #1153127 is a reply to message #1153067] Thu, 24 October 2013 11:55 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

if you press crtl + Shift+ F3
does your ssm stuff occur in the dialog or not
http://christiandietrich.wordpress.com/2011/07/17/xtext-2-0-and-uml/


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Issue with cross-referencing elements of other EMF model [message #1170088 is a reply to message #1153127] Mon, 04 November 2013 11:52 Go to previous messageGo to next message
Nieves Salor is currently offline Nieves SalorFriend
Messages: 19
Registered: September 2013
Junior Member
Hi,
When I press nothing appears. I have also tried your approach of the UML and is also not working. I have created a simplification of my projects, with an Xtext simple grammar referencing an EMF element and all the plugings associated. Could you please take a look to see which is the issue? Here I put the zip with all the plugings related.
Thanks in advance
Nieves
Re: Issue with cross-referencing elements of other EMF model [message #1170655 is a reply to message #1170088] Mon, 04 November 2013 20:02 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

there are multiple warnings on your resourceserviceprovider projects. there are there for a reason.

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Cr
Bundle-SymbolicName: crossReferences.xtext.cr
Bundle-Version: 1.0.0.qualifier
Require-Bundle: org.eclipse.ui,
 org.eclipse.core.runtime,
 crossReferencesTest;bundle-version="0.1.0",
 org.eclipse.xtext;bundle-version="2.4.3"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Import-Package: com.google.inject;version="1.3.0",
 org.eclipse.xtext.naming,
 org.eclipse.xtext.resource,
 org.eclipse.xtext.resource.generic,
 org.eclipse.xtext.resource.impl
Export-Package: crossreferences.xtext.cr



<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
   <extension
         point="org.eclipse.xtext.extension_resourceServiceProvider">
      <resourceServiceProvider
            class="crossreferences.xtext.ui.cr.ExecutableExtensionFactory:org.eclipse.xtext.ui.resource.generic.EmfResourceUIServiceProvider"
            uriExtension="crossreferences">
      </resourceServiceProvider>
   </extension>

</plugin>


then you should adapt the grammar to be able to handle qualified names

Task:
	act=[crossing::activity|FQN] 'during' duration=INT 'minutes';
	
FQN: ID ("." ID)*;	


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Issue with cross-referencing elements of other EMF model [message #1171934 is a reply to message #1170655] Tue, 05 November 2013 15:39 Go to previous messageGo to next message
Nieves Salor is currently offline Nieves SalorFriend
Messages: 19
Registered: September 2013
Junior Member
Thanks for the info, now the references are working Very Happy. However the main issue in my real project was that my ID attribute was not named 'name' but 'spacesysobjname'. This said I though that defining the specific DQNP would take care of the problem but it is not like that. You can reproduce this behaviour in the projects I attached yesterday and changing the attribute name in the EMF objects for something else and fixing accordingly the DQNP and then the references would not work anymore. Which is something I still do not understand :S
Another issue with the cross-references is regarding the Outline View as the label providers of the .edit plugin project seem not to be picked and when trying to display the outline view of my grammar I get an error saying
java.lang.NoClassDefFoundError: .../ssm/model/ssm/{ReferredEMFObject}
whenever in the grammar LabelProvider I use the method 'text' to display the data from the element. But debugging I can see the info of the populated referred element.
In the manual I've seen that it says
Quote:
If your grammar uses an imported EPackage (src), there may be an existing edit-plug-in generated by EMF that also provides label providers for model elements. To use this as a fallback, your label provider should call the constructor with the delegate parameter and use dependency injection for its initialization, e.g.

public class MyLabelProvider {
    @Inject
    public MyLabelProvider(AdapterFactoryLabelProvider delegate) {
    super(delegate);
    }
    }


But chekcing my grammar label provider I have that constructor, so do I have to inject the EMF Model ItemProviderAdapterFactory into the runtime UI Module? And if so, how?
Thanks
P.S I think I will write a small tutorial when I complete the whole project about the integration between external EMF within Xtext for future users Smile
Re: Issue with cross-referencing elements of other EMF model [message #1173828 is a reply to message #1171934] Wed, 06 November 2013 19:45 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

for your grammars outline you have to care yourself. (or a least set a dependency from to ui project to whatever it wants.
the point on the nameprovider i do not understand. are you should you did implement it correct and bound it in the module of the reourceserviceprovider? is it called when debugging?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Set non-transient value to transient
Next Topic:(SOLVED) Cyclic resolution of lazy links problem
Goto Forum:
  


Current Time: Fri Mar 29 01:25:48 GMT 2024

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

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

Back to the top