eclipse-api

Get the absolute path of the currently edited file in Eclipse

坚强是说给别人听的谎言 提交于 2019-12-03 09:03:05
问题 I'd like to write a plugin that does something with the currently edited file in Eclipse. But I'm not sure how to properly get the file's full path. This is what I do now: IFile file = (IFile) window.getActivePage().getActiveEditor.getEditorInput(). getAdapter(IFile.class); Now I have an IFile object, and I can retrieve it's path: file.getFullPath().toOSString(); However this still only gives me the path relative to the workspace. How can I get the absolute path from that? 回答1: Looks like you

Get the absolute path of the currently edited file in Eclipse

柔情痞子 提交于 2019-12-02 23:11:57
I'd like to write a plugin that does something with the currently edited file in Eclipse. But I'm not sure how to properly get the file's full path. This is what I do now: IFile file = (IFile) window.getActivePage().getActiveEditor.getEditorInput(). getAdapter(IFile.class); Now I have an IFile object, and I can retrieve it's path: file.getFullPath().toOSString(); However this still only gives me the path relative to the workspace. How can I get the absolute path from that? Looks like you want IResource.getRawLocation() . That returns an IPath , which also has a makeAbsolute() method if you