Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » NPE opening external files
NPE opening external files [message #894553] Mon, 09 July 2012 15:07 Go to next message
Nicola Serreli is currently offline Nicola SerreliFriend
Messages: 26
Registered: July 2009
Junior Member
Hello,

I'm using xtext to develop an editor and during a test, I notice that if I try to open a file located outside eclipse workspace I get a NullPointer Exception:

java.lang.NullPointerException
	at org.eclipse.xtext.ui.editor.folding.DefaultFoldingStructureProvider.handleProjectionEnabled(DefaultFoldingStructureProvider.java:100)
	at org.eclipse.xtext.ui.editor.folding.DefaultFoldingStructureProvider$ProjectionChangeListener.projectionEnabled(DefaultFoldingStructureProvider.java:186)
	at org.eclipse.jface.text.source.projection.ProjectionViewer.fireProjectionEnabled(ProjectionViewer.java:487)
	at org.eclipse.jface.text.source.projection.ProjectionViewer.enableProjection(ProjectionViewer.java:535)
	at org.eclipse.jface.text.source.projection.ProjectionViewer.doOperation(ProjectionViewer.java:1414)
	at org.eclipse.xtext.ui.editor.XtextEditor.installFoldingSupport(XtextEditor.java:471)
	at org.eclipse.xtext.ui.editor.XtextEditor.createPartControl(XtextEditor.java:453)
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.createPartControl(CompatibilityPart.java:129)
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor.createPartControl(CompatibilityEditor.java:95)
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.create(CompatibilityPart.java:300)
....


This happens both if I use "File/open.." menu or if I "drag&drop" the file in the editor area.

I'm using eclipse 4.2 and I do not know if the problem is related to eclipse components or to xtext ones:
I tried to debug the problem and I saw that XtextDocumentProvider.setDocumentContent(IDocument document, IEditorInput editorInput, String encoding) asks super classes to set the content but both do not handle the provided FileStoreEditorInput (both super-classes come from eclipse.ui.editors)

thanks in advance for any hint/suggestion about how solve it
Nicola


ps. note, esternal files of "standard types" (like java, c and txt) are opened without any problem
Re: NPE opening external files [message #894559 is a reply to message #894553] Mon, 09 July 2012 15:20 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
This is a known problem (don't have the bugzilla issue # for it).
Workarounds exist - I have one in cloudsmith/geppetto @ github where I
create a hidden "auto linked" project that automatically links to the
external files that are being opened. The problem is that resources
being edited must be Eclipse Resources as there is otherwise nothing to
tie things like markers and other meta data to.

The solution in Geppetto is not 100% generic, but should be easily
adapted to your dsl.

Regards
- henrik

The topic has been discussed in the forum a number of times.

On 2012-09-07 17:07, Nicola Serreli wrote:
> Hello,
>
> I'm using xtext to develop an editor and during a test, I notice that if
> I try to open a file located outside eclipse workspace I get a
> NullPointer Exception:
>
> java.lang.NullPointerException
> at
> org.eclipse.xtext.ui.editor.folding.DefaultFoldingStructureProvider.handleProjectionEnabled(DefaultFoldingStructureProvider.java:100)
>
> at
> org.eclipse.xtext.ui.editor.folding.DefaultFoldingStructureProvider$ProjectionChangeListener.projectionEnabled(DefaultFoldingStructureProvider.java:186)
>
> at
> org.eclipse.jface.text.source.projection.ProjectionViewer.fireProjectionEnabled(ProjectionViewer.java:487)
>
> at
> org.eclipse.jface.text.source.projection.ProjectionViewer.enableProjection(ProjectionViewer.java:535)
>
> at
> org.eclipse.jface.text.source.projection.ProjectionViewer.doOperation(ProjectionViewer.java:1414)
>
> at
> org.eclipse.xtext.ui.editor.XtextEditor.installFoldingSupport(XtextEditor.java:471)
>
> at
> org.eclipse.xtext.ui.editor.XtextEditor.createPartControl(XtextEditor.java:453)
>
> at
> org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.createPartControl(CompatibilityPart.java:129)
>
> at
> org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor.createPartControl(CompatibilityEditor.java:95)
>
> at
> org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.create(CompatibilityPart.java:300)
>
> ....
>
> This happens both if I use "File/open.." menu or if I "drag&drop" the
> file in the editor area.
>
> I'm using eclipse 4.2 and I do not know if the problem is related to
> eclipse components or to xtext ones:
> I tried to debug the problem and I saw that
> XtextDocumentProvider.setDocumentContent(IDocument document,
> IEditorInput editorInput, String encoding) asks super classes to set the
> content but both do not handle the provided FileStoreEditorInput (both
> super-classes come from eclipse.ui.editors)
>
> thanks in advance for any hint/suggestion about how solve it
> Nicola
>
>
> ps. note, esternal files of "standard types" (like java, c and txt) are
> opened without any problem
Re: NPE opening external files [message #894560 is a reply to message #894559] Mon, 09 July 2012 15:22 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
This geppetto issue: https://github.com/cloudsmith/geppetto/issues/19
has links to more information, and shows what was changed in Geppetto to
allow editing of external files (i.e. the commit delta).

Regards
- henrik

On 2012-09-07 17:20, Henrik Lindberg wrote:
> This is a known problem (don't have the bugzilla issue # for it).
> Workarounds exist - I have one in cloudsmith/geppetto @ github where I
> create a hidden "auto linked" project that automatically links to the
> external files that are being opened. The problem is that resources
> being edited must be Eclipse Resources as there is otherwise nothing to
> tie things like markers and other meta data to.
>
> The solution in Geppetto is not 100% generic, but should be easily
> adapted to your dsl.
>
> Regards
> - henrik
>
> The topic has been discussed in the forum a number of times.
>
> On 2012-09-07 17:07, Nicola Serreli wrote:
>> Hello,
>>
>> I'm using xtext to develop an editor and during a test, I notice that if
>> I try to open a file located outside eclipse workspace I get a
>> NullPointer Exception:
>>
>> java.lang.NullPointerException
>> at
>> org.eclipse.xtext.ui.editor.folding.DefaultFoldingStructureProvider.handleProjectionEnabled(DefaultFoldingStructureProvider.java:100)
>>
>>
>> at
>> org.eclipse.xtext.ui.editor.folding.DefaultFoldingStructureProvider$ProjectionChangeListener.projectionEnabled(DefaultFoldingStructureProvider.java:186)
>>
>>
>> at
>> org.eclipse.jface.text.source.projection.ProjectionViewer.fireProjectionEnabled(ProjectionViewer.java:487)
>>
>>
>> at
>> org.eclipse.jface.text.source.projection.ProjectionViewer.enableProjection(ProjectionViewer.java:535)
>>
>>
>> at
>> org.eclipse.jface.text.source.projection.ProjectionViewer.doOperation(ProjectionViewer.java:1414)
>>
>>
>> at
>> org.eclipse.xtext.ui.editor.XtextEditor.installFoldingSupport(XtextEditor.java:471)
>>
>>
>> at
>> org.eclipse.xtext.ui.editor.XtextEditor.createPartControl(XtextEditor.java:453)
>>
>>
>> at
>> org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.createPartControl(CompatibilityPart.java:129)
>>
>>
>> at
>> org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor.createPartControl(CompatibilityEditor.java:95)
>>
>>
>> at
>> org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.create(CompatibilityPart.java:300)
>>
>>
>> ....
>>
>> This happens both if I use "File/open.." menu or if I "drag&drop" the
>> file in the editor area.
>>
>> I'm using eclipse 4.2 and I do not know if the problem is related to
>> eclipse components or to xtext ones:
>> I tried to debug the problem and I saw that
>> XtextDocumentProvider.setDocumentContent(IDocument document,
>> IEditorInput editorInput, String encoding) asks super classes to set the
>> content but both do not handle the provided FileStoreEditorInput (both
>> super-classes come from eclipse.ui.editors)
>>
>> thanks in advance for any hint/suggestion about how solve it
>> Nicola
>>
>>
>> ps. note, esternal files of "standard types" (like java, c and txt) are
>> opened without any problem
>
>
Re: NPE opening external files [message #894674 is a reply to message #894560] Tue, 10 July 2012 05:51 Go to previous messageGo to next message
Nicola Serreli is currently offline Nicola SerreliFriend
Messages: 26
Registered: July 2009
Junior Member
Thanks for answers and links

Nicola
Re: NPE opening external files [message #894964 is a reply to message #894553] Wed, 11 July 2012 09:02 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Which version of Xtext do you use? This should be fixed in 2.3

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 09.07.12 17:07, schrieb Nicola Serreli:
> Hello,
>
> I'm using xtext to develop an editor and during a test, I notice that if
> I try to open a file located outside eclipse workspace I get a
> NullPointer Exception:
>
> java.lang.NullPointerException
> at
> org.eclipse.xtext.ui.editor.folding.DefaultFoldingStructureProvider.handleProjectionEnabled(DefaultFoldingStructureProvider.java:100)
>
> at
> org.eclipse.xtext.ui.editor.folding.DefaultFoldingStructureProvider$ProjectionChangeListener.projectionEnabled(DefaultFoldingStructureProvider.java:186)
>
> at
> org.eclipse.jface.text.source.projection.ProjectionViewer.fireProjectionEnabled(ProjectionViewer.java:487)
>
> at
> org.eclipse.jface.text.source.projection.ProjectionViewer.enableProjection(ProjectionViewer.java:535)
>
> at
> org.eclipse.jface.text.source.projection.ProjectionViewer.doOperation(ProjectionViewer.java:1414)
>
> at
> org.eclipse.xtext.ui.editor.XtextEditor.installFoldingSupport(XtextEditor.java:471)
>
> at
> org.eclipse.xtext.ui.editor.XtextEditor.createPartControl(XtextEditor.java:453)
>
> at
> org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.createPartControl(CompatibilityPart.java:129)
>
> at
> org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor.createPartControl(CompatibilityEditor.java:95)
>
> at
> org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.create(CompatibilityPart.java:300)
>
> ....
>
> This happens both if I use "File/open.." menu or if I "drag&drop" the
> file in the editor area.
>
> I'm using eclipse 4.2 and I do not know if the problem is related to
> eclipse components or to xtext ones:
> I tried to debug the problem and I saw that
> XtextDocumentProvider.setDocumentContent(IDocument document,
> IEditorInput editorInput, String encoding) asks super classes to set the
> content but both do not handle the provided FileStoreEditorInput (both
> super-classes come from eclipse.ui.editors)
>
> thanks in advance for any hint/suggestion about how solve it
> Nicola
>
>
> ps. note, esternal files of "standard types" (like java, c and txt) are
> opened without any problem
Re: NPE opening external files [message #895030 is a reply to message #894964] Wed, 11 July 2012 12:59 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
On 2012-11-07 11:02, Sebastian Zarnekow wrote:
> Which version of Xtext do you use? This should be fixed in 2.3
>
> Regards,
> Sebastian
Is there a description of how this was fixed somewhere? I am wondering
about if the fix in 2.3 allows editing, and in which context the file is
opened (i.e. what is visible to this file).

Regards
- henrik
Re: NPE opening external files [message #895898 is a reply to message #894964] Mon, 16 July 2012 13:05 Go to previous messageGo to next message
Nicola Serreli is currently offline Nicola SerreliFriend
Messages: 26
Registered: July 2009
Junior Member
Sebastian Zarnekow wrote on Wed, 11 July 2012 05:02
Which version of Xtext do you use? This should be fixed in 2.3

Regards,
Sebastian


Hi Sebastian,

you are right, with Xtext 2.3 I'm able to open external file, even in an empty workspace (no projects).

I just do a quick check and a lot of things are working:
- color and text format
- content assist
- the pop-up with the element documentation (with both mouse hover and content assist)

But there are (at least?) two problems:
- if I press "crtl-left click" on a reference, nothing happens, even if the referenced object is in the same file. Please note that the editor shows correctly the documentation associated to referenced object
- there is no validation while typing. If I ask (through pop-up menu) to force validation, I get NullPointerException:

java.lang.NullPointerException
	at org.eclipse.xtext.ui.editor.validation.AddMarkersOperation.execute(AddMarkersOperation.java:94)
	at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(WorkspaceModifyOperation.java:106)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
	at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:118)
	at org.eclipse.xtext.ui.editor.validation.MarkerIssueProcessor.processIssues(MarkerIssueProcessor.java:58)
	at org.eclipse.xtext.ui.editor.validation.ValidationJob.run(ValidationJob.java:67)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)



clearly, I was not able to check if quick fix is working or not


Regards,
Nicola
Re: NPE opening external files [message #896428 is a reply to message #895898] Wed, 18 July 2012 11:37 Go to previous message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Nicola,

could you please file some tickets for your findings? That would be very
helpful.

Thanks,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 16.07.12 15:05, schrieb Nicola Serreli:
> Sebastian Zarnekow wrote on Wed, 11 July 2012 05:02
>> Which version of Xtext do you use? This should be fixed in 2.3
>>
>> Regards,
>> Sebastian
>
>
> Hi Sebastian,
>
> you are right, with Xtext 2.3 I'm able to open external file, even in an
> empty workspace (no projects).
>
> I just do a quick check and a lot of things are working:
> - color and text format
> - content assist
> - the pop-up with the element documentation (with both mouse hover and
> content assist)
>
> But there are (at least?) two problems:
> - if I press "crtl-left click" on a reference, nothing happens, even if
> the referenced object is in the same file. Please note that the editor
> shows correctly the documentation associated to referenced object
> - there is no validation while typing. If I ask (through pop-up menu) to
> force validation, I get NullPointerException:
>
> java.lang.NullPointerException
> at
> org.eclipse.xtext.ui.editor.validation.AddMarkersOperation.execute(AddMarkersOperation.java:94)
>
> at
> org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(WorkspaceModifyOperation.java:106)
>
> at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
> at
> org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:118)
>
> at
> org.eclipse.xtext.ui.editor.validation.MarkerIssueProcessor.processIssues(MarkerIssueProcessor.java:58)
>
> at
> org.eclipse.xtext.ui.editor.validation.ValidationJob.run(ValidationJob.java:67)
>
> at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
>
>
> clearly, I was not able to check if quick fix is working or not
>
>
> Regards,
> Nicola
>
Previous Topic:Server-side parsing concepts
Next Topic:Export DSL
Goto Forum:
  


Current Time: Fri Apr 19 14:57:21 GMT 2024

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

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

Back to the top