如何为 XtextGenerator 指定 Xtext 语言生成的顺序?

How to specify order of Xtext Language generation for the XtextGenerator?

我们有一个包含两个 Xtext 语法的项目,遵循此线程中的描述:https://www.eclipse.org/forums/index.php/t/1079008/

我们的语言生成模块有一个 XtextGenerator 块,有两个语言块。一种语言块通过 'referencedResource' 属性.

引用另一种语言块

将语法放在一个项目中是有意义的,因为它们紧密相关,并且一种语法依赖于另一种语法。

但是运行Langauge Generation模块时,依赖的语言好像是在依赖语言之后生成的,导致被依赖语言的.genmodel出现FileNotFoundException。

为什么被依赖的语言在依赖语言之后生成?是否可以指定生成语言的顺序?

我已经试过了:

语言生成模块代码如下:

module com.a.b.GenerateLang

import org.eclipse.xtext.xtext.generator.*
import org.eclipse.emf.mwe.utils.StandaloneSetup
import org.eclipse.xtext.xtext.generator.model.project.*

var rootPath = ".."

Workflow {

    component = XtextGenerator {
        configuration = {
            project = StandardProjectConfig {
                baseName = "com.a.b"
                rootPath = rootPath
                runtimeTest = {
                    enabled = true
                }
                genericIde = {
                    enabled = true
                }
                mavenLayout = true
            }
            code = {
                encoding = "UTF-8"
                lineDelimiter = "\n"
                fileHeader = "/*\n * generated by Xtext ${version}\n */"
            }
        }
        language = StandardLanguage {
            name = "com.a.b.BxLang"
            fileExtensions = "bxlang"
            referencedResource =
            "platform:/resource/com.a.b/model/generated/BxLangSubjectScope.genmodel" 
            serializer = {
                generateStub = false
            }
            validator = {
                generateDeprecationValidation = true
            }
            junitSupport = {
                junitVersion = "5"
            }
        }
        language = StandardLanguage {
            name = "com.a.b.BxLangSubjectScope"
            fileExtensions = "bxscope"
            serializer = {
                generateStub = false
            }
            validator = {
                generateDeprecationValidation = true
            }
            junitSupport = {
                junitVersion = "5"
            }
        }
    }
}

运行 上述语言生成模块导致以下错误:

359  [main] ERROR mf.mwe2.launch.runtime.Mwe2Launcher  - Problems running workflow com.a.b.GenerateBxLang: java.io.FileNotFoundException: /model/generated/BxLangSubjectScope.genmodel (No such file or directory)
java.lang.RuntimeException: Problems running workflow com.a.b.GenerateBxLang: java.io.FileNotFoundException: /model/generated/BxLangSubjectScope.genmodel (No such file or directory)

解决方案正如 Christian Dietrich 对原始问题的评论:

referencedResource应该是语法文件,不是genmodel。正确的参考如下:

referencedResource =
          "platform:/resource/com.a.b/src/main/java/com/a/b/BxLangSubjectScope.xtext"