From 513c4e7d67820ba7c3248f8e5c666b25e778546c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Emma=20S=C3=B6derberg?= <emma.m.soderberg@gmail.com>
Date: Mon, 25 Jun 2018 22:10:28 +0200
Subject: [PATCH] Updates code generation for incremental/region and
 incremental/param.

- Adds enter/exit construction for List constructor.
- Adds handler check to setChild for region to prevent duplicate notificaiton on the same handler.
- Adds check of computed OR created to handler when reacting to dependency change.
---
 src/template/ast/NodeConstructor.tt   | 2 ++
 src/template/incremental/ASTChange.tt | 2 +-
 src/template/incremental/DDGNode.tt   | 2 +-
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/template/ast/NodeConstructor.tt b/src/template/ast/NodeConstructor.tt
index ba43b91a..2c5963f8 100644
--- a/src/template/ast/NodeConstructor.tt
+++ b/src/template/ast/NodeConstructor.tt
@@ -78,10 +78,12 @@ OptDecl.constructor = [[
 # A list constructor that builds a list with all arguments
 ListDecl.constructor = [[
   public $List.$List(T... initialChildren) {
+    $include(State.incHookConstructionStart)
     children = new $ASTNode[initialChildren.length];
     for (int i = 0; i < children.length; ++i) {
       addChild(initialChildren[i]);
     }
+    $include(State.incHookConstructionEnd)
   }
 ]]
 
diff --git a/src/template/incremental/ASTChange.tt b/src/template/incremental/ASTChange.tt
index 9e7ddcfe..5a27cc91 100644
--- a/src/template/incremental/ASTChange.tt
+++ b/src/template/incremental/ASTChange.tt
@@ -116,7 +116,7 @@ if (!state().IN_CONSTRUCTION && !(state().IN_COMPUTATION > 0)) {
   if (h != null) {
     h.notifyDependencies();
   }
-  if (i == numChildren) {
+  if (i == numChildren && h != handler()) {
     handler().notifyDependencies();
   }
 $endif
diff --git a/src/template/incremental/DDGNode.tt b/src/template/incremental/DDGNode.tt
index ebba919b..115e9cc8 100644
--- a/src/template/incremental/DDGNode.tt
+++ b/src/template/incremental/DDGNode.tt
@@ -242,7 +242,7 @@ $endif
   // React to change
 
   public void dependencyChanged() {
-    if (isComputed()) {
+    if (isComputed() || isCreated()) {
       setEmpty();
 $if (IncrementalTrack)
       trackedFlushes++;
-- 
GitLab