Java 模型到源代码转换的问题

Problem with Java model to source code transformation

我对 Modisco java 模型的 Java 源代码生成有问题。

我在 Modisco 文档中使用了下面的指南:
https://help.eclipse.org/2018-12/topic/org.eclipse.modisco.java.doc/mediawiki/java_generation/user.html?cp=67_0_1_1_2

首先,我在工作区
中导入了插件org.eclipse.gmt.modisco.java.generation 然后我在 src 文件夹中添加了一个 class,如下所示:

import java.io.File;
import java.io.IOException;
import java.util.*;

import org.eclipse.emf.common.util.URI;

import org.eclipse.gmt.modisco.java.generation.files.GenerateJavaExtended;

public class Generation {

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

    GenerateJavaExtended javaGenerator = new GenerateJavaExtended(URI.createFileURI("mymodel.xmi"),
            new File("myOutputFolder"), new ArrayList<Object>());

    javaGenerator.doGenerate(null);
    }

}    

但是当我 运行 此代码作为 Java 应用程序时,我收到此错误:

Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 67, Size: 1
at java.util.ArrayList.rangeCheck(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at org.eclipse.emf.ecore.impl.EPackageImpl.eObjectForURIFragmentNameSegment(EPackageImpl.java:1970)
at org.eclipse.emf.ecore.impl.EModelElementImpl.eObjectForURIFragmentSegment(EModelElementImpl.java:473)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.getEObject(ResourceImpl.java:811)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.getEObject(ResourceImpl.java:787)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setValueFromId(XMLHandler.java:2868)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setAttribValue(XMLHandler.java:2773)
at org.eclipse.emf.ecore.xmi.impl.SAXXMIHandler.handleObjectAttribs(SAXXMIHandler.java:79)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFactory(XMLHandler.java:2247)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromTypeName(XMLHandler.java:2150)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObject(XMLHandler.java:2085)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.createObject(XMIHandler.java:151)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLHandler.java:1868)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:1048)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMIHandler.java:82)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:1026)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:720)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHandler.java:190)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(Unknown Source)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:175)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:261)
at org.eclipse.acceleo.model.mtl.resource.EMtlResourceImpl.doLoad(EMtlResourceImpl.java:93)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1563)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1342)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:259)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:406)
at org.eclipse.acceleo.common.utils.ModelUtils.load(ModelUtils.java:391)
at org.eclipse.acceleo.common.utils.ModelUtils.load(ModelUtils.java:356)
at org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator.initialize(AbstractAcceleoGenerator.java:485)
at org.eclipse.gmt.modisco.java.generation.files.GenerateJava.<init>(GenerateJava.java:92)
at org.eclipse.gmt.modisco.java.generation.files.GenerateJavaExtended.<init>(GenerateJavaExtended.java:39)
at Generation.main(Generation.java:13)

如何将我的 java 模型转换回原始 Java 源代码?


我用过的工具:


您可能会在 https://www.eclipse.org/forums/index.php?t=msg&th=1098046&goto=1804354&#msg_1804354

重复发布此消息中找到答案