I am devloping a plug-in for eclipse that present metrics of Xtext-project.
I should present at in two levels : Xtext file and the all project.
in order to get details about the file I am using the following code in order to extract the Xtext file :
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorPart activeEditor = page.getActiveEditor();
if (activeEditor instanceof XtextEditor) {
XtextEditor xtextEditor = (XtextEditor) activeEditor;
xtextEditor.getDocument().readOnly((XtextResource resource) -> {
ResourceHandler.resource = resource;
});
and It works good on the current open Xtext file.
Now I want to get all the Xtext files in current eclipse project.
I tried the following code,but it doesnt seem to work :
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();
for (IWorkbenchWindow window : windows) {
IWorkbenchPage[] pages = window.getPages();
for (IWorkbenchPage page : pages) {
IEditorPart activeEditor = page.getActiveEditor();
if (activeEditor instanceof XtextEditor) {
XtextEditor xtextEditor = (XtextEditor) activeEditor;
xtextEditor.getDocument().readOnly((XtextResource resource) -> {
resourceList.add(resource);
the best solution for me is getting a list of XtextResource.
thanks.