我正在以编程方式运行Mwe2工作流程,并且需要将Terminals.xtext的referencedResource添加到GenerateYourDsl.mwe2文件中,以便成功运行此工作流程。提及的GenerateYourDsl.mwe2文件是在创建新项目时由Xtext生成的-我没有对其进行修改。 是否有可能使对象脱离此工作流程,使用Java访问该对象并将该一个属性添加到工作流程的组件属性的language属性中?
以下是工作流程:
Workflow {
component = XtextGenerator {
configuration = {
project = StandardProjectConfig {
baseName = "org.example.yourdsl"
rootPath = rootPath
eclipsePlugin = {
enabled = true
}
createEclipseMetaData = true
}
code = {
encoding = "UTF-8"
lineDelimiter = "\n"
fileHeader = "/*\n * generated by Xtext \${version}\n */"
}
}
language = StandardLanguage {
name = "org.example.yourdsl.YourDsl"
fileExtensions = "yourdsl"
//following line needs to be added - in original generated workflow it is not
referencedResource = "platform:/resource/org.eclipse.xtext/org/eclipse/xtext/common/Terminals.xtext"
serializer = {
generateStub = false
}
validator = {
// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
// Generates checks for @Deprecated grammar annotations, an IssueProvider and a corresponding PropertyPage
generateDeprecationValidation = true
}
}
}
}
我正在以编程方式生成项目(使用CliProjectsCreator
和WizardConfiguration
),并且需要在生成项目时运行工作流,以便生成src,src-gen文件等。 m尝试以编程方式运行它(不是在Eclipse中),并且在我的语法中使用了Terminals,我遇到了这个错误:
XtextLinkingDiagnostic: null:1 Couldn't resolve reference to Grammar 'org.eclipse.xtext.common.Terminals'.
TransformationDiagnostic: null:36 Cannot create datatype WS. If this is supposed to return EString, make sure you have imported 'http://www.eclipse.org/emf/2002/Ecore' (ErrorCode: NoSuchTypeAvailable)
TransformationDiagnostic: null:39 Cannot create datatype NAME_TERMINAL. If this is supposed to return EString, make sure you have imported 'http://www.eclipse.org/emf/2002/Ecore' (ErrorCode: NoSuchTypeAvailable)
TransformationDiagnostic: null:42 Cannot create datatype VALUE_TERMINAL. If this is supposed to return EString, make sure you have imported 'http://www.eclipse.org/emf/2002/Ecore' (ErrorCode: NoSuchTypeAvailable)
答案 0 :(得分:0)
无需明确添加终端语法。如果使用正确的类路径调用工作流,则应通过org.eclipse.xtext.resource.ClassloaderClasspathUriResolver.resolve(Object, URI)
在类路径上找到它。
看一下选择maven时向导创建的内容:对maven exec插件的调用,并使用适当的类路径调用Mwe2Launcher main