插件:如何在我的eclipse工作区中获得所有可用的类型?

时间:2021-08-04 20:54:54

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.

我正在编写一个eclipse插件,我想获得工作区中可用的所有类型,比如按Ctrl+Shift+T时,而是在列表或数组中。

How can I do it?

我怎么做呢?

1 个解决方案

#1


1  

The relevant code is referenced from the org.eclipse.jdt.internal.ui.dialogs.FilteredTypesSelectionDialog (which the OpenTypeSelectionDialog triggered by ctrl-shift-T inherits from).

相关的代码从org. eclipsee . jdt.internal.ui.dialogs.filteredtypesselectiondialog(按ctrl-shift-T触发的OpenTypeSelectionDialog)中引用。

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.

如果您检查fillContentProvider()方法,您将看到org.eclipse.jdt.core.search。SearchEngine,它通过一个TypeSearchRequestor和TypeItemsFilter来匹配所需的类型。

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.

如果您查看SearchEngine.searchAllTypeNames()和/或其执行的Javadoc,您应该对如何在请求者中获取工作空间类型并相应地处理它们有一个非常清晰的概念。

#1


1  

The relevant code is referenced from the org.eclipse.jdt.internal.ui.dialogs.FilteredTypesSelectionDialog (which the OpenTypeSelectionDialog triggered by ctrl-shift-T inherits from).

相关的代码从org. eclipsee . jdt.internal.ui.dialogs.filteredtypesselectiondialog(按ctrl-shift-T触发的OpenTypeSelectionDialog)中引用。

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.

如果您检查fillContentProvider()方法,您将看到org.eclipse.jdt.core.search。SearchEngine,它通过一个TypeSearchRequestor和TypeItemsFilter来匹配所需的类型。

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.

如果您查看SearchEngine.searchAllTypeNames()和/或其执行的Javadoc,您应该对如何在请求者中获取工作空间类型并相应地处理它们有一个非常清晰的概念。