diff --git a/src/jastadd/incremental/IncrementalNotification.jadd b/src/jastadd/incremental/IncrementalNotification.jadd index 7631efeec1122edbe6cb52fcb49b7ddf3f4c0fa8..1ca0fa086b9ec0d1172103533c67962a47d9e126 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 44fa00a1307604e680e0801d9bb221a7211de44a..48ed36dca55a0641a2afa307b7eb2a6419db965b 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)