如何隐藏我不想看的东西
我正在使用Sirius和Xtext进行图形文本双向同步工作,可能是在我使用Sirius绘制图形来生成Xtext文本的图形后,并且修改文本会同步修改图形。 当我与小天狼星一起绘画时,该模型将存储许多必要的信息,如下所示 [在这里输入图像描述] [1] 我会得到XML喜欢的:
<siriusModel:ElementFactory>
<Elements> type="A" deviveName="A" logicalEntity="AbstractA"
<Elements> type="B" deviceName="B" logicalEntity="AbstractB"
</Elements>
</Elements>
</siriusModel:ElementFactory>
我的Xtext Grammer就是这样:
ElementFactory returns ElementFactory:
{ElementFactory}
'ElementFactory'
'{'
Elements+=Element*
'}';
Element returns Element:
{Element}
'{'
'[''type''='type=STRING']'
'[''deviceName''='deviceName=STRING']'
'[''logicalEntity''='logicalEntity=STRING']'
'}';
而且我的DSL看起来像这样:
ElementFactory{
Element{
[type="A"]
[deviceName="A"]
[logicalEntity="AbstractA"]
}
Element{
[type="B"]
[deviceName="B"]
[logicalEntity="AbstractB"]
}
}
但是我不想显示[deviceName =“ a”]]和[逻辑=“ Abstracta”],我只想为此:
ElementFactory{
Element{
[type="A"]
}
Element{
[type="B"]
}
}
有什么办法可以做到的?我会感谢任何帮助!谢谢! [1]: https://i.sstatic.net/qh5qy.png
I am using Sirius and Xtext to do a graphic-text two-way synchronization work, probably after I use Sirius to draw a graphic to generate Xtext text, and modifying the text will modify the graphic synchronously.
When I draw with Sirius, the model will store a lot of necessary information, as shown below
[enter image description here][1]
I will get the XML likes this :
<siriusModel:ElementFactory>
<Elements> type="A" deviveName="A" logicalEntity="AbstractA"
<Elements> type="B" deviceName="B" logicalEntity="AbstractB"
</Elements>
</Elements>
</siriusModel:ElementFactory>
My xtext grammer is like this:
ElementFactory returns ElementFactory:
{ElementFactory}
'ElementFactory'
'{'
Elements+=Element*
'}';
Element returns Element:
{Element}
'{'
'[''type''='type=STRING']'
'[''deviceName''='deviceName=STRING']'
'[''logicalEntity''='logicalEntity=STRING']'
'}';
And my DSL looks like this:
ElementFactory{
Element{
[type="A"]
[deviceName="A"]
[logicalEntity="AbstractA"]
}
Element{
[type="B"]
[deviceName="B"]
[logicalEntity="AbstractB"]
}
}
but i don't want to show the [deviceName="A"] and [logicalEntity="AbstractA"] , I only want to this:
ElementFactory{
Element{
[type="A"]
}
Element{
[type="B"]
}
}
is there any way i can do it? Any help i would appreciate! thanks!
[1]: https://i.sstatic.net/qh5Qy.png
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的问题是您希望您的文本混凝土语法(Xtext语法)不代表您的整个语义模型。据我所知,XTEXT并不是真正的可能:总体上,整个文件是整个模型。
在Sirius中,您可以更轻松地选择不是代表一些语义信息,而且还可以。
我建议您为您的语言设计一种“真实,完整的”抽象语法,然后还创建一个Xtext的抽象语法,用于用于文本零件,并在“真实”模型和“为文本制造”中进行同步。我相信Eclipse OCL也可以与几种元模型一起使用,其中有几个具有转换的元模型,以既适应Xtext技术,又可以符合OCL标准/API。
Your problem is that you want your textual concrete syntax (Xtext grammar) to not represent your whole semantic model. As far as I know this is not really possible for Xtext: in general the whole file is the whole model.
In Sirius you can more easily choose to not represent some of the semantic informations and its OK.
I would advise you to devise a "real, complete" abstract syntax for your language, then also create an Xtext-facing abstract syntax to use for the textual parts, and synchronize between the "real" model and the "made for text" one. I believe Eclipse OCL works like this as well with several metamodels with transformations in-between in order to both accomodate the Xtext technology and the OCL standard/API it is supposed to conform to.