【问题标题】:Modifying of the Mwe2 workflow generated by Xtext programmatically以编程方式修改 Xtext 生成的 Mwe2 工作流
【发布时间】:2019-03-09 14:33:33
【问题描述】:

我正在以编程方式运行 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
            }
        }
    }
}

我正在以编程方式生成项目(使用CliProjectsCreatorWizardConfiguration),并且需要在生成项目时运行工作流以生成 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)

【问题讨论】:

  • 你为什么要这样做? terminal.xtext 隐含可用
  • 当您以编程方式运行工作流时,它不隐式可用 - 而不是在 Eclipse 中。
  • 你能提供更多细节吗?也许你明智地做了一些奇怪的类路径
  • 我把它加到了描述的末尾。
  • 你应该调试 org.eclipse.xtext.xtext.XtextLinkingService.getUsedGrammar(Grammar, INode) org.eclipse.xtext.resource.ClassloaderClasspathUriResolver.resolve(Object, URI) 你说的“运行”是什么意思以编程方式”

标签: java dsl xtext


【解决方案1】:

应该不需要显式添加终端语法。如果使用正确的类路径调用工作流,则应通过org.eclipse.xtext.resource.ClassloaderClasspathUriResolver.resolve(Object, URI) 在类路径中找到它。 看看在选择 maven 时向导会创建什么:使用正确的类路径调用 maven exec 插件调用 Mwe2Launcher main

【讨论】:

    猜你喜欢
    • 2021-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-29
    • 2010-11-06
    • 1970-01-01
    相关资源
    最近更新 更多