Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext and document providers
Xtext and document providers [message #722712] Tue, 06 September 2011 14:59 Go to next message
raffaello  is currently offline raffaello Friend
Messages: 5
Registered: June 2011
Junior Member
Hi,

I'm developing an Eclipse product and i created an editor for my product language through Xtext. Yesterday I integrated Saros(I can't paste the link but the project can be found on sourceforge) in my project and i found that when the Saros's plugin tryed to get a IDocumentProvider for an opened XtextEditor fails and returns a document provider which is not the XTextDocumentProvider. Saros obtains the document provider through:
DocumentProviderRegistry.getDefault().getDocumentProvider(input);

where input is an IEditorInput.

If i change the above code with this:
Set<IEditorPart> set = EditorAPI.getOpenEditors();
        if (set.size() > 0) {
            Iterator<IEditorPart> current = set.iterator();
            while (current.hasNext()) {
                IEditorPart part = current.next();
                if (part.getEditorInput().equals(input)
                    && part instanceof ExtLinkedXtextEditor)
                    return ((ExtLinkedXtextEditor) part).getDocumentProvider();
            }
        }

I can obtain the right document provider.

I tryed to use the org.eclipse.ui.editors.documentProviders extension point to associate the XtextDocumentProvider to my file extension but in that case i get a null pointer exception when the function createEmptyDocument is called.

<extension
         point="org.eclipse.ui.editors.documentProviders">
      <provider
            class="org.eclipse.xtext.ui.editor.model.XtextDocumentProvider"
            extensions="s3d"
            id="org.xvr.s3d.document_provider"
            inputTypes="org.eclipse.ui.part.FileEditorInput">
      </provider>
   </extension>


java.lang.NullPointerException at org.eclipse.xtext.ui.editor.model.XtextDocumentProvider.createEmptyDocument(XtextDocumentProvider.java:82)


How can I fix this problem?

thanks a lot

Raffaello
Re: Xtext and document providers [message #722817 is a reply to message #722712] Tue, 06 September 2011 19:23 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

i have no idea on documentprovider but never the less: shouldn't you guicify this (using the ExecutableExtensionFactory of your dsl):

<extension
         point="org.eclipse.ui.editors.documentProviders">
      <provider
            class="org.xtext.example.mydsl.ui.MyDslExecutableExtensionFactory:org.eclipse.xtext.ui.editor.model.XtextDocumentProvider"
            extensions="s3d"
            id="org.xvr.s3d.document_provider"
            inputTypes="org.eclipse.ui.part.FileEditorInput">
      </provider>
   </extension>


~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext and document providers [message #722928 is a reply to message #722817] Wed, 07 September 2011 08:33 Go to previous message
raffaello  is currently offline raffaello Friend
Messages: 5
Registered: June 2011
Junior Member
Hi Christian,

Thanks a lot for your reply. It fixed the problem.

Now Eclipse provide the right document provider for my document editors. But probably i'm doing other mistakes.

Saros registers a IDocumentListener in order to be notified about documentAboutToBeChanged events. Through the debugger i saw that the registration correctly adds a IDocumentListener to the document. But when i type something, in the fireDocumentAboutToBeChanged()function inside the AbstractDocument class the document doesn't have the Saros's listener. Seems like the two IDocuments are different.

This happens if i get the IDocumentProvider through
DocumentProviderRegistry.getDefault().getDocumentProvider(input);


If i use the other solution, and i get the document provider from the EditorPart, all works fine.

Which could be the problem?

Thanks

Raffaello
Previous Topic:(no subject)
Next Topic:Need org.eclipselabs.xtext.xtend plugin
Goto Forum:
  


Current Time: Thu Apr 25 19:46:36 GMT 2024

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

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

Back to the top