Reputation: 1632
I want to make an eclipse plugin which can analyze java code in the current project and display it in the editor.
Scenario:
On right-clicking the java file inside eclipse, I want my plugin option to be seen (which is successfully done) and on clicking it, an editor should open with the contents of that particular java file.
I am stuck at opening the java file and reading its contents.
I think the org.eclipse.jface.text
can be of help.
For editor support, I am using org.eclipse.ui.editors
.
How to proceed with reading the contents of particular java file that has been right clicked ?
I am new to eclipse plugin development. Any help is highly appreciated.
Upvotes: 0
Views: 392
Reputation: 1632
I solved the problem even better way than expected.
In the handler class's execute method , I used IWorkspace
and IWorkspaceRoot
from org.eclipse.core.resources package.
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = workspace.getRoot();
From above code, I had access to each and every resource of the current workspace. I fetched the project using IJavaProject
and filtered java files from the resources.
Upvotes: 1