Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Load EMF EObject from several dsl files
Load EMF EObject from several dsl files [message #654357] Tue, 15 February 2011 11:35 Go to next message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
Hello everybody.

I have a dsl wich can be contain in different files :

for exemple ;
file authors..mydsl1
metaRepository authors

author jguidoux {
	firstName toto;
	lastName Wallis;
	description "unknows";
}



and the files rules. mydsl1 :
 metaRepository rules

import authors.*

rule  rule1 type AUDIT refactoring NONE{
	author jguidoux;



I try to load the dsl on a EObject.
But it does not works very well.

I have this method to load the dsl :
    public static MetaRepository loadDSL(File file) {
        if (!EPackage.Registry.INSTANCE.containsKey(MetaRepositoryPackage.eNS_URI)) {
            EPackage.Registry.INSTANCE.put(MetaRepositoryPackage.eNS_URI, MetaRepositoryPackage.eINSTANCE);
        }
        MetarepositoryDSLStandaloneSetup.doSetup();
        final ResourceSet rs = new ResourceSetImpl();
        final Resource resource = rs.getResource(URI.createURI(file.getPath()), true);
        return (MetaRepository) resource.getContents().get(0);
    }


With this I can load my dsl, but I don't havv all the information in my EObject.

for exemple ;
Author author = metarepository.getAuthor()

return a proxy. And I don't manage to resolve the proxy.
I try to load the other dsl file with contain the author and after to resovle the proxy. By this way :
public static EList<MetaRepository> loadDSLs(String path) {
        final EList<MetaRepository> metareps = new BasicEList<MetaRepository>();
        final List<File> files = getDSLFiles(new File(path));
        for (final File file : files) {
            final MetaRepository metarep = loadDSL(file);
            validateMetarep(metarep);
            metareps.add(metarep);
        }
        return metareps;
    }


But it still doesn't work.

Have you got any idea?

Thanks

Jérémie


Re: Load EMF EObject from several dsl files [message #654362 is a reply to message #654357] Tue, 15 February 2011 12:03 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hello,

first you should call standalonesetups only once. then you have to add all model files to the resourceset to get the references running since the global scope is build of all resources in standalone mode.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Load EMF EObject from several dsl files [message #654534 is a reply to message #654362] Wed, 16 February 2011 09:06 Go to previous message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
Thanks Dietrish.

That was the solution.

Smile

Jérémie
Previous Topic:Using Namespace URIs to Import Existing EPackages
Next Topic:Embedding an Xtext DSL in JDT / CDT editors
Goto Forum:
  


Current Time: Thu Apr 18 23:13:29 GMT 2024

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

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

Back to the top