@Override
public CopyHistory history() {
- return delegate.getCopyHistory();
+ return delegate.history();
}
@Override
@Override
public YangVersion yangVersion() {
- return delegate.getRootVersion();
+ return delegate.yangVersion();
}
@Override
InferredStatementContext(final StatementContextBase<?, ?, ?> parent, final StatementContextBase<A, D, E> prototype,
final CopyType myCopyType, final CopyType childCopyType, final QNameModule targetModule) {
- super(prototype.definition(), CopyHistory.of(myCopyType, prototype.getCopyHistory()));
+ super(prototype.definition(), CopyHistory.of(myCopyType, prototype.history()));
this.parent = requireNonNull(parent);
this.prototype = requireNonNull(prototype);
this.argument = targetModule == null ? prototype.argument()
}
@Override
- public final YangVersion getRootVersion() {
+ public final YangVersion yangVersion() {
return getRoot().getRootVersionImpl();
}
*/
if (root == null) {
root = new RootStatementContext<>(this, def, ref, argument);
- } else if (!RootStatementContext.DEFAULT_VERSION.equals(root.getRootVersion())
+ } else if (!RootStatementContext.DEFAULT_VERSION.equals(root.yangVersion())
&& inProgressPhase == ModelProcessingPhase.SOURCE_LINKAGE) {
- root = new RootStatementContext<>(this, def, ref, argument, root.getRootVersion(),
+ root = new RootStatementContext<>(this, def, ref, argument, root.yangVersion(),
root.getRootIdentifier());
} else {
final QName rootStatement = root.definition().getStatementName();
* @return version of root statement context
*/
YangVersion getRootVersion() {
- return root != null ? root.getRootVersion() : RootStatementContext.DEFAULT_VERSION;
+ return root != null ? root.yangVersion() : RootStatementContext.DEFAULT_VERSION;
}
void startPhase(final ModelProcessingPhase phase) {
}
@Override
- public CopyHistory getCopyHistory() {
+ public CopyHistory history() {
return copyHistory;
}
}
final StatementDefinitionContext<?, ?, ?> def = new StatementDefinitionContext<>(optImplicit.get());
- final CopyType type = original.getCopyHistory().getLastOperation();
+ final CopyType type = original.history().getLastOperation();
final SubstatementContext<?, ?, ?> result = new SubstatementContext(original.getParentContext(), def,
original.sourceReference(), original.rawArgument(), original.argument(), type);
throw new SourceException(ctx.sourceReference(), e, "Argument \"%s\" is not valid XPath string", xpath);
}
- if (ctx.getRootVersion().compareTo(parsed.getYangVersion()) < 0) {
+ if (ctx.yangVersion().compareTo(parsed.getYangVersion()) < 0) {
LOG.warn("{} features required in {} context to parse expression '{}' [at {}]",
- parsed.getYangVersion().getReference(), ctx.getRootVersion().getReference(), xpath,
+ parsed.getYangVersion().getReference(), ctx.yangVersion().getReference(), xpath,
ctx.sourceReference());
}
return parsed;
// This could be an augmentation stacked on top of a previous augmentation from the same module, which is
// conditional -- in which case we do not run further checks
- if (targetCtx.getCopyHistory().getLastOperation() == CopyType.ADDED_BY_AUGMENTATION) {
+ if (targetCtx.history().getLastOperation() == CopyType.ADDED_BY_AUGMENTATION) {
final Optional<? extends StmtContext<?, ?, ?>> optPrevCopy = targetCtx.getPreviousCopyCtx();
if (optPrevCopy.isPresent()) {
final StmtContext<?, ?, ?> original = optPrevCopy.get();
private static void validateDeviationTarget(final StmtContext<?, ?, ?> deviateSubStmtCtx,
final StmtContext<?, ?, ?> targetCtx) {
InferenceException.throwIf(!isSupportedDeviationTarget(deviateSubStmtCtx, targetCtx,
- targetCtx.getRootVersion()), deviateSubStmtCtx.sourceReference(),
+ targetCtx.yangVersion()), deviateSubStmtCtx.sourceReference(),
"%s is not a valid deviation target for substatement %s.", targetCtx.argument(),
deviateSubStmtCtx.publicDefinition().getStatementName());
}
private static boolean isSupportedDeviationTarget(final StmtContext<?, ?, ?> deviateSubstatementCtx,
final StmtContext<?, ?, ?> deviateTargetCtx, final YangVersion yangVersion) {
Set<StatementDefinition> supportedDeviationTargets =
- YangValidationBundles.SUPPORTED_DEVIATION_TARGETS.get(deviateTargetCtx.getRootVersion(),
+ YangValidationBundles.SUPPORTED_DEVIATION_TARGETS.get(yangVersion,
deviateSubstatementCtx.publicDefinition());
if (supportedDeviationTargets == null) {
/*
* In case of Yang 1.1, checks whether features are supported.
*/
- return !YangVersion.VERSION_1_1.equals(subStmtCtx.getRootVersion()) || subStmtCtx.isSupportedByFeatures();
+ return !YangVersion.VERSION_1_1.equals(subStmtCtx.yangVersion()) || subStmtCtx.isSupportedByFeatures();
}
private static void performRefine(final Mutable<?, ?, ?> subStmtCtx, final StmtContext<?, ?, ?> usesParentCtx) {
import com.google.common.base.VerifyException;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
+import org.opendaylight.yangtools.yang.common.YangVersion;
/**
* A {@link CommonStmtCtx} which has additionally been bound to a {@link StatementSupport}. It provides
default @NonNull A getArgument() {
return verifyNotNull(argument(), "Attempted to use non-existent argument of %s", this);
}
+
+ /**
+ * Return the {@link YangVersion} associated with this statement.
+ *
+ * @return YANG version used to bind this statement
+ */
+ @NonNull YangVersion yangVersion();
}
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.yangtools.concepts.Immutable;
-import org.opendaylight.yangtools.yang.common.YangVersion;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
* Effective view of a {@link StmtContext} for the purposes of creating an {@link EffectiveStatement}.
*/
@Beta
-public interface EffectiveStmtCtx extends CommonStmtCtx, Immutable {
+public interface EffectiveStmtCtx extends CommonStmtCtx, StmtContextCompat, Immutable {
/**
* Return parent of this context, if there is one. All statements except for top-level source statements, such as
* {@code module} and {@code submodule}.
@NonNull CommonStmtCtx root();
- @NonNull CopyHistory history();
-
@NonNull D declared();
<K, V, T extends K, N extends IdentifierNamespace<K, V>> @Nullable V getFromNamespace(Class<@NonNull N> type,
@Nullable EffectiveStatement<?, ?> original();
- @NonNull YangVersion yangVersion();
-
/**
* Summon the <a href="https://en.wikipedia.org/wiki/Rabbit_of_Caerbannog">Rabbit of Caerbannog</a>.
*
* @param <E> Effective Statement representation
*/
public interface StmtContext<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>>
- extends BoundStmtCtx<A> {
+ extends BoundStmtCtx<A>, StmtContextCompat {
@Deprecated(forRemoval = true)
default @NonNull StatementDefinition getPublicDefinition() {
return publicDefinition();
/*
* FIXME: YANGTOOLS-784: the next three methods are closely related to the copy process:
- * - getCopyHistory() is a brief summary of what went on
+ * - copyHistory() is a brief summary of what went on
* - getOriginalContext() points to the CopyHistory.ORIGINAL
* - getPreviousCopyCtx() points to the immediate predecessor forming a singly-linked list terminated
* at getOriginalContext()
* and hence should become arguments to that method.
*/
- /**
- * Return the executive summary of the copy process that has produced this context.
- *
- * @return A simplified summary of the copy process.
- */
- CopyHistory getCopyHistory();
-
/**
* Return the statement context of the original definition, if this statement is an instantiated copy.
*
ModelProcessingPhase getCompletedPhase();
- /**
- * Return version of root statement context.
- *
- * @return version of root statement context
- */
- @NonNull YangVersion getRootVersion();
-
/**
* An mutable view of an inference context associated with an instance of a statement.
*
--- /dev/null
+/*
+ * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.spi.meta;
+
+import com.google.common.annotations.Beta;
+import org.eclipse.jdt.annotation.NonNull;
+
+/**
+ * Intermediate compatibility interface between {@link StmtContext} and {@link EffectiveStmtCtx.Current}.
+ */
+@Beta
+public interface StmtContextCompat extends CommonStmtCtx {
+ /**
+ * Return the executive summary of the copy process that has produced this context.
+ *
+ * @return A simplified summary of the copy process.
+ */
+ @NonNull CopyHistory history();
+}
}
private static boolean isRelevantForIfFeatureAndWhenOnListKeysCheck(final StmtContext<?, ?, ?> ctx) {
- return YangVersion.VERSION_1_1.equals(ctx.getRootVersion()) && hasParentOfType(ctx, YangStmtMapping.LIST)
+ return YangVersion.VERSION_1_1.equals(ctx.yangVersion()) && hasParentOfType(ctx, YangStmtMapping.LIST)
&& findFirstDeclaredSubstatement(ctx.coerceParentContext(), KeyStatement.class) != null;
}
localName = value;
qnameModule = getRootModuleQName(ctx);
}
- if (qnameModule == null && ctx.getCopyHistory().getLastOperation() == CopyType.ADDED_BY_AUGMENTATION) {
+ if (qnameModule == null && ctx.history().getLastOperation() == CopyType.ADDED_BY_AUGMENTATION) {
ctx = ctx.getOriginalCtx().orElse(null);
qnameModule = getModuleQNameByPrefix(ctx, prefix);
}