ModelDriven / Alf-Reference-Implementation

Open-source implementation of the Action Language for fUML (Alf) specification.
30 stars 2 forks source link

o.m.a.eclipse initialization does not find Alf libraries #14

Closed JoriDubrovin closed 8 years ago

JoriDubrovin commented 8 years ago

I am trying to set up the EMF resources for Libraries/uml/Alf.library.uml and other library files by running

new org.modeldriven.alf.eclipse.units.RootNamespaceImpl().initialize();

That seems to run into two issues:

My current attempt at a workaround is

URI baseUri = URI.createURI(Platform.getBundle("org.modeldriven.alf.eclipse").getResource("/").toString());
RootNamespaceImpl rootNs = new RootNamespaceImpl(baseUri);

// Work around org.modeldriven.alf.eclipse.units.RootNamespaceImpl.resourceSet being uninitialized when
// setLibraryDirectory is called from RootNamespaceImpl constructor.
rootNs.setLibraryDirectory(RootNamespaceImpl.DEFAULT_LIBRARY_DIRECTORY);

rootNs.initialize();

while patching RootNamespaceImpl with another constructor

public RootNamespaceImpl(URI baseURI) {
    super();
    this.resourceSet = new ResourceSetImpl();
    this.baseURI = baseURI;
    UMLResourcesUtil.init(this.resourceSet);
}

Using v0.6.0g.

seidewitz commented 8 years ago

The first issue is due to setLibraryDirectory being called in the constructor for the superclass org.modeldriven.alf.fuml.units.RootNamespaceImpl(). This is definitely a bug, which was covered up by the fact that org.modeldriven.alf.eclipse.fuml.execution.AlfCompiler has leftover code to explicitly set the default library (much as you did in your workaround).

The second issue was not a bug for the original intent of the Eclipse implementation, but it is for actually using the implementation as a plugin.

JoriDubrovin commented 8 years ago

v0.6.0h works without problems using the new RootNamespaceImpl(URI) constructor.

seidewitz commented 8 years ago

Resolved in v0.6.0h.