简体   繁体   English

Eclipse插件开发找出ICompilationUnit属于哪个workingSet

[英]Eclipse Plugin Developement find out which workingSet an ICompilationUnit belongs to

I have an ICompilationUnit and try to find out which workingSet it belongs to , or if it even has a workingSet. 我有一个ICompilationUnit,尝试找出它属于哪个workingSet,或者什至有一个workingSet。 I have looked at the diffrent methods that ICompilationUnit has, howeber i did not find anything that helps. 我已经看过ICompilationUnit拥有的不同方法,但是我没有找到任何有用的方法。 Does anyone have an idea? 有人有主意吗?

A compilation unit may be a member of 0, 1, or many working sets. 编译单元可以是0、1或许多工作集的成员。 You will have to search through the list of working sets seeing which contain it. 您将必须在工作集列表中进行搜索,以查看其中包含哪些工作集。

Get the working sets with: 通过以下方式获取工作集:

IWorkingSetManager manager = PlatformUI.getWorkbench().getWorkingSetManager();

IWorkingSet [] sets = manager.getAllWorkingSets();

for each working set get the members with: 对于每个工作集,使成员具有:

IAdaptable [] members = set.getElements();

Members can be many things, instanceof ICompilationUnit may work for some members or you may need to adapt: 成员可以是很多事情, instanceof ICompilationUnit可能对某些成员instanceof ICompilationUnit ,或者您可能需要调整:

ICompilationUnit unit = (ICompilationUnit)member.getAdapter(ICompilationUnit.class);

Note: the exact syntax of the getAdapter call varies depending on the Eclipse release as generics support was added in 4.5. 注意: getAdapter调用的确切语法因Eclipse版本而异,因为在4.5中添加了泛型支持。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM