Преглед на файлове

fixed npe for statechart scopes (#2039)

Robert Rudi преди 7 години
родител
ревизия
0074ecebf0
променени са 1 файла, в които са добавени 8 реда и са изтрити 2 реда
  1. 8 2
      plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/scoping/STextGlobalScopeProvider.java

+ 8 - 2
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/scoping/STextGlobalScopeProvider.java

@@ -87,7 +87,10 @@ public class STextGlobalScopeProvider extends ImportUriGlobalScopeProvider {
 	public IScope getScope(Resource context, EReference reference, Predicate<IEObjectDescription> filter) {
 		IScope parentScope = super.getScope(context, reference, filter);
 		parentScope = new SimpleScope(parentScope, filterPropertiesOfLibrary(context, reference, filter).getAllElements());
-		final Statechart statechart = getStatechart(context);
+		Statechart statechart = getStatechart(context);
+		if(statechart == null)
+			return IScope.NULLSCOPE;
+		final String statechartDomain = statechart.getDomainID();
 		parentScope = new TypeSystemAwareScope(parentScope, typeSystem, qualifiedNameProvider,
 				reference.getEReferenceType());
 		IScope result = new FilteringScope(parentScope, new Predicate<IEObjectDescription>() {
@@ -97,7 +100,7 @@ public class STextGlobalScopeProvider extends ImportUriGlobalScopeProvider {
 				if (userData == null)
 					return true;
 
-				return statechart.getDomainID().equals(userData);
+				return statechartDomain.equals(userData);
 			}
 		});
 		result = filterAnnotations(reference, result);
@@ -155,6 +158,9 @@ public class STextGlobalScopeProvider extends ImportUriGlobalScopeProvider {
 					return EcoreUtil.getObjectsByType(specification.getScopes(), StextPackage.Literals.IMPORT_SCOPE);
 				} else {
 					Statechart statechart = getStatechart(resource);
+					if (statechart == null) {
+						return new LinkedHashSet<>();
+					}
 					return EcoreUtil.getObjectsByType(statechart.getScopes(), StextPackage.Literals.IMPORT_SCOPE);
 				}
 			}