我创建了一个Xpand生成器。在它的src /文件夹中,我已经将我的模型My.nn定义为模板和工作流程。
这就是我的workflow.mwe2文件的样子:
module workflow.NeuralNetworksGenerator
import org.eclipse.emf.mwe.utils.*
var targetDir = "src-gen"
var fileEncoding = "Cp1252"
var modelPath = "src/model"
Workflow {
component = org.eclipse.xtext.mwe.Reader {
// lookup all resources on the classpath
//useJavaClassPath = true
// or define search scope explicitly
path = modelPath
// this class will be generated by the xtext generator
register = org.xtext.example.neuralnetworks.NeuralNetworksStandaloneSetup {}
load = {
slot = "systems"
type = "System"
}
}
component = org.eclipse.xpand2.Generator {
expand = "templates::Template::main FOREACH systems"
outlet = {
path = targetDir
}
fileEncoding = fileEncoding
}
}
当我尝试将此workflow.mwe2文件作为MWE2 Workflow运行时,出现以下错误:
0 INFO AbstractExpressionsUsingWorkflowComponent - No meta models configured, using JavaBeans as default.
75 ERROR Mwe2Launcher - Problems running workflow workflow.NeuralNetworksGenerator: Couldn't find EClass for name 'System'.
java.lang.RuntimeException: Problems running workflow workflow.NeuralNetworksGenerator: Couldn't find EClass for name 'System'.
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:99)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:73)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:64)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:55)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:74)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:35)
Caused by: org.eclipse.emf.mwe.core.WorkflowInterruptedException: Couldn't find EClass for name 'System'.
at org.eclipse.xtext.mwe.SlotEntry.findEClasses(SlotEntry.java:135)
at org.eclipse.xtext.mwe.SlotEntry.put(SlotEntry.java:91)
at org.eclipse.xtext.mwe.AbstractReader.addModelElementsToContext(AbstractReader.java:95)
at org.eclipse.xtext.mwe.Reader.invokeInternal(Reader.java:166)
at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:126)
at org.eclipse.emf.mwe.core.lib.Mwe2Bridge.invoke(Mwe2Bridge.java:34)
at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:201)
at org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkflowComponent.invoke(AbstractCompositeWorkflowComponent.java:35)
at org.eclipse.emf.mwe2.runtime.workflow.Workflow.run(Workflow.java:19)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:97)
... 5 more
我用来创建特定工作流程mwe2文件的示例来自Xpand参考手册。
这是MANIFEST.MF文件中的插件依赖项列表:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: my.neuralnetworks.generator.project
Bundle-SymbolicName: my.neuralnetworks.generator.project; singleton:=true
Bundle-Version: 1.0.0
Require-Bundle: org.eclipse.jdt.core;bundle-version="3.5.0",
org.eclipse.xtend.profiler;resolution:=optional,
org.apache.commons.logging,
org.apache.log4j;resolution:=optional,
com.ibm.icu;bundle-version="4.0.1",
org.antlr.runtime;bundle-version="3.0.0",
org.eclipse.core.runtime;bundle-version="3.5.0",
org.eclipse.emf.mwe.utils;bundle-version="0.7.0",
org.eclipse.emf.ecore.xmi;bundle-version="2.5.0",
org.eclipse.jface.text;bundle-version="3.5.0",
org.eclipse.xpand;bundle-version="0.7.0",
org.eclipse.xtend;bundle-version="0.7.0",
org.eclipse.xtend.typesystem.emf;bundle-version="0.7.0",
org.eclipse.xtend.backend;bundle-version="1.0.0";resolution:=optional,
org.eclipse.xtend.middleend.xpand;bundle-version="1.0.0";resolution:=optional,
org.eclipse.xtend.middleend.xtend;bundle-version="1.0.0";resolution:=optional,
neuralnetworks;bundle-version="1.0.0",
org.xtext.example.neuralnetworks;bundle-version="1.0.0",
org.eclipse.emf.ecore.xmi.source;bundle-version="2.7.0",
org.eclipse.jface.text.source;bundle-version="3.7.0",
org.antlr.runtime.source;bundle-version="3.2.0",
org.antlr.runtime_3.1.b1;bundle-version="3.1.0",
com.ibm.icu.source;bundle-version="4.4.2",
org.eclipse.jdt.core.source;bundle-version="3.7.0",
org.eclipse.emf.mwe2.launch;bundle-version="2.2.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Import-Package: nn
neuralnetworks 插件是指我的图形编辑器的gmf项目,其中找到元模型, org.xtext.example.neuralnetworks 是对应的一个我的文字编辑。
与emf文件对应的ecore文件中确实包含EClass系统。
答案 0 :(得分:0)
你的dsl怎么样?它是否包含名为System的EClass? 更新:刚看到你没有基于Xtext的元模型。因此,如果您想使用Xtext Mwe Reader Component,您必须使用AbstractGenericResourceSupport并注册您的epackage,并在此Xtend2示例中描述http://christiandietrich.wordpress.com/2011/07/29/xtend2-code-generators-with-non-xtext-models/
答案 1 :(得分:0)
不,但由于您使用的是现有元模型而非衍生元模型,因此您应将以下内容添加到工作流程的开头
bean = StandaloneSetup {
registerGeneratedEPackage = "sample.SamplePackage"
}