插件:如何获取 eclipse 工作区中可用的所有类型?
我正在编写一个 Eclipse 插件,我想获取工作区中可用的所有类型,
就像按 Ctrl+Shift+T 时一样,
但在列表或数组中。
我该怎么做呢?
I'm writing an eclipse plugin, and I want to get all the types that are available in my workspace,
like when pressing Ctrl+Shift+T,
but in a list or array.
How can I do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
相关代码引用自org.eclipse.jdt.internal.ui.dialogs.FilteredTypesSelectionDialog(由ctrl-shift-T 继承自)。
如果您检查 fillContentProvider() 方法,您将看到它是 org.eclipse.jdt.core.search.SearchEngine,它传递了 TypeSearchRequestor 和 TypeItemsFilter 以匹配所需的类型。
如果您查看 SearchEngine.searchAllTypeNames() 的 Javadoc 和/或调试其执行,您应该非常清楚如何将工作区类型获取到请求者中,并相应地处理它们。
The relevant code is referenced from the org.eclipse.jdt.internal.ui.dialogs.FilteredTypesSelectionDialog (which the OpenTypeSelectionDialog triggered by ctrl-shift-T inherits from).
If you inspect the fillContentProvider() method you'll see it the org.eclipse.jdt.core.search.SearchEngine, which is passed a TypeSearchRequestor and TypeItemsFilter to match the required types.
If you look at the Javadoc for SearchEngine.searchAllTypeNames() and/or debug its execution, you should have a pretty clear idea how to obtain the workspace types into a requestor, and process them accordingly.