Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » [Solved] Getting project in implementation of ISpellingEngine([org.eclipse.ui.texteditor])
[Solved] Getting project in implementation of ISpellingEngine [message #836264] Wed, 04 April 2012 09:43 Go to next message
Boris von Loesch is currently offline Boris von LoeschFriend
Messages: 5
Registered: July 2009
Location: Germany
Junior Member
Hi,

I am one developer of the Texlipse plugin and we encountered a serious bug, which can lead to freezes of Eclipse (bugs.eclipse.org/bugs/show_bug.cgi?id=319098).

The main reason why this bug occurs is the need to get the project of the currently checked IDocument in our implementation of ISpellingEngine, since we have a language preference in the project. I have seen no other possibility but checking which editor is currently active and obtain the project from its IEditorInput (if it belongs to a project). On the one hand this is not very elegant, because it is by no means guaranteed that the checker always checks the currently active editor, and on the other hand can lead to freezes in rare situations where this implementation of ISpellingEngine is set as default spelling engine because of a deadlock in the UI thread.

Is there a better solution to get the project in the check routine of ISpellingEngine?

Thanks in advance,
Boris

[Updated on: Tue, 24 April 2012 12:04]

Report message to a moderator

Re: Getting project in implementation of ISpellingEngine [message #854139 is a reply to message #836264] Mon, 23 April 2012 17:47 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4435
Registered: July 2009
Senior Member

On 4/4/2012 5:43 AM, Boris von Loesch wrote:
> Hi,
>
> I am one developer of the Texlipse plugin and we encountered a serious
> bug, which can lead to freezes of Eclipse
> (bugs.eclipse.org/bugs/show_bug.cgi?id=319098).
> The main reason why this bug occurs is the need to get the project of
> the currently checked IDocument in our implementation of
> ISpellingEngine, since we have a language preference in the project. I
> have seen no other possibility but checking which editor is currently
> active and obtain the project from its IEditorInput (if it belongs to a
> project). On the one hand this is not very elegant, because it is by no
> means guaranteed that the checker always checks the currently active
> editor, and on the other hand can lead to freezes in rare situations
> where this implementation of ISpellingEngine is set as default spelling
> engine because of a deadlock in the UI thread.
>
> Is there a better solution to get the project in the check routine of
> ISpellingEngine?
>
> Thanks in advance,
> Boris

Check the APIs in the org.eclipse.core.filebuffers plug-in, particularly
ITextFileBufferManager#getTextFileBuffer(IDocument) .

--
---
Nitin Dahyabhai
Eclipse WTP Source Editing and JSDT
IBM Rational


_
Nitin Dahyabhai
Eclipse Web Tools Platform
Re: Getting project in implementation of ISpellingEngine (Solved) [message #854972 is a reply to message #854139] Tue, 24 April 2012 12:03 Go to previous message
Boris von Loesch is currently offline Boris von LoeschFriend
Messages: 5
Registered: July 2009
Location: Germany
Junior Member
Nitin Dahyabhai wrote on Mon, 23 April 2012 19:47

Check the APIs in the org.eclipse.core.filebuffers plug-in, particularly
ITextFileBufferManager#getTextFileBuffer(IDocument) .


Hi Nitin,

thank you very much for your valuable tip. It works like a charm Smile. I attach my final method to obtain the project, maybe it is interesting for others.

    private static IProject getProject(IDocument document) {
        ITextFileBufferManager fileBufferMgr = FileBuffers.getTextFileBufferManager();
        ITextFileBuffer fileBuffer = fileBufferMgr.getTextFileBuffer(document);
        
        if (fileBuffer != null) {
            IWorkspace workspace = ResourcesPlugin.getWorkspace();
            IResource res = workspace.getRoot().findMember(fileBuffer.getLocation());
            if (res != null) return res.getProject();        	
        }
        return null;
    }
Previous Topic:JFace tree - saving tree state while refreshing
Next Topic:Filtering action using in org.eclipse.ui.activities
Goto Forum:
  


Current Time: Fri Apr 19 00:54:26 GMT 2024

Powered by FUDForum. Page generated in 0.02083 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top