xText 2 - 处理令牌
是否可以在将令牌分配给 EAttribute 之前修改令牌或
将相同的标记分配给多个EAttributes?
类似以下内容(伪代码):
MyRuleWithModifiedToken:
'entity' name=${ID + 'Entity'} '{' ... '}'
MyRuleUsingSameToken:
name=ID sameName=${<ID}
我读到有关使用 用 xTend 编写的 PostProcessor 但不允许不修改生成模型的数据。
提前致谢
Is it possible to modify a token before it gets assigned to an EAttribute or
to assign the same token to multiple EAttributes?
Something like the following (Pseudocode):
MyRuleWithModifiedToken:
'entity' name=${ID + 'Entity'} '{' ... '}'
MyRuleUsingSameToken:
name=ID sameName=${<ID}
I read about using a PostProcessor written in xTend but it's not allowed not modify the data of the generated model.
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过使用 IValueConverter 来修改令牌 - 这适用于终端或数据类型规则,因此您可能必须为要进行特殊转换的特殊 EAttribute 引入一个令牌。
然后,ValueConverter 会在进行 tovalue 转换时删除实体后缀,并在进行 toString 转换时添加它。
You can modify the Token through using a IValueConverter - this works on Terminal or on Datatype rule so you may have to introduce one for the special EAttribute you want to do the special conversion.
the ValueConverter then would remove the Entity postfix when doing the tovalue conversion and adding it when doing the toString conversion.