Skip to content
Snippets Groups Projects
Commit 8491a208 authored by Simon Barner's avatar Simon Barner
Browse files

- Avoid NPE by considering the case that the annotation might not be hooked to the resource yet

refs 2309
parent 5500e623
No related branches found
No related tags found
No related merge requests found
......@@ -32,6 +32,7 @@ import org.eclipse.emf.ecore.EFactory;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.base.model.element.IAnnotatedSpecification;
import org.fortiss.tooling.base.model.element.IModelElement;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.service.IPersistencyService;
/**
......@@ -40,7 +41,7 @@ import org.fortiss.tooling.kernel.service.IPersistencyService;
* @author diewald, barner
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 68F8F5C4D491184B72784AC7242EEADC
* @ConQAT.Rating YELLOW Hash: B97EC7D0532A4B28D92F9CB55F505000
*/
public abstract class ValueProviderBase<T extends IAnnotatedSpecification> implements
IAnnotationValueProvider<T> {
......@@ -199,8 +200,14 @@ public abstract class ValueProviderBase<T extends IAnnotatedSpecification> imple
}
}
// Assign unique id
IPersistencyService.INSTANCE.getTopLevelElementFor(element).prepareIDs(specification);
// Assign unique id (if model element hosting annotation is already hooked to the resource).
// Otherwise, IDs will be assigned to the annotations when the model element is added to the
// resource)
ITopLevelElement topLevelElement =
IPersistencyService.INSTANCE.getTopLevelElementFor(element);
if(topLevelElement != null) {
topLevelElement.prepareIDs(specification);
}
// Hook specification to model element
element.addSpecification(specification);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment