Explorar o código

added null pointer checks

benjamin.schwertfeger@gmail.com %!s(int64=13) %!d(string=hai) anos
pai
achega
ad8199c84c

+ 3 - 2
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/validation/STextJavaValidator.java

@@ -149,7 +149,7 @@ public class STextJavaValidator extends AbstractSTextJavaValidator {
 						StextPackage.Literals.REACTION_TRIGGER__GUARD_EXPRESSION);
 			}
 		} catch (TypeCheckException ex) {
-			//This is handled by checkExpression
+			// This is handled by checkExpression
 		}
 
 	}
@@ -194,7 +194,8 @@ public class STextJavaValidator extends AbstractSTextJavaValidator {
 	}
 
 	protected void checkFeatureCallEffect(FeatureCall call) {
-		if (!(call.getFeature() instanceof Operation)) {
+		if (call.getFeature() != null
+				&& !(call.getFeature() instanceof Operation)) {
 			if (call.getFeature() instanceof Property) {
 				error("Access to property '"
 						+ nameProvider.getFullyQualifiedName(call.getFeature())

+ 3 - 0
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/validation/TypeInferrer.xtend

@@ -61,6 +61,9 @@ class TypeInferrer implements org.yakindu.sct.model.stext.validation.ITypeInferr
 	org.yakindu.sct.model.stext.validation.TypeInferrerCache cache
 	
 	override getType(Statement stmt) {
+		if (stmt == null) {
+			return null;
+		}
 		cache.get(stmt, this)
 	}
 	

+ 10 - 2
plugins/org.yakindu.sct.model.stext/xtend-gen/org/yakindu/sct/model/stext/validation/TypeInferrer.java

@@ -60,8 +60,16 @@ public class TypeInferrer implements ITypeInferrer, ICacheableTypeAnalyzer {
   private TypeInferrerCache cache;
   
   public Type getType(final Statement stmt) {
-    Type _get = this.cache.get(stmt, this);
-    return _get;
+    Type _xblockexpression = null;
+    {
+      boolean _equals = Objects.equal(stmt, null);
+      if (_equals) {
+        return null;
+      }
+      Type _get = this.cache.get(stmt, this);
+      _xblockexpression = (_get);
+    }
+    return _xblockexpression;
   }
   
   protected Type _inferType(final Statement statement) {