I'm making an Eclipse plug-in that requires access to code written in the Eclipse editor. I've followed the process mentioned in the link. Accessing Eclipse editor code But it's showing filepath instead of code in the message box. The getEditorInput() of IEditorEditor class isn't doing what it should do according to the link. Here's my code. Please help me find what i'm doing wrong.
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
IEditorPart editor = ((IWorkbenchPage) PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage()).getActiveEditor();
IEditorInput input = (IEditorInput) editor.getEditorInput(); // accessing code from eclipse editor
String code = input.toString();
MessageDialog.openInformation(
window.getShell(),
"Project",
code);
return null;
}
And here's snap of the output.