X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-parser-reactor%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fparser%2Fstmt%2Freactor%2FStatementContextBase.java;h=8cc6b37712003e0d993b735986bf3676031fe319;hb=refs%2Fchanges%2F17%2F87117%2F1;hp=47f2a3e2e082193aa9aeeef6f76d1fe8f29d31d3;hpb=7abc24d13cfd3d1efd99d095884308d45adedc1c;p=yangtools.git diff --git a/yang/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/StatementContextBase.java b/yang/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/StatementContextBase.java index 47f2a3e2e0..8cc6b37712 100644 --- a/yang/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/StatementContextBase.java +++ b/yang/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/StatementContextBase.java @@ -101,6 +101,7 @@ public abstract class StatementContextBase, E private final @NonNull StatementDefinitionContext definition; private final @NonNull StatementSourceReference statementDeclSource; private final StmtContext originalCtx; + private final StmtContext prevCopyCtx; private final CopyHistory copyHistory; private final String rawArgument; @@ -127,6 +128,7 @@ public abstract class StatementContextBase, E this.rawArgument = def.internArgument(rawArgument); this.copyHistory = CopyHistory.original(); this.originalCtx = null; + this.prevCopyCtx = null; } StatementContextBase(final StatementDefinitionContext def, final StatementSourceReference ref, @@ -136,6 +138,7 @@ public abstract class StatementContextBase, E this.rawArgument = rawArgument; this.copyHistory = CopyHistory.of(copyType, CopyHistory.original()); this.originalCtx = null; + this.prevCopyCtx = null; } StatementContextBase(final StatementContextBase original, final CopyType copyType) { @@ -144,6 +147,7 @@ public abstract class StatementContextBase, E this.rawArgument = original.rawArgument; this.copyHistory = CopyHistory.of(copyType, original.getCopyHistory()); this.originalCtx = original.getOriginalCtx().orElse(original); + this.prevCopyCtx = original; } StatementContextBase(final StatementContextBase original) { @@ -152,6 +156,7 @@ public abstract class StatementContextBase, E this.rawArgument = original.rawArgument; this.copyHistory = original.getCopyHistory(); this.originalCtx = original.getOriginalCtx().orElse(original); + this.prevCopyCtx = original; this.substatements = original.substatements; this.effective = original.effective; } @@ -210,9 +215,7 @@ public abstract class StatementContextBase, E // If the set of supported features has not been provided, all features are supported by default. final Set supportedFeatures = getFromNamespace(SupportedFeaturesNamespace.class, SupportedFeatures.SUPPORTED_FEATURES); - final boolean ret = supportedFeatures == null ? true - : StmtContextUtils.checkFeatureSupport(this, supportedFeatures); - + final boolean ret = supportedFeatures == null || StmtContextUtils.checkFeatureSupport(this, supportedFeatures); supportedByFeatures = OptionalBoolean.of(ret); return ret; } @@ -243,6 +246,11 @@ public abstract class StatementContextBase, E return Optional.ofNullable(originalCtx); } + @Override + public Optional> getPreviousCopyCtx() { + return Optional.ofNullable(prevCopyCtx); + } + @Override public ModelProcessingPhase getCompletedPhase() { return completedPhase; @@ -313,6 +321,15 @@ public abstract class StatementContextBase, E return Collections.unmodifiableCollection(effective); } + /** + * Remove a set of statements from effective statements. + * + * @param statements statements to be removed + * @deprecated This method was used by EffectiveStatementBase to restore proper order of effects of uses statements. + * It is no longer used in that capacity and slated for removal. + */ + // FIXME: 5.0.0: remove this method + @Deprecated public void removeStatementsFromEffectiveSubstatements( final Collection> statements) { if (!effective.isEmpty()) { @@ -792,12 +809,11 @@ public abstract class StatementContextBase, E copy = new SubstatementContext<>(original, result, childCopyType, targetModule); result.addEffectiveSubstatement(copy); - original.definition().onStatementAdded(copy); } else { result = copy = new SubstatementContext<>(original, this, type, targetModule); - original.definition().onStatementAdded(copy); } + original.definition().onStatementAdded(copy); original.copyTo(copy, type, targetModule); return result; } @@ -873,11 +889,11 @@ public abstract class StatementContextBase, E } // FIXME: revise this, as it seems to be wrong - private static final Set NOCOPY_FROM_GROUPING_SET = ImmutableSet.of( + private static final ImmutableSet NOCOPY_FROM_GROUPING_SET = ImmutableSet.of( YangStmtMapping.DESCRIPTION, YangStmtMapping.REFERENCE, YangStmtMapping.STATUS); - private static final Set REUSED_DEF_SET = ImmutableSet.of( + private static final ImmutableSet REUSED_DEF_SET = ImmutableSet.of( YangStmtMapping.TYPE, YangStmtMapping.TYPEDEF, YangStmtMapping.USES);