作用域对象的 Xtext 示例
我正在寻找一个示例(在 XText 中),说明如何在用户定义的对象成员上实现代码完成。据我所知,我需要使用 IScope,但所有这些如何连接在一起还不清楚。
鉴于 trait
是用户定义的类型,当我输入 name.< 时,如何构建语法来编码完成/验证
String
中包含的方法。 /代码>?
trait String {
def toLowerCase(): String
def toUpperCase(): String
}
val name = new String()
name.toLowerCase()
谢谢
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这在很大程度上取决于你的语法,你必须做什么才能采用范围界定。
假设您的语法类似于
您的范围提供程序,
您可以在此处找到有关该主题的博客系列:
https://web.archive.org/web/20130129085620/http://blogs.itemis.de/stundzig/archives/773
It highly depends on your grammar what you have to do to adopt scoping.
Let us say you have a grammar like
then your scopeprovider would look like
You can find a blog series on the topic here:
https://web.archive.org/web/20130129085620/http://blogs.itemis.de/stundzig/archives/773
在我关于 Xtext 的书中,“使用 Xtext 和 Xtend 实现特定领域语言”,https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend ,有一章关于范围为“较小的”Java 语言(也处理继承)。您可以在此处找到示例来源: https://github.com/LorenzoBettini/packtpub- xtext-book-examples
In my book on Xtext, "Implementing Domain-Specific Languages with Xtext and Xtend", https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend , there is a chapter about scoping for a "smaller" Java language (dealing also with inheritance). You can find the sources of examples here: https://github.com/LorenzoBettini/packtpub-xtext-book-examples