1

Interest is to get list of opened files in eclipse cdt editor. Lets say aaa.c, bbb.c, ddd.c are the files opened in eclipse editor. How to get the IFile[] for these files.

1 Answers1

2

You can get a list of all open editors using the IWorkbenchPage getEditorReferences method. You can use this to find the editors you are interested in. So:

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);

  ...
}
greg-449
  • 109,219
  • 232
  • 102
  • 145