Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Resolving cross-references in standalone
Resolving cross-references in standalone [message #977547] Fri, 09 November 2012 11:19 Go to next message
Quentin Boucher is currently offline Quentin BoucherFriend
Messages: 27
Registered: July 2012
Junior Member
Hello!

I'm currently trying to export my model files to XMI in standalone. My language (called FCSS) refers to elements of another language (TVL). In the editor, cross references are right. However, when I try to generate the XMI, I cannot resolve them and get links like #xtextLink_::0.1.1.0::0::/1"/. I have read a lot of threads from this forum but was not able to solve my problem.

Here is my current export method, inspired by a previous thread:

public class Main {

	public static void main(String[] args) throws IOException {

		// register the TVLPackage to ecore
		EPackage.Registry.INSTANCE.put(TVLPackage.eNS_URI, TVLPackage.eINSTANCE);
		Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("tvl", new XMIResourceFactoryImpl());
		// register the resourceserviceprovider
		new TVLSupport().registerServices(true);
		// register the dsl
		Injector injector = new FCSSStandaloneSetup().createInjectorAndDoEMFRegistration();
		// load all model file to the resourceset
		XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class);
		resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
		Resource fcssResource = resourceSet.getResource(URI.createURI("/Users/Quentin/runtime-New_configuration/Test/Tune.fcss"), true);
		Resource tvlResource = resourceSet.getResource(URI.createURI("/Users/Quentin/runtime-New_configuration/Test/Tune.tvl"), true);
		// work with the resources (the elements come from Tune.tvl)
		fcssResource.load(null);
		Resource xmiResource = resourceSet.createResource(URI.createURI("/Users/Quentin/runtime-New_configuration/Test/Tune.xmi"));
		xmiResource.getContents().add(fcssResource.getContents().get(0));
		try {
			xmiResource.save(null);
		} catch (IOException e) {
			e.printStackTrace();
		}

	}
}


But, when I try to launch it, I get a
Exception in thread "main" org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: org.xml.sax.SAXParseException: Content is not allowed in prolog.
at line
Resource tvlResource = resourceSet.getResource(URI.createURI("/Users/Quentin/runtime-New_configuration/Test/Tune.tvl"), true);


The code of TVLSupport is the following:

import org.eclipse.xtext.resource.generic.AbstractGenericResourceSupport;

import com.google.inject.Module;

public class TVLSupport extends AbstractGenericResourceSupport {

	@Override
	protected Module createGuiceModule() {
		return new TVLRuntimeModule();
	}

}


Do you have any idea of the sources of my problems?

Thank you very much for your help!
Re: Resolving cross-references in standalone [message #982702 is a reply to message #977547] Tue, 13 November 2012 10:51 Go to previous messageGo to next message
Quentin Boucher is currently offline Quentin BoucherFriend
Messages: 27
Registered: July 2012
Junior Member
Does anybody have a clue?

Thanks!
Re: Resolving cross-references in standalone [message #982752 is a reply to message #982702] Tue, 13 November 2012 11:40 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14668
Registered: July 2009
Senior Member
Looks very strange to me:

1 call the stand alone setups
2 load all Xtext resources to the resource set
3 resolve all
4 add to xmi and save

No factory support etc 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: Resolving cross-references in standalone [message #985839 is a reply to message #982752] Fri, 16 November 2012 10:32 Go to previous message
Quentin Boucher is currently offline Quentin BoucherFriend
Messages: 27
Registered: July 2012
Junior Member
Thank you for your answer!
I finally managed to implemented by looking at the main class generated by mwe2 workflow of my language.
Previous Topic:Chain 2 parsers/generators
Next Topic:Change of display string in editor after content assist
Goto Forum:
  


Current Time: Fri Apr 26 19:11:59 GMT 2024

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

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

Back to the top