【发布时间】:2018-10-07 23:26:01
【问题描述】:
兴趣是在 eclipse cdt 编辑器中获取打开文件的列表。 假设 aaa.c、bbb.c、ddd.c 是在 eclipse 编辑器中打开的文件。如何获取这些文件的 IFile[]。
【问题讨论】:
标签: eclipse eclipse-plugin eclipse-cdt
兴趣是在 eclipse cdt 编辑器中获取打开文件的列表。 假设 aaa.c、bbb.c、ddd.c 是在 eclipse 编辑器中打开的文件。如何获取这些文件的 IFile[]。
【问题讨论】:
标签: eclipse eclipse-plugin eclipse-cdt
您可以使用IWorkbenchPage getEditorReferences 方法获取所有打开的编辑器的列表。您可以使用它来查找您感兴趣的编辑器。所以:
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorReference [] editors = page.getEditorReferences();
for (IEditorReference editor : editors) {
String editorId = editor.getId();
// TODO test if this is an editor you are interested in
IEditorInput inout = editor.getEditorInput();
IFile file = inout.getAdapter(IFile.class);
...
}
【讨论】: