Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Multiple input files problem
Multiple input files problem [message #1012818] Fri, 22 February 2013 09:24 Go to next message
n d is currently offline n dFriend
Messages: 11
Registered: February 2013
Junior Member
Hi all,

I am exporting my xtext project to the command-line/standalone mode. This is achieved without a problem

but now I need to modify it in order to accept multiple files (in order to resolve cross-references

between files). To do this, I have implemented a version of the suggestion in

http://www.eclipse.org/forums/index.php/m/761659/?srch=standalone+multiple+files#msg_761659

in which the model of the secondary files are added for the Resource of the main file.

ResourceSet set = resourceSetProvider.get();
Resource compositeResource = set.getResource(URI.createURI(mainfilename),true);
for (String otherfilename : getOtherSourceFiles()) {
	Resource modelFromFile = set.getResource(URI.createURI(otherfilename ), true);
	compositeResource.getContents().addAll(modelFromFile.getContents());
}

List<Issue> list = validator.validate(compositeResource, CheckMode.ALL, CancelIndicator.NullImpl);




The problem is, although the validation works, I cannot get ride of this exception:

0    ERROR LazyLinkingResource - resolution of uriFragment 'xtextLink_::0.0.0.1.0::0::/3' failed.
org.eclipse.emf.common.util.BasicEList$BasicIndexOutOfBoundsException: index=0, size=0
        at org.eclipse.emf.common.util.BasicEList.get(BasicEList.java:346)
        at org.eclipse.xtext.linking.lazy.LazyURIEncoder.resolveShortFragment(LazyURIEncoder.java:109)
        at org.eclipse.xtext.linking.lazy.LazyURIEncoder.decode(LazyURIEncoder.java:89)
        at org.eclipse.xtext.linking.lazy.LazyLinkingResource.getEObject(LazyLinkingResource.java:166)
        at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getEObject(ResourceSetImpl.java:223)
        at org.eclipse.emf.ecore.util.EcoreUtil.resolve(EcoreUtil.java:197)
        at org.eclipse.emf.ecore.util.EcoreUtil.resolve(EcoreUtil.java:257)
        at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eResolveProxy(BasicEObjectImpl.java:1473)
        at org.xtext.example.mydsl1.myDsl1.impl.TestName2Impl.getName(TestName2Impl.java:73)
        at org.xtext.example.mydsl1.myDsl1.impl.TestName2Impl.eGet(TestName2Impl.java:117)
        at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:1011)
        at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:1003)
        at org.eclipse.emf.ecore.util.EContentsEList$FeatureIteratorImpl.hasNext(EContentsEList.java:403)
        at org.eclipse.emf.ecore.util.EObjectValidator.validate_EveryReferenceIsContained(EObjectValidator.java:782)
        at org.eclipse.emf.ecore.util.EObjectValidator.validate_EveryDefaultConstraint(EObjectValidator.java:355)
        at org.eclipse.emf.ecore.util.EObjectValidator$DynamicEClassValidator.validate(EObjectValidator.java:1420)
        at org.eclipse.emf.ecore.util.EObjectValidator.validate(EObjectValidator.java:333)
        at org.eclipse.xtext.validation.CompositeEValidator.validate(CompositeEValidator.java:126)
        at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:159)
        at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:137)
        at org.eclipse.xtext.validation.CancelableDiagnostician.validate(CancelableDiagnostician.java:36)
        at org.eclipse.emf.ecore.util.Diagnostician.doValidateContents(Diagnostician.java:178)
        at org.eclipse.xtext.validation.CancelableDiagnostician.doValidateContents(CancelableDiagnostician.java:48)
        at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:162)
        at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:137)
        at org.eclipse.xtext.validation.CancelableDiagnostician.validate(CancelableDiagnostician.java:36)
        at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:120)
        at org.eclipse.xtext.validation.ResourceValidatorImpl.validate(ResourceValidatorImpl.java:108)
        at org.xtext.example.mydsl1.generator.Main.runGenerator(Main.java:80)
        at org.xtext.example.mydsl1.generator.Main.main(Main.java:39)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)



Does anybody encoutered this and have any suggestion to share?
Thanks a lot,
Nuno
Re: Multiple input files problem [message #1012833 is a reply to message #1012818] Fri, 22 February 2013 09:56 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6550
Registered: July 2009
Senior Member
Hi,

why do you do the compositeResource.getContents().addAll(modelFromFile.getContents()); at all?

"the model" is the set off all resources aka resourceset.

if you add all required resources to the resourceset you wont get errors like that.
you may call compositeResource.getContents().addAll(modelFromFile.getContents());
to resolve all lazy cross refs after you added all resources to the resourceset
Re: Multiple input files problem [message #1012844 is a reply to message #1012833] Fri, 22 February 2013 10:20 Go to previous message
n d is currently offline n dFriend
Messages: 11
Registered: February 2013
Junior Member
Hi,

You are completely right.
By validating the resources one by one, I don't need to call compositeResource.getContents().addAll(modelFromFile.getContents()).
All the cross references are resolved.

Thanks for the swift help,
Nuno
Previous Topic:Rename of created EObject for implicit declaration
Next Topic:error when generating my language
Goto Forum:
  


Current Time: Sun Dec 21 22:17:21 GMT 2014

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

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