以编程方式修改由 Xtext 生成的 Mwe2 工作流
Modifying of the Mwe2 workflow generated by Xtext programmatically
我正在以编程方式 运行ning 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
我正在以编程方式 运行ning 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