I'm creating an editor for Eclipse. Right now the editor fires up with the user creates a new file with the appropriate extension. My question is, how can I get a reference to the project in which the file resides? For example, say I have a workspace with 2 projects, P1 and P2. I right click P2 and create a new file, can I get a reference to P2 from this somehow?
Ultimately I need to reference the AST or Java Model of the project but even a String identifying the project would work.
I think, the answer is simply IFile.getProject() would work...
If you work with a FileEditorInput in the init() method, you could use the following code to obtain the searched project resource:
FileEditorInput fileInput = (FileEditorInput) input; fileInput.getFile().getProject();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With