Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 348256

Summary: [editor] NPE in Open Definition
Product: [Modeling] OCL Reporter: Ed Willink <ed>
Component: CoreAssignee: OCL Inbox <mdt-ocl-inbox>
Status: CLOSED FIXED QA Contact: Ed Willink <ed>
Severity: normal    
Priority: P3 CC: adolfosbh, eclipse
Version: 3.1.0   
Target Milestone: SR1   
Hardware: PC   
OS: Windows Vista   
Whiteboard:
Attachments:
Description Flags
SR1 Fix for Console selections none

Description Ed Willink CLA 2011-06-03 14:25:18 EDT
RC3: In the OCLinEcore tutorial open Tutorial.ecore as OCLinEcore, selerct a reference and Open Declaration

java.lang.NullPointerException
	at org.eclipse.ocl.examples.xtext.oclinecore.ui.OCLinEcoreEditorCallback$XtextEditor_EcoreEditor.getEObject(OCLinEcoreEditorCallback.java:108)
	at org.eclipse.ocl.examples.xtext.oclinecore.ui.OCLinEcoreEditorCallback$XtextEditor_EcoreEditor.access$1(OCLinEcoreEditorCallback.java:106)
	at org.eclipse.ocl.examples.xtext.oclinecore.ui.OCLinEcoreEditorCallback$XtextEditor_EcoreEditor$DummyResourceSet.getEObject(OCLinEcoreEditorCallback.java:89)
	at org.eclipse.xtext.ui.ecore.EcoreEditorOpener.selectAndReveal(EcoreEditorOpener.java:26)
	at org.eclipse.xtext.ui.editor.LanguageSpecificURIEditorOpener.open(LanguageSpecificURIEditorOpener.java:82)
	at org.eclipse.xtext.ui.editor.LanguageSpecificURIEditorOpener.open(LanguageSpecificURIEditorOpener.java:70)
	at org.eclipse.xtext.ui.editor.GlobalURIEditorOpener.open(GlobalURIEditorOpener.java:61)
	at org.eclipse.ocl.examples.xtext.essentialocl.ui.model.BaseURIEditorOpener.open(BaseURIEditorOpener.java:32)
	at org.eclipse.xtext.ui.editor.hyperlinking.XtextHyperlink.open(XtextHyperlink.java:26)
Comment 1 Ed Willink CLA 2011-06-03 15:28:45 EDT
Cannot reproduce. Must be dependent on a complex preamble.

The NPE itself suggests that editor.getDocument() returned null.

A simple guard will at least just leave nothing happening quietly.

Since hard to reproduce patch for RC4 not essential.
Comment 2 Ed Willink CLA 2011-06-03 15:59:33 EDT
Problem is that the OCLinEcore editor is editing a *.ecore file.

The OCLinEcore editor knows that the *.ecore is an Xtext resource and so the subsequent fragment makes sense.

The Console thinks the *.ecore is an Ecore resource and IAEs on the inconsistent fragment.

Need to normalize everything to Pivot URIs. Too hard for RC4.

Works ok from an *.oclinecore, except that the selection is a CS class rather than the AST class.
Comment 3 Ed Willink CLA 2011-08-23 03:31:49 EDT
(In reply to comment #0)
> RC3: In the OCLinEcore tutorial open Tutorial.ecore as OCLinEcore, selerct a
> reference and Open Declaration
> 
> java.lang.NullPointerException

Still cannot reproduce; perhaps Xtext fixed a race condition that allowed access to a half initialized editor. Anyway NPE guard added to OCLinEcoreEditorCallback$XtextEditor_EcoreEditor.getEObject.


(In reply to comment #2)
> Problem is that the OCLinEcore editor is editing a *.ecore file.
It can go wrong both ways.

OCLConsolePage.refreshSelection now gets TypeManager to load the pivot for a selected Ecore or UML object.

OCLConsolePage's selectionChanged now converts a CS selection from an Outline to a pivot selection.

Fixes pushed to master.
Comment 4 Ed Willink CLA 2011-08-23 03:33:29 EDT
Created attachment 201970 [details]
SR1 Fix for Console selections
Comment 5 Ed Willink CLA 2011-08-23 03:34:00 EDT
Please review patch for SR1.
Comment 6 Axel Uhl CLA 2011-08-23 06:01:22 EDT
Source changes look ok to me, but Adolfo should again review too with a working xtext set-up.
Comment 7 Ed Willink CLA 2011-08-29 04:07:45 EDT
Rebase following bug 351578 now in bug/348256sr1 branch.

Adolfo: any chance of oking it today for RC2?
Comment 8 Adolfo Sanchez-Barbudo Herrera CLA 2011-08-29 14:50:08 EDT
Ed,

I'm sorry for the delay but I've been at home due to an illness...

Last week I had some problems with the Xtext test cases (still to be solved) in my local workspace and I'm afraid that I didn't try the issue in a second instance so I couldn't properly do the review.

On the other hand the code looked/looks OK to me... so feel free to commit it today.

Let's see if tomorrow I feel better to go to work and do the SR RC2, otherwise I'll do it from my home (probably in the afternoon/evening).

Best Regards,
Adolfol.
Comment 9 Ed Willink CLA 2011-08-29 16:19:35 EDT
Thanks. Hope you feel better soon.

Pushed to maintenance/R3_1 for SR1 RC2.
Comment 10 Ed Willink CLA 2011-11-10 15:04:32 EST
*** Bug 348251 has been marked as a duplicate of this bug. ***
Comment 11 Ed Willink CLA 2013-05-20 11:35:26 EDT
CLOSED after a year in the RESOLVED state.