xText 2 - 处理令牌

发布于 2025-01-01 16:18:20 字数 439 浏览 2 评论 0原文

是否可以在将令牌分配给 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

对你而言 2025-01-08 16:18:20

您可以通过使用 IValueConverter 来修改令牌 - 这适用于终端或数据类型规则,因此您可能必须为要进行特殊转换的特殊 EAttribute 引入一个令牌。

EntityName: ID 'Entity';
MyRuleWithModifiedToken: 'entity' name=EntityName ....;

然后,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.

EntityName: ID 'Entity';
MyRuleWithModifiedToken: 'entity' name=EntityName ....;

the ValueConverter then would remove the Entity postfix when doing the tovalue conversion and adding it when doing the toString conversion.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文