我正在以编程方式运行Mwe2工作流,我需要将Terminals.xtext的referencedResource添加到GenerateYourDsl.mwe2文件,以便成功运行此工作流。提到GenerateYourDsl.mwe2文件是由我在创建新项目时由Xtext生成的 - 我没有修改它。是否有可能将对象从此工作流中取出,在Java中访问它并将此属性添加到工作流的组件属性的语言属性中?
这是工作流程:
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文件等。但是我正在尝试以编程方式运行它(而不是在Eclipse中)在我的语法中使用了终端,我收到了这个错误:
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)
应该没有必要明确地添加终端语法。如果使用适当的类路径调用工作流,则应通过org.eclipse.xtext.resource.ClassloaderClasspathUriResolver.resolve(Object, URI)
在类路径中找到它。看一下选择maven时向导创建的内容:调用maven exec插件调用Mwe2Launcher main并使用正确的类路径