tags:

views:

28

answers:

1

I'm trying to implement a HyperlinkDetector for an Eclipse plug-in and the callback method is giving 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.

+2  A: 

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.

VonC
What the... that actually works!
Stroboskop