开发者

How do i find the project of the contents of an ITextViewer?

开发者 https://www.devze.com 2022-12-13 16:59 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消