How do i find the project of the contents of an ITextViewer?
I'm trying to implement a HyperlinkDetector for an Eclipse plug-in and the callback method is givin开发者_Python百科g me an ITextViewer to work with.
How do i get the project, IPath or IFile of the viewer's IDocument?
Apparently the concept of an IDocument is to only allow access to the content regardless of the source. All i can come up with is to check the active editor part in the workbench...Since it's Java code i'm working on, the actual type is a JavaSourceViewer if that helps.
After looking at the article Abstract Syntax Tree, may be you could look for the right path by asking the ITextFileBufferManager
ITextFileBufferManager bufferManager = FileBuffers.getTextFileBufferManager(); // get the buffer manager
Use then getTextFileBuffer()
ITextFileBuffer getTextFileBuffer(IDocument document);
If you get a ITextFileBuffer
, you can call on it getLocation()
and get back its IPath
.
精彩评论