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

Bug 484544

Summary: NPE in TraceabilityMarkerNavigationProvider when no representation element exists
Product: [Modeling] Sirius Reporter: Yvan Lussaud <yvan.lussaud>
Component: CoreAssignee: Project inbox <sirius.core-inbox>
Status: CLOSED FIXED QA Contact: Laurent Redor <laurent.redor>
Severity: normal    
Priority: P3 CC: florian.barbin, laurent.redor
Version: 3.1.0Keywords: triaged
Target Milestone: 4.0.0M5   
Hardware: PC   
OS: Linux   
See Also: https://git.eclipse.org/r/64976
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=d4ce5d750def671d3cee2de9ca410a1dc271bc32
https://git.eclipse.org/r/73468
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=81484fb9b62c8098572164f95e7a428da2d5d7fe
Whiteboard: trivial

Description Yvan Lussaud CLA 2015-12-17 03:15:44 EST
When using TraceabilityMarkerNavigationProvider on a semantic element that have no representation on a diagram an NPE is thrown

shadowMarker.setAttribute(TraceabilityMarkerNavigationProvider.REPRESENTATION_ELEMENT_ID, resource.getURIFragment(representationElementToSelect).toString())

representationElementToSelect is null... If the representation of the element is the diagram itself the representationElementToSelect is also null.
Comment 1 Eclipse Genie CLA 2016-01-22 04:47:30 EST
New Gerrit change created: https://git.eclipse.org/r/64976
Comment 3 Florian Barbin CLA 2016-01-28 07:47:53 EST
Merged on master
Comment 4 Laurent Redor CLA 2016-05-23 10:57:34 EDT
Can you please add steps to reproduce? I try to validate with Sirius 4.0.0. I have no NPE with the scenario I used. But I have neither error with Sirius 3.1.5 so I'm not sure of the scenario.
Comment 5 Yvan Lussaud CLA 2016-05-24 03:19:26 EDT
You should trigger this bug programmatically.

DialectEditor editorPart = ...; // any opened Sirius editor

final TraceabilityMarkerNavigationProvider navigationProvider = new TraceabilityMarkerNavigationProvider((DialectEditor)editorPart);

EObject eObject = ...; // the root of the diagram or any EObject not represented on the diagram but present in the resource
final URI resourceURI = eObject.eResource().getURI();
final String resourcePath = resourceURI.toPlatformString(true);
final IResource resource = ResourcesPlugin.getWorkspace().getRoot().getFile(
					new Path(resourcePath));

final IMarker marker = resource.createMarker(EValidator.MARKER);
marker.setAttribute(EValidator.URI_ATTRIBUTE, EcoreUtil.getURI(eObject).toString());


navigationProvider.gotoMarker(marker); // NPE here
Comment 6 Florian Barbin CLA 2016-05-24 04:43:44 EDT
Yvan added the scenario. I set the ticket as resolved.
Comment 7 Eclipse Genie CLA 2016-05-24 08:57:56 EDT
New Gerrit change created: https://git.eclipse.org/r/73468
Comment 8 Laurent Redor CLA 2016-05-24 08:59:38 EDT
Verified on Sirius 4.0.0 RC1 (4.0.0.201605180923)

A test auto will be added according to scenario of comment 5.
Comment 10 Pierre-Charles David CLA 2016-06-24 08:01:24 EDT
Available in Sirius 4.0.0.