Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Xtext手动向语法添加值_Java_Xtext_Xtend - Fatal编程技术网

Java Xtext手动向语法添加值

Java Xtext手动向语法添加值,java,xtext,xtend,Java,Xtext,Xtend,我有一个语法,可以解析容器和模块的列表,然后按字母顺序生成这些容器。但是,我还想将模块名称添加到容器列表中 例如: With the configuration: CONTAINER cont1; CONTAINER cont2; MODULE external WITH PRIORITY 1; MODULE internal WITH PRIORITY 2; The generated file should have: main() { Container(cont1); Con

我有一个语法,可以解析容器和模块的列表,然后按字母顺序生成这些容器。但是,我还想将模块名称添加到容器列表中

例如:

With the configuration:
CONTAINER cont1;
CONTAINER cont2;
MODULE external WITH PRIORITY 1;
MODULE internal WITH PRIORITY 2;


The generated file should have:
main()
{
  Container(cont1);
  Container(cont2);
  Container(external);
  Container(internal);
}
我能够生成容器配置中的内容。但是我想将模块名“internal”和“external”合并到容器中。然后按字母顺序排列


在xtext中是否有这样做的方法?这是属于生成器还是作用域部分?

这应该进入生成器。您需要它生成所有
容器
模块
节点的列表。我假设您已经用Xtend编写了生成器:

val list = Lists.newArrayList( model.containers )
list.addAll( model.modules )
迭代已排序的列表:

for( part : list.sortBy(e|e.name) ) {
    part.generateContainer()
}
然后每个类型有一个generateContainer()方法