|
|
Re: EOL Script error in standalone execution: The feature 'x' is not a valid feature [message #1862133 is a reply to message #1862126] |
Tue, 14 November 2023 15:00 |
|
Off the top of my head, I suspect that what happens is that you actually have multiple in-memory copies of the metamodel: the copy that is in your EPackage registry, the copy that you are using as a model in your EOL script, and the copy that you ask Epsilon to instantiate via the use of setMetamodelFileUri(...) instead of just setMetamodelUri(...) (which would reuse the copy in your package registry). You're trying to do x.eGet(f) where x conforms to one of the in-memory copies of the metamodel, and f belongs to another in-memory copy of the metamodel - this may not work in Ecore as it heavily uses object identity (sameness).
Since it looks like sourceModel conforms to sourceMM, I think it'd be much simpler to only use sourceModel from your EOL script, and then use object.eClass when you want to check the EClass that an object belongs to. That way you only need to register your metamodel as usual, and then refer to it by EPackage URI from your code.
[Updated on: Tue, 14 November 2023 15:01] Report message to a moderator
|
|
|
Re: EOL Script error in standalone execution: The feature 'x' is not a valid feature [message #1862150 is a reply to message #1862133] |
Wed, 15 November 2023 13:56 |
Thomas Stifter Messages: 5 Registered: September 2021 |
Junior Member |
|
|
First of all, thanks for the help! I first thought about Antonio's reference to in-memory copies of the same metamodel. So I removed the ".setMetamodelFileUri(...)" part, and lo and behold, it works!
But strangely, in one case the mentioned error still occurs. Namely, when I use the Ecore model as metamodel, one with nsURI/ns "http://www.eclipse.org/emf/2002/Ecore". In this case, I get the mentioned error, specifically "The feature 'abstract' is not a valid feature".
I attach a minimal example project (zip) for the case described so that the error can be reproduced.
[Updated on: Wed, 15 November 2023 15:56] Report message to a moderator
|
|
|
Re: EOL Script error in standalone execution: The feature 'x' is not a valid feature [message #1862160 is a reply to message #1862150] |
Wed, 15 November 2023 22:59 |
|
Hi Thomas,
Tweaking your code as follows seems to be doing the trick.
package eol;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.OutputStream;
import java.io.PrintStream;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.epsilon.emc.emf.EmfMetaModel;
import org.eclipse.epsilon.emc.emf.EmfModel;
import org.eclipse.epsilon.eol.EolModule;
public class EolTest {
public static void main(String[] args) {
System.setProperty("org.eclipse.emf.ecore.EPackage.Registry.INSTANCE", "org.eclipse.emf.ecore.impl.EPackageRegistryImpl");
final EolModule module = new EolModule();
try {
module.parse(new File("model_cov.eol"));
final OutputStream outputStream = new ByteArrayOutputStream();
final String sourceModel = "models/ecore.xmi";
EPackage.Registry.INSTANCE.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
final EmfMetaModel emfModelMM = new EmfMetaModel("MM", EcorePackage.eNS_URI);
emfModelMM.load();
final EmfModel emfModelM = new EmfModel();
emfModelM.setName("m");
emfModelM.setModelFile(sourceModel);
emfModelM.setMetamodelUri(EcorePackage.eNS_URI);
emfModelM.load();
module.getContext().setOutputStream(new PrintStream(outputStream));
module.getContext().getModelRepository().addModel(emfModelMM);
module.getContext().getModelRepository().addModel(emfModelM);
module.execute();
emfModelMM.dispose();
emfModelM.dispose();
String output = outputStream.toString();
System.out.println(output);
} catch (final Exception e) {
e.printStackTrace();
}
}
}
Thanks,
Dimitris
|
|
|
|
Powered by
FUDForum. Page generated in 0.04222 seconds