From fca9011ceef1413e8a0f40bf2f033bd7ad3b8a9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emma=20S=C3=B6derberg?= <emma.m.soderberg@gmail.com> Date: Thu, 5 Jul 2018 11:44:39 +0200 Subject: [PATCH] Adds flushing of collection attributes for incremental/param. --- .../incremental/IncrementalNotification.jadd | 26 +++++++++++++++++++ src/template/incremental/Notification.tt | 14 +++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/jastadd/incremental/IncrementalNotification.jadd b/src/jastadd/incremental/IncrementalNotification.jadd index 7631efee..1ca0fa08 100644 --- a/src/jastadd/incremental/IncrementalNotification.jadd +++ b/src/jastadd/incremental/IncrementalNotification.jadd @@ -42,6 +42,7 @@ tt.expand("ASTDecl.incValueAffectedMethod", out); tt.bind("AttrFlushChecks", emitAttrFlushChecksString()); + tt.bind("CollAttrFlushChecks", emitCollAttrFlushChecksString()); tt.expand("ASTDecl.incReactToDepChangeMethod", out); tt.bind("FlushAttrs", emitFlushAttrsString()); @@ -206,6 +207,31 @@ return res.toString(); } + /** + * Creates string with code checking if a collection attribute should be + * flushed and dependencies notified. + */ + public String ASTDecl.emitCollAttrFlushChecksString() { + if (config().incrementalLevelNode() || config().incrementalLevelRegion()) { + return ""; + } + StringBuffer res = new StringBuffer(); + TemplateContext tt = templateContext(); + boolean firstAttr = true; + for (int k = 0; k < getNumCollDecl(); k++) { + CollDecl attr = getCollDecl(k); + res.append(firstAttr ? "" : "else "); + tt.bind("AttrSign", attr.signature()); + tt.bind("AttrType", attr.type()); + tt.bind("AttrResetVisit", attr.resetVisit()); + tt.bind("AttrResetCache", attr.resetCache()); + tt.bind("CollectionReset", collectionReset()); + res.append(tt.expand("ASTDecl.collAttrFlushCheck")); + firstAttr = false; + } + return res.toString(); + } + /** * Creates string with code flushing attributes. */ diff --git a/src/template/incremental/Notification.tt b/src/template/incremental/Notification.tt index 44fa00a1..48ed36dc 100644 --- a/src/template/incremental/Notification.tt +++ b/src/template/incremental/Notification.tt @@ -176,9 +176,9 @@ $endif ASTDecl.incChangeFlush = [[ $if(IncrementalChangeFlush) -// flush children $if(IncrementalLevelParam) $if(#isASTNodeDecl) +// flush children if (attrID.equals("getChild")) { int i = (Integer)_parameters; getChild_handler[i].notifyDependencies(); @@ -214,11 +214,23 @@ handler.notifyDependencies(); $endif $endif +$CollAttrFlushChecks $AttrFlushChecks $endif ]] +ASTDecl.collAttrFlushCheck = [[ +$if(IncrementalLevelParam) +if (attrID.equals("$AttrSign") && $(AttrSign)_computed) { + $AttrResetVisit + $AttrResetCache + $CollectionReset + $(AttrSign)_handler.notifyDependencies(); +} +$endif +]] + ASTDecl.attrFlushCheck = [[ $if(IncrementalLevelParam) $if(IsParameterized) -- GitLab