2 * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.mdsal.binding.generator.impl.reactor;
10 import static com.google.common.base.Verify.verify;
11 import static com.google.common.base.Verify.verifyNotNull;
12 import static java.util.Objects.requireNonNull;
14 import java.util.ArrayList;
15 import java.util.Iterator;
16 import java.util.List;
17 import java.util.stream.Collectors;
18 import org.eclipse.jdt.annotation.NonNull;
19 import org.eclipse.jdt.annotation.Nullable;
20 import org.opendaylight.mdsal.binding.model.api.Enumeration;
21 import org.opendaylight.mdsal.binding.model.api.GeneratedTransferObject;
22 import org.opendaylight.mdsal.binding.model.api.GeneratedType;
23 import org.opendaylight.mdsal.binding.model.api.Type;
24 import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTypeBuilder;
25 import org.opendaylight.mdsal.binding.model.ri.BindingTypes;
26 import org.opendaylight.mdsal.binding.runtime.api.CompositeRuntimeType;
27 import org.opendaylight.mdsal.binding.runtime.api.RuntimeType;
28 import org.opendaylight.yangtools.yang.common.QName;
29 import org.opendaylight.yangtools.yang.model.api.AddedByUsesAware;
30 import org.opendaylight.yangtools.yang.model.api.CopyableNode;
31 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
32 import org.opendaylight.yangtools.yang.model.api.stmt.ActionEffectiveStatement;
33 import org.opendaylight.yangtools.yang.model.api.stmt.AnydataEffectiveStatement;
34 import org.opendaylight.yangtools.yang.model.api.stmt.AnyxmlEffectiveStatement;
35 import org.opendaylight.yangtools.yang.model.api.stmt.AugmentEffectiveStatement;
36 import org.opendaylight.yangtools.yang.model.api.stmt.CaseEffectiveStatement;
37 import org.opendaylight.yangtools.yang.model.api.stmt.ChoiceEffectiveStatement;
38 import org.opendaylight.yangtools.yang.model.api.stmt.ContainerEffectiveStatement;
39 import org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement;
40 import org.opendaylight.yangtools.yang.model.api.stmt.IdentityEffectiveStatement;
41 import org.opendaylight.yangtools.yang.model.api.stmt.InputEffectiveStatement;
42 import org.opendaylight.yangtools.yang.model.api.stmt.LeafEffectiveStatement;
43 import org.opendaylight.yangtools.yang.model.api.stmt.LeafListEffectiveStatement;
44 import org.opendaylight.yangtools.yang.model.api.stmt.ListEffectiveStatement;
45 import org.opendaylight.yangtools.yang.model.api.stmt.NotificationEffectiveStatement;
46 import org.opendaylight.yangtools.yang.model.api.stmt.OutputEffectiveStatement;
47 import org.opendaylight.yangtools.yang.model.api.stmt.RpcEffectiveStatement;
48 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeEffectiveStatement;
49 import org.opendaylight.yangtools.yang.model.api.stmt.TypedefEffectiveStatement;
50 import org.opendaylight.yangtools.yang.model.api.stmt.UsesEffectiveStatement;
51 import org.opendaylight.yangtools.yang.model.ri.type.TypeBuilder;
52 import org.slf4j.Logger;
53 import org.slf4j.LoggerFactory;
56 * A composite generator. Composite generators may contain additional children, which end up being mapped into
57 * the naming hierarchy 'under' the composite generator. To support this use case, each composite has a Java package
61 * State tracking for resolution of children to their original declaration, i.e. back along the 'uses' and 'augment'
62 * axis. This is quite convoluted because we are traversing the generator tree recursively in the iteration order of
63 * children, but actual dependencies may require resolution in a different order, for example in the case of:
68 * container xyzzy; // C
73 * container bar { // D
85 * augment /foo/bar/xyzzy { // G
93 * In this case we have three manifestations of 'leaf baz' -- marked A, E and F in the child iteration order. In order
94 * to perform a resolution, we first have to determine that F is the original definition, then establish that E is using
95 * the definition made by F and finally establish that A is using the definition made by F.
98 * Dealing with augmentations is harder still, because we need to attach them to the original definition, hence for the
99 * /foo/bar container at A, we need to understand that its original definition is at D and we need to attach the augment
100 * at B to D. Futhermore we also need to establish that the augmentation at G attaches to container defined in C, so
101 * that the 'leaf xyzzy' existing as /foo/bar/xyzzy/xyzzy under C has its original definition at H.
104 * Finally realize that the augment at G can actually exist in a different module and is shown in this example only
105 * the simplified form. That also means we could encounter G well before 'container foo' as well as we can have multiple
106 * such augments sprinkled across multiple modules having the same dependency rules as between C and G -- but they still
107 * have to form a directed acyclic graph and we partially deal with those complexities by having modules sorted by their
111 * For further details see {@link #linkOriginalGenerator()} and {@link #linkOriginalGeneratorRecursive()}, which deal
112 * with linking original instances in the tree iteration order. The part dealing with augment attachment lives mostly
113 * in {@link AugmentRequirement}.
115 public abstract class AbstractCompositeGenerator<S extends EffectiveStatement<?, ?>, R extends CompositeRuntimeType>
116 extends AbstractExplicitGenerator<S, R> {
117 private static final Logger LOG = LoggerFactory.getLogger(AbstractCompositeGenerator.class);
119 // FIXME: we want to allocate this lazily to lower memory footprint
120 private final @NonNull CollisionDomain domain = new CollisionDomain(this);
121 private final @NonNull List<Generator> childGenerators;
124 * List of {@code augment} statements targeting this generator. This list is maintained only for the primary
125 * incarnation. This list is an evolving entity until after we have finished linkage of original statements. It is
126 * expected to be stable at the start of {@code step 2} in {@link GeneratorReactor#execute(TypeBuilderFactory)}.
128 private @NonNull List<AbstractAugmentGenerator> augments = List.of();
131 * List of {@code grouping} statements this statement references. This field is set once by
132 * {@link #linkUsesDependencies(GeneratorContext)}.
134 private List<GroupingGenerator> groupings;
137 * List of composite children which have not been recursively processed. This may become a mutable list when we
138 * have some children which have not completed linking. Once we have completed linking of all children, including
139 * {@link #unlinkedChildren}, this will be set to {@code null}.
141 private List<AbstractCompositeGenerator<?, ?>> unlinkedComposites = List.of();
143 * List of children which have not had their original linked. This list starts of as null. When we first attempt
144 * linkage, it becomes non-null.
146 private List<Generator> unlinkedChildren;
148 AbstractCompositeGenerator(final S statement) {
150 childGenerators = createChildren(statement);
153 AbstractCompositeGenerator(final S statement, final AbstractCompositeGenerator<?, ?> parent) {
154 super(statement, parent);
155 childGenerators = createChildren(statement);
159 public final Iterator<Generator> iterator() {
160 return childGenerators.iterator();
164 final GeneratedType runtimeJavaType() {
165 return generatedType().orElse(null);
168 final @NonNull List<AbstractAugmentGenerator> augments() {
172 final @NonNull List<GroupingGenerator> groupings() {
173 return verifyNotNull(groupings, "Groupings not initialized in %s", this);
177 final R createExternalRuntimeType(final Type type) {
178 verify(type instanceof GeneratedType, "Unexpected type %s", type);
179 return createBuilder(statement()).populate(new AugmentResolver(), this).build((GeneratedType) type);
182 abstract @NonNull CompositeRuntimeTypeBuilder<S, R> createBuilder(S statement);
185 final R createInternalRuntimeType(final AugmentResolver resolver, final S statement, final Type type) {
186 verify(type instanceof GeneratedType, "Unexpected type %s", type);
187 return createBuilder(statement).populate(resolver, this).build((GeneratedType) type);
191 final boolean isEmpty() {
192 return childGenerators.isEmpty();
195 final @Nullable AbstractExplicitGenerator<?, ?> findGenerator(final List<EffectiveStatement<?, ?>> stmtPath) {
196 return findGenerator(MatchStrategy.identity(), stmtPath, 0);
199 final @Nullable AbstractExplicitGenerator<?, ?> findGenerator(final MatchStrategy childStrategy,
200 // TODO: Wouldn't this method be nicer with Deque<EffectiveStatement<?, ?>> ?
201 final List<EffectiveStatement<?, ?>> stmtPath, final int offset) {
202 final EffectiveStatement<?, ?> stmt = stmtPath.get(offset);
204 // Try direct children first, which is simple
205 AbstractExplicitGenerator<?, ?> ret = childStrategy.findGenerator(stmt, childGenerators);
207 final int next = offset + 1;
208 if (stmtPath.size() == next) {
209 // Final step, return child
212 if (ret instanceof AbstractCompositeGenerator) {
213 // We know how to descend down
214 return ((AbstractCompositeGenerator<?, ?>) ret).findGenerator(childStrategy, stmtPath, next);
216 // Yeah, don't know how to continue here
220 // At this point we are about to fork for augments or groupings. In either case only schema tree statements can
221 // be found this way. The fun part is that if we find a match and need to continue, we will use the same
222 // strategy for children as well. We now know that this (and subsequent) statements need to have a QName
224 if (stmt instanceof SchemaTreeEffectiveStatement) {
225 // grouping -> uses instantiation changes the namespace to the local namespace of the uses site. We are
226 // going the opposite direction, hence we are changing namespace from local to the grouping's namespace.
227 for (GroupingGenerator gen : groupings) {
228 final MatchStrategy strat = MatchStrategy.grouping(gen);
229 ret = gen.findGenerator(strat, stmtPath, offset);
235 // All augments are dead simple: they need to match on argument (which we expect to be a QName)
236 final MatchStrategy strat = MatchStrategy.augment();
237 for (AbstractAugmentGenerator gen : augments) {
238 ret = gen.findGenerator(strat, stmtPath, offset);
247 final @NonNull CollisionDomain domain() {
251 final void linkUsesDependencies(final GeneratorContext context) {
252 // We are establishing two linkages here:
253 // - we are resolving 'uses' statements to their corresponding 'grouping' definitions
254 // - we propagate those groupings as anchors to any augment statements, which takes out some amount of guesswork
255 // from augment+uses resolution case, as groupings know about their immediate augments as soon as uses linkage
257 final List<GroupingGenerator> tmp = new ArrayList<>();
258 for (EffectiveStatement<?, ?> stmt : statement().effectiveSubstatements()) {
259 if (stmt instanceof UsesEffectiveStatement) {
260 final UsesEffectiveStatement uses = (UsesEffectiveStatement) stmt;
261 final GroupingGenerator grouping = context.resolveTreeScoped(GroupingGenerator.class, uses.argument());
264 // Trigger resolution of uses/augment statements. This looks like guesswork, but there may be multiple
265 // 'augment' statements in a 'uses' statement and keeping a ListMultimap here seems wasteful.
266 for (Generator gen : this) {
267 if (gen instanceof UsesAugmentGenerator) {
268 ((UsesAugmentGenerator) gen).resolveGrouping(uses, grouping);
273 groupings = List.copyOf(tmp);
276 final void startUsesAugmentLinkage(final List<AugmentRequirement> requirements) {
277 for (Generator child : childGenerators) {
278 if (child instanceof UsesAugmentGenerator) {
279 requirements.add(((UsesAugmentGenerator) child).startLinkage());
281 if (child instanceof AbstractCompositeGenerator) {
282 ((AbstractCompositeGenerator<?, ?>) child).startUsesAugmentLinkage(requirements);
287 final void addAugment(final AbstractAugmentGenerator augment) {
288 if (augments.isEmpty()) {
289 augments = new ArrayList<>(2);
291 augments.add(requireNonNull(augment));
295 * Attempt to link the generator corresponding to the original definition for this generator's statements as well as
296 * to all child generators.
298 * @return Progress indication
300 final @NonNull LinkageProgress linkOriginalGeneratorRecursive() {
301 if (unlinkedComposites == null) {
302 // We have unset this list (see below), and there is nothing left to do
303 return LinkageProgress.DONE;
306 if (unlinkedChildren == null) {
307 unlinkedChildren = childGenerators.stream()
308 .filter(AbstractExplicitGenerator.class::isInstance)
309 .map(child -> (AbstractExplicitGenerator<?, ?>) child)
310 .collect(Collectors.toList());
313 var progress = LinkageProgress.NONE;
314 if (!unlinkedChildren.isEmpty()) {
315 // Attempt to make progress on child linkage
316 final var it = unlinkedChildren.iterator();
317 while (it.hasNext()) {
318 final var child = it.next();
319 if (child instanceof AbstractExplicitGenerator) {
320 if (((AbstractExplicitGenerator<?, ?>) child).linkOriginalGenerator()) {
321 progress = LinkageProgress.SOME;
324 // If this is a composite generator we need to process is further
325 if (child instanceof AbstractCompositeGenerator) {
326 if (unlinkedComposites.isEmpty()) {
327 unlinkedComposites = new ArrayList<>();
329 unlinkedComposites.add((AbstractCompositeGenerator<?, ?>) child);
335 if (unlinkedChildren.isEmpty()) {
336 // Nothing left to do, make sure any previously-allocated list can be scavenged
337 unlinkedChildren = List.of();
341 // Process children of any composite children we have.
342 final var it = unlinkedComposites.iterator();
343 while (it.hasNext()) {
344 final var tmp = it.next().linkOriginalGeneratorRecursive();
345 if (tmp != LinkageProgress.NONE) {
346 progress = LinkageProgress.SOME;
348 if (tmp == LinkageProgress.DONE) {
353 if (unlinkedChildren.isEmpty() && unlinkedComposites.isEmpty()) {
354 // All done, set the list to null to indicate there is nothing left to do in this generator or any of our
356 unlinkedComposites = null;
357 return LinkageProgress.DONE;
364 final AbstractCompositeGenerator<S, R> getOriginal() {
365 return (AbstractCompositeGenerator<S, R>) super.getOriginal();
369 final AbstractCompositeGenerator<S, R> tryOriginal() {
370 return (AbstractCompositeGenerator<S, R>) super.tryOriginal();
373 final <X extends EffectiveStatement<?, ?>, Y extends RuntimeType> @Nullable OriginalLink<X, Y> originalChild(
374 final QName childQName) {
375 // First try groupings/augments ...
376 var found = findInferredGenerator(childQName);
378 return (OriginalLink<X, Y>) OriginalLink.partial(found);
381 // ... no luck, we really need to start looking at our origin
382 final var prev = previous();
384 final QName prevQName = childQName.bindTo(prev.getQName().getModule());
385 found = prev.findSchemaTreeGenerator(prevQName);
387 return (OriginalLink<X, Y>) found.originalLink();
395 final AbstractExplicitGenerator<?, ?> findSchemaTreeGenerator(final QName qname) {
396 final AbstractExplicitGenerator<?, ?> found = super.findSchemaTreeGenerator(qname);
397 return found != null ? found : findInferredGenerator(qname);
400 final @Nullable AbstractAugmentGenerator findAugmentForGenerator(final QName qname) {
401 for (var augment : augments) {
402 final var gen = augment.findSchemaTreeGenerator(qname);
410 final @Nullable GroupingGenerator findGroupingForGenerator(final QName qname) {
411 for (GroupingGenerator grouping : groupings) {
412 final var gen = grouping.findSchemaTreeGenerator(qname.bindTo(grouping.statement().argument().getModule()));
420 private @Nullable AbstractExplicitGenerator<?, ?> findInferredGenerator(final QName qname) {
421 // First search our local groupings ...
422 for (var grouping : groupings) {
423 final var gen = grouping.findSchemaTreeGenerator(qname.bindTo(grouping.statement().argument().getModule()));
428 // ... next try local augments, which may have groupings themselves
429 for (var augment : augments) {
430 final var gen = augment.findSchemaTreeGenerator(qname);
439 * Update the specified builder to implement interfaces generated for the {@code grouping} statements this generator
442 * @param builder Target builder
443 * @param builderFactory factory for creating {@link TypeBuilder}s
444 * @return The number of groupings this type uses.
446 final int addUsesInterfaces(final GeneratedTypeBuilder builder, final TypeBuilderFactory builderFactory) {
447 for (GroupingGenerator grp : groupings) {
448 builder.addImplementsType(grp.getGeneratedType(builderFactory));
450 return groupings.size();
453 static final void addAugmentable(final GeneratedTypeBuilder builder) {
454 builder.addImplementsType(BindingTypes.augmentable(builder));
457 final void addGetterMethods(final GeneratedTypeBuilder builder, final TypeBuilderFactory builderFactory) {
458 for (Generator child : this) {
459 // Only process explicit generators here
460 if (child instanceof AbstractExplicitGenerator) {
461 ((AbstractExplicitGenerator<?, ?>) child).addAsGetterMethod(builder, builderFactory);
464 final GeneratedType enclosedType = child.enclosedType(builderFactory);
465 if (enclosedType instanceof GeneratedTransferObject) {
466 builder.addEnclosingTransferObject((GeneratedTransferObject) enclosedType);
467 } else if (enclosedType instanceof Enumeration) {
468 builder.addEnumeration((Enumeration) enclosedType);
470 verify(enclosedType == null, "Unhandled enclosed type %s in %s", enclosedType, child);
475 private @NonNull List<Generator> createChildren(final EffectiveStatement<?, ?> statement) {
476 final var tmp = new ArrayList<Generator>();
477 final var tmpAug = new ArrayList<AbstractAugmentGenerator>();
479 for (var stmt : statement.effectiveSubstatements()) {
480 if (stmt instanceof ActionEffectiveStatement) {
481 if (!isAugmenting(stmt)) {
482 tmp.add(new ActionGenerator((ActionEffectiveStatement) stmt, this));
484 } else if (stmt instanceof AnydataEffectiveStatement) {
485 if (!isAugmenting(stmt)) {
486 tmp.add(new OpaqueObjectGenerator.Anydata((AnydataEffectiveStatement) stmt, this));
488 } else if (stmt instanceof AnyxmlEffectiveStatement) {
489 if (!isAugmenting(stmt)) {
490 tmp.add(new OpaqueObjectGenerator.Anyxml((AnyxmlEffectiveStatement) stmt, this));
492 } else if (stmt instanceof CaseEffectiveStatement) {
493 tmp.add(new CaseGenerator((CaseEffectiveStatement) stmt, this));
494 } else if (stmt instanceof ChoiceEffectiveStatement) {
495 // FIXME: use isOriginalDeclaration() ?
496 if (!isAddedByUses(stmt)) {
497 tmp.add(new ChoiceGenerator((ChoiceEffectiveStatement) stmt, this));
499 } else if (stmt instanceof ContainerEffectiveStatement) {
500 if (isOriginalDeclaration(stmt)) {
501 tmp.add(new ContainerGenerator((ContainerEffectiveStatement) stmt, this));
503 } else if (stmt instanceof GroupingEffectiveStatement) {
504 tmp.add(new GroupingGenerator((GroupingEffectiveStatement) stmt, this));
505 } else if (stmt instanceof IdentityEffectiveStatement) {
506 tmp.add(new IdentityGenerator((IdentityEffectiveStatement) stmt, this));
507 } else if (stmt instanceof InputEffectiveStatement) {
508 final var cast = (InputEffectiveStatement) stmt;
509 // FIXME: do not generate legacy RPC layout
510 tmp.add(this instanceof RpcGenerator ? new RpcInputGenerator(cast, this)
511 : new InputGenerator(cast, this));
512 } else if (stmt instanceof LeafEffectiveStatement) {
513 if (!isAugmenting(stmt)) {
514 tmp.add(new LeafGenerator((LeafEffectiveStatement) stmt, this));
516 } else if (stmt instanceof LeafListEffectiveStatement) {
517 if (!isAugmenting(stmt)) {
518 tmp.add(new LeafListGenerator((LeafListEffectiveStatement) stmt, this));
520 } else if (stmt instanceof ListEffectiveStatement) {
521 if (isOriginalDeclaration(stmt)) {
522 final ListGenerator listGen = new ListGenerator((ListEffectiveStatement) stmt, this);
525 final KeyGenerator keyGen = listGen.keyGenerator();
526 if (keyGen != null) {
530 } else if (stmt instanceof NotificationEffectiveStatement) {
531 if (!isAugmenting(stmt)) {
532 tmp.add(new NotificationGenerator((NotificationEffectiveStatement) stmt, this));
534 } else if (stmt instanceof OutputEffectiveStatement) {
535 final var cast = (OutputEffectiveStatement) stmt;
536 // FIXME: do not generate legacy RPC layout
537 tmp.add(this instanceof RpcGenerator ? new RpcOutputGenerator(cast, this)
538 : new OutputGenerator(cast, this));
539 } else if (stmt instanceof RpcEffectiveStatement) {
540 tmp.add(new RpcGenerator((RpcEffectiveStatement) stmt, this));
541 } else if (stmt instanceof TypedefEffectiveStatement) {
542 tmp.add(new TypedefGenerator((TypedefEffectiveStatement) stmt, this));
543 } else if (stmt instanceof AugmentEffectiveStatement) {
544 // FIXME: MDSAL-695: So here we are ignoring any augment which is not in a module, while the 'uses'
545 // processing takes care of the rest. There are two problems here:
547 // 1) this could be an augment introduced through uses -- in this case we are picking
548 // confusing it with this being its declaration site, we should probably be
549 // ignoring it, but then
551 // 2) we are losing track of AugmentEffectiveStatement for which we do not generate
552 // interfaces -- and recover it at runtime through explicit walk along the
553 // corresponding AugmentationSchemaNode.getOriginalDefinition() pointer
555 // So here is where we should decide how to handle this augment, and make sure we
556 // retain information about this being an alias. That will serve as the base for keys
557 // in the augment -> original map we provide to BindingRuntimeTypes.
558 if (this instanceof ModuleGenerator) {
559 tmpAug.add(new ModuleAugmentGenerator((AugmentEffectiveStatement) stmt, this));
561 } else if (stmt instanceof UsesEffectiveStatement) {
562 final UsesEffectiveStatement uses = (UsesEffectiveStatement) stmt;
563 for (EffectiveStatement<?, ?> usesSub : uses.effectiveSubstatements()) {
564 if (usesSub instanceof AugmentEffectiveStatement) {
565 tmpAug.add(new UsesAugmentGenerator((AugmentEffectiveStatement) usesSub, uses, this));
569 LOG.trace("Ignoring statement {}", stmt);
573 // Sort augments and add them last. This ensures child iteration order always reflects potential
574 // interdependencies, hence we do not need to worry about them. This is extremely important, as there are a
575 // number of places where we would have to either move the logic to parent statement and explicitly filter/sort
576 // substatements to establish this order.
577 tmpAug.sort(AbstractAugmentGenerator.COMPARATOR);
580 // Compatibility FooService and FooListener interfaces, only generated for modules.
581 if (this instanceof ModuleGenerator) {
582 final ModuleGenerator moduleGen = (ModuleGenerator) this;
584 final List<NotificationGenerator> notifs = tmp.stream()
585 .filter(NotificationGenerator.class::isInstance)
586 .map(NotificationGenerator.class::cast)
587 .collect(Collectors.toUnmodifiableList());
588 if (!notifs.isEmpty()) {
589 tmp.add(new NotificationServiceGenerator(moduleGen, notifs));
592 final List<RpcGenerator> rpcs = tmp.stream()
593 .filter(RpcGenerator.class::isInstance)
594 .map(RpcGenerator.class::cast)
595 .collect(Collectors.toUnmodifiableList());
596 if (!rpcs.isEmpty()) {
597 tmp.add(new RpcServiceGenerator(moduleGen, rpcs));
601 return List.copyOf(tmp);
604 // Utility equivalent of (!isAddedByUses(stmt) && !isAugmenting(stmt)). Takes advantage of relationship between
605 // CopyableNode and AddedByUsesAware
606 private static boolean isOriginalDeclaration(final EffectiveStatement<?, ?> stmt) {
607 if (stmt instanceof AddedByUsesAware) {
608 if (((AddedByUsesAware) stmt).isAddedByUses()
609 || stmt instanceof CopyableNode && ((CopyableNode) stmt).isAugmenting()) {
616 private static boolean isAddedByUses(final EffectiveStatement<?, ?> stmt) {
617 return stmt instanceof AddedByUsesAware && ((AddedByUsesAware) stmt).isAddedByUses();
620 private static boolean isAugmenting(final EffectiveStatement<?, ?> stmt) {
621 return stmt instanceof CopyableNode && ((CopyableNode) stmt).isAugmenting();