Browse Source

Added null check for statechart

Andreas Mülder 13 years ago
parent
commit
bbf1b20579

+ 14 - 9
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/scoping/STextScopeProvider.java

@@ -113,31 +113,32 @@ public class STextScopeProvider extends AbstractDeclarativeScopeProvider {
 
 		Predicate<IEObjectDescription> predicate = calcuateFilterPredicate(
 				context, reference);
-		
+
 		Expression owner = context.getOwner();
 		EObject element = null;
 		if (owner instanceof ElementReferenceExpression) {
-			element = ((ElementReferenceExpression) owner) .getReference();
-		} else if (owner instanceof FeatureCall ) {
-			element = ((FeatureCall)owner).getFeature();
+			element = ((ElementReferenceExpression) owner).getReference();
+		} else if (owner instanceof FeatureCall) {
+			element = ((FeatureCall) owner).getFeature();
 		} else {
 			return getDelegate().getScope(context, reference);
 		}
 
 		IScope scope = IScope.NULLSCOPE;
-		
+
 		if (element instanceof Scope) {
 			scope = Scopes.scopeFor(((Scope) element).getDeclarations());
 			scope = new FilteringScope(scope, predicate);
-		} 
-		
-		if (element instanceof Type ) {
+		}
+
+		if (element instanceof Type) {
 			scope = Scopes.scopeFor(allFeatures((Type) element), scope);
 			scope = new FilteringScope(scope, predicate);
 		}
 
 		if (element instanceof Feature) {
-			scope = Scopes.scopeFor(allFeatures(((Feature) element).getType()),scope);
+			scope = Scopes.scopeFor(allFeatures(((Feature) element).getType()),
+					scope);
 			scope = new FilteringScope(scope, predicate);
 		}
 
@@ -168,6 +169,8 @@ public class STextScopeProvider extends AbstractDeclarativeScopeProvider {
 			EReference reference) {
 		List<EObject> scopeCandidates = Lists.newArrayList();
 		Statechart statechart = getStatechart(context);
+		if (statechart == null)
+			return IScope.NULLSCOPE;
 		EList<Scope> scopes = statechart.getScopes();
 		for (Scope scope : scopes) {
 			if (scope instanceof InterfaceScope) {
@@ -187,6 +190,8 @@ public class STextScopeProvider extends AbstractDeclarativeScopeProvider {
 			EReference reference) {
 		List<EObject> scopeCandidates = Lists.newArrayList();
 		Statechart statechart = getStatechart(context);
+		if (statechart == null)
+			return IScope.NULLSCOPE;
 		EList<Scope> scopes = statechart.getScopes();
 		for (Scope scope : scopes) {
 			if (scope instanceof InterfaceScope) {