Просмотр исходного кода

inference result may be null for invalid types

Andreas Muelder 9 лет назад
Родитель
Сommit
402ad0bc3a

+ 4 - 0
plugins/org.yakindu.base.types/src/org/yakindu/base/types/inferrer/ITypeSystemInferrer.java

@@ -13,6 +13,7 @@ package org.yakindu.base.types.inferrer;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.eclipse.core.runtime.Assert;
 import org.eclipse.emf.ecore.EObject;
 import org.yakindu.base.types.Type;
 import org.yakindu.base.types.validation.IValidationIssueAcceptor;
@@ -36,10 +37,13 @@ public interface ITypeSystemInferrer {
 		private List<InferenceResult> bindings = new ArrayList<>();
 
 		protected InferenceResult(Type type) {
+			Assert.isNotNull(type);
 			this.type = type;
 		}
 
 		protected InferenceResult(Type type, List<InferenceResult> bindings) {
+			Assert.isNotNull(type);
+			Assert.isNotNull(bindings);
 			this.type = type;
 			this.bindings.addAll(bindings);
 		}

+ 4 - 2
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/scoping/STextScopeProvider.java

@@ -34,6 +34,7 @@ import org.yakindu.base.types.ComplexType;
 import org.yakindu.base.types.EnumerationType;
 import org.yakindu.base.types.Type;
 import org.yakindu.base.types.inferrer.ITypeSystemInferrer;
+import org.yakindu.base.types.inferrer.ITypeSystemInferrer.InferenceResult;
 import org.yakindu.base.types.typesystem.ITypeSystem;
 import org.yakindu.sct.model.sgraph.SGraphPackage;
 import org.yakindu.sct.model.sgraph.Scope;
@@ -133,12 +134,13 @@ public class STextScopeProvider extends AbstractDeclarativeScopeProvider {
 		}
 
 		IScope scope = IScope.NULLSCOPE;
-		Type ownerType = typeInferrer.infer(owner).getType();
+		InferenceResult result = typeInferrer.infer(owner);
+		Type ownerType = result != null ? result.getType() : null;
 
 		if (element instanceof Scope) {
 			scope = Scopes.scopeFor(((Scope) element).getDeclarations());
 			return new FilteringScope(scope, predicate);
-		}else{
+		}else if(ownerType != null){
 			scope = Scopes.scopeFor(typeSystem.getPropertyExtensions(ownerType));
 			scope = Scopes.scopeFor(typeSystem.getOperationExtensions(ownerType),scope);
 		}