RadRails、Ruby、内容辅助和方法

发布于 2024-11-19 18:11:33 字数 660 浏览 10 评论 0原文

我是 Ruby 新手,目前正在使用一个我不熟悉的 API。为了使用有助于我学习的代码补全,我在 Eclipse 中安装了 RadRails。但是,我在使用内容辅助时遇到了问题:具体来说,内容辅助不会显示 API 中对象的方法。

例如,我的对象之一 ins 表示加载的 XBRL 实例文档。如果我运行 ins.methods,该列表包含我想要的所有方法,包括 API 中的方法(例如允许我访问实例中项目的函数):

...
项目
全部项目
item_all_groupby_vocab
item_all_map
按词汇逐项
item_ctx_filter
...
等等。

但是,如果我只是输入 ins。启用内容辅助后,它仅显示以下选项:

dclone
宝石
gem_original_require
JSON
路径名(路径)
...
等等

这似乎是系统选项。结果,内容辅助暴露了我实际想要使用的方法中的零个。如果我提前知道这些方法并开始输入它们,我最终可以通过按 Ctrl+空格键让内容辅助将它们提供给我。然而,这需要我提前知道自己想要什么;因为我用它来探索 API,所以这对我不起作用。

有谁知道如何让 RadRails/Eclipse 向我展示正确的方法?

问候, 马特

I am new to Ruby, and I am currently working with an API which is unfamiliar to me. In order to use code completion, which helps me learn, I installed RadRails in Eclipse. However, I am having trouble with Content Assist: specifically, the Content Assist does not reveal the methods for objects in the API.

For example, one of my objects, ins, represents a loaded XBRL instance document. If I run ins.methods, the list contains all of the methods I want, including those in the API (such as functions that allow me to access items in the instance):

...
item
item_all
item_all_groupby_vocab
item_all_map
item_by_vocab
item_ctx_filter
...
etc.

However, if I just type ins. with Content Assist enabled, it only shows options like:

dclone
gem
gem_original_require
JSON
Pathname(path)
...
etc.

which appear to be system options. As a result, the Content Assist exposes exactly zero of the methods I actually want to use. If I know the methods ahead of time and start typing them, I can get Content Assist to give them to me, eventually, by pressing Ctrl+Space. However, that requires me to know what I want ahead of time; since I am using this to explore the API, that doesn't work for me.

Does anyone know how to get RadRails/Eclipse to show me the correct methods?

Regards,
Matt

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

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

发布评论

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

评论(1

南冥有猫 2024-11-26 18:11:33

这是动态语言和 IDE/编辑器固有的普遍问题。 IDE 必须猜测正在调用代码辅助的变量的类型,并从中生成适用方法的列表。

IRB 在运行时具有类型信息,因此它知道应用哪些方法。 IDE 尝试通过静态分析代码(而不是运行代码)来猜测类型。

话虽如此,IDE 通常应该能够正确猜测。提供正在调用的代码片段的更大上下文将有助于研究我们是否可以为此对象提供有用的内容帮助。您可能需要在此处提交包含版本号和示例代码的票证:http://aptana.com/r /apbugs

This is a general problem inherent to dynamic languages and IDEs/editors. The IDE has to guess at the type of the variable that the code assist is being invoked upon, and from that generate the list of applicable methods.

IRB has type information at runtime, so it knows what methods apply. The IDE is trying to guess the type by analyzing your code statically (not running it).

Having said that, the IDE should often be able to guess correctly. Providing the larger context of the snippet of code that this is being invoked on would be helpful to look into whether or not we could provide helpful content assist on this object. You may want to file a ticket with the version number, and the sample code here: http://aptana.com/r/apbugs

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