From 706f720571b1e5b3342d3a9fb5d9680c3f9f2a9e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Emma=20S=C3=B6derberg?= <emma.m.soderberg@gmail.com>
Date: Fri, 29 Jun 2018 10:04:41 +0200
Subject: [PATCH] Updates incremental code generation to comply with
 refactoring of generated code for parameterized NTAs.

Parameterized NTAs used to have a List node as parent but this has been changed to a plain ASTNode
referred to as a proxy node. The incremental implementation generated additional code for Lists to
distinguish internal NTA lists from normal lists and made use of iteration over list children.
---
 src/jastadd/incremental/IncrementalEval.jadd |  2 -
 src/template/ast/Attributes.tt               |  2 -
 src/template/incremental/NTAs.tt             | 37 ---------------
 src/template/incremental/Notification.tt     | 49 +++-----------------
 4 files changed, 6 insertions(+), 84 deletions(-)

diff --git a/src/jastadd/incremental/IncrementalEval.jadd b/src/jastadd/incremental/IncrementalEval.jadd
index be4e8845..6b38fe05 100644
--- a/src/jastadd/incremental/IncrementalEval.jadd
+++ b/src/jastadd/incremental/IncrementalEval.jadd
@@ -38,8 +38,6 @@ aspect IncrementalEval {
 
     tt.expand("ASTDecl.relativeNodeIDMethodWithRewrite", out);
 
-    tt.expand("List.internalNTAList", out);
-
     tt.bind("NtaIndexCheck", emitNtaIndexCheckString());
     tt.expand("ASTDecl.childIsNtaMethod", out);
 
diff --git a/src/template/ast/Attributes.tt b/src/template/ast/Attributes.tt
index 407e5b18..ec0f76f5 100644
--- a/src/template/ast/Attributes.tt
+++ b/src/template/ast/Attributes.tt
@@ -231,7 +231,6 @@ SynDecl.higherOrderAttributeCode:norewrite [[
 $if(#isParameterized)
 if (#(signature)_proxy == null) {
   #(signature)_proxy = new $ASTNode();
-  $include(AttrDecl.incHookCreateNtaList)
   #(signature)_proxy.setParent(this);
 }
 if (#(signature)_value != null) {
@@ -246,7 +245,6 @@ SynDecl.higherOrderAttributeCode:rewritesEnabled [[
 $if(#isParameterized)
 if (#(signature)_proxy == null) {
   #(signature)_proxy = new $ASTNode();
-  $include(AttrDecl.incHookCreateNtaList)
   $if(LegacyRewrite)
   #(signature)_proxy.is$$Final = true;
   $endif
diff --git a/src/template/incremental/NTAs.tt b/src/template/incremental/NTAs.tt
index 9fac34d9..6580f15c 100644
--- a/src/template/incremental/NTAs.tt
+++ b/src/template/incremental/NTAs.tt
@@ -38,40 +38,3 @@ $if(IncrementalEnabled)
   }
 $endif
 ]]
-
-List.internalNTAList = [[
-$if(IncrementalEnabled)
-$if(#isListDecl)
-  /** @apilevel internal */
-  public boolean $List.inc_internalNTAList = false;
-
-  /** @apilevel internal */
-  public java.util.Map $List.inc_internalNTAList_map;
-
-  /** @apilevel internal */
-  public void $List.inc_internalNTAList(java.util.Map m) {
-    inc_internalNTAList = true;
-    inc_internalNTAList_map = m;
-  }
-
-$endif
-$endif
-]]
-
-AttrDecl.incHookCreateNtaList = [[
-$if(IncrementalEnabled)
-
-$if(IncrementalLevelNode)
-$if(#getNTA)
-#(signature)_proxy.inc_internalNTAList(#(signature)_values);
-$endif
-$endif
-
-$if(IncrementalLevelRegion)
-$if(#getNTA)
-#(signature)_proxy.inc_internalNTAList(#(signature)_values);
-$endif
-$endif
-
-$endif
-]]
diff --git a/src/template/incremental/Notification.tt b/src/template/incremental/Notification.tt
index 828748f8..44fa00a1 100644
--- a/src/template/incremental/Notification.tt
+++ b/src/template/incremental/Notification.tt
@@ -439,51 +439,8 @@ $if(IncrementalLevelRegion)
   /** @apilevel internal */
   public boolean #name.inc_flush_NTA($ASTNode node) {
   $if(#isListDecl)
-    if (inc_internalNTAList) {
-      state().enterConstruction();
-      int childIndex = getIndexOfChild(node);
-      removeChild(childIndex);
-      node.inc_flush_subtree(node.handler());
-      state().exitConstruction();
-      if (inc_internalNTAList_map.containsValue(node)) {
-        for (java.util.Iterator itr = inc_internalNTAList_map.keySet().iterator(); itr.hasNext();) {
-          Object key = itr.next();
-          if (inc_internalNTAList_map.get(key) == node) {
-            inc_internalNTAList_map.remove(key);
-            break;
-          }
-        }
-      }
-      return true;
-    }
-    if (parent != null) {
-      int index = parent.getIndexOfChild(this);
-      if (index >= 0 && parent.childIsNTA(index)) {
-        state().enterConstruction();
-        int childIndex = getIndexOfChild(node);
-        removeChild(childIndex);
-        node.inc_flush_subtree(node.handler());
-        state().exitConstruction();
-        return true;
-      }
-      return false;
-    }
   $else
-    $if(#isListDecl)
-    if (parent != null) {
-      int index = parent.getIndexOfChild(this);
-      if (index >= 0 && parent.childIsNTA(index)) {
-        state().enterConstruction();
-        node.setParent(null);
-        node.inc_flush_subtree(node.handler());
-        state().exitConstruction();
-        return true;
-      }
-      return false;
-    }
-    $else
     $FlushNTAs
-    $endif
   $endif
     return false;
   }
@@ -619,6 +576,11 @@ $if(IncrementalChangeFlush)
 $if(IsNTA)
 $if(IsParameterized)
 if ($(AttrSign)_proxy != null) {
+  for (Object v : $(AttrSign)_values.values()) {
+    ((ASTNode)v).inc_flush_subtree(handler());
+  }
+  $(AttrSign)_values.clear();
+/*
   for (int index = 0; index < $(AttrSign)_proxy.numChildren; index++) {
     $ASTNode value = $(AttrSign)_proxy.children[index];
     if (!value.isRegionRoot()) {
@@ -639,6 +601,7 @@ if ($(AttrSign)_proxy != null) {
       }
     }
   }
+*/
 }
 $else
 $if(IsNtaWithTree)
-- 
GitLab