来自 Xpand 的样本 -

发布于 2024-07-12 05:30:50 字数 178 浏览 7 评论 0原文

我可以得到一些关于 XPand 的好的教程吗?我需要获取有关 LET 等命令的信息。 如果有人能在上面贴一些样本就更好了。

我面临的问题就像......我运行一个“for”循环,在检查某些条件后我需要增加一个计数器。 但我无法这样做。 当我增加计数器时,它会被打印到输出文件中。

提前致谢。

Can i get some good tutorials on XPand.. i need to get info on commands like LET. It would better if some one could post some samples on it.

The problem i am facing is like.. i run a "for" loop and after checking some condition i need to increment a counter . but i am unable to do so. when i increment the counter, it gets printed to the output file.

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

倾城月光淡如水﹏ 2024-07-19 05:30:50

有一个 工作示例,它模板化了 Ant 脚本。 同一篇文章在 DZone 上重新发布。

更具体地说,本文LET 运算符:

<<LET packageName + "." + className AS fqn>>
  the fully qualified name is: <<fqn>>;
<<ENDLET>>

最后,来自 的这篇文章openArchitecureWare 论坛

LET 语句非常简单:它创建一个具有指定值的局部常量以及该常量可见的范围。 这也意味着 LET 语句不能用于循环行为。

事实上,如果你尝试循环,你基本上是在错误的地方解决问题。 XPand 模板仅用于生成文本工件,而生成背后的大多数逻辑应在 Xtensions 中实现。 Xtend 也没有循环构造,但如果您愿意遵循函数式编程范式,则可以找到替代方案。 另外,请注意 oaw.List 的“indexOf”方法。

There is a worked example which templates Ant scripts. The same article is republished on DZone.

More specifically, this paper presents this example on the LET operator:

<<LET packageName + "." + className AS fqn>>
  the fully qualified name is: <<fqn>>;
<<ENDLET>>

Finally, from this post on openArchitecureWare forum:

The LET statement is really simple: it creates a local constant with the specified value and a scope in which this constant is visible. This also means that the LET statement is unusable for looping behavior.

In fact, if you try to loop, you're basically solving problems in the wrong place. XPand templates are only meant for generating textual artifacts while most logic underlying the generation should be implemented in Xtensions. Xtend does not have a loop construct either but it's possible to find an alternative if you're willing to follow the functional programming-paradigm. Also, take note of the 'indexOf' method of oaw.List.

撩人痒 2024-07-19 05:30:50

这个答案与使用第二段发布的第二个问题有关。 您可以使用链运算符 (->) 阻止打印表达式值。
例如:

<<counterInc()->"">>

请参阅官方在线帮助文​​档中的“throwError (Object o)”示例:
http://help. eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.xpand.doc%2Fhelp%2Fch04s02.html

您可能还会发现“计数器扩展”部分对计数器很有帮助Xpand 中的操作

This answer is pertaining to the second question posted using the second paragraph. you can stop an expression value from getting printed using a chain operator (->).
For ex:

<<counterInc()->"">>

See the example for 'throwError (Object o)' in the official online help documentation here:
http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.xpand.doc%2Fhelp%2Fch04s02.html

You may also find the 'Counter extensions' section helpful for counter operations in Xpand

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