--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. 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.base.Preconditions;
+import java.util.Map;
+import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
+
+public abstract class DerivedNamespaceBehaviour<K, V, N extends IdentifierNamespace<K, V>, T extends IdentifierNamespace<?, ?>>
+ extends NamespaceBehaviour<K, V, N> {
+
+ private Class<T> derivedFrom;
+
+ protected DerivedNamespaceBehaviour(Class<N> identifier, Class<T> derivedFrom) {
+ super(identifier);
+ this.derivedFrom = Preconditions.checkNotNull(derivedFrom);
+ }
+
+ public Class<T> getDerivedFrom() {
+ return derivedFrom;
+ }
+
+ @Override
+ public Map<K, V> getAllFrom(NamespaceStorageNode storage) {
+ throw new UnsupportedOperationException("Virtual namespaces does not support provision of all items.");
+ }
+
+ @Override
+ public abstract V getFrom(NamespaceBehaviour.NamespaceStorageNode storage, K key);
+
+ @Override
+ public void addTo(NamespaceStorageNode storage, K key, V value) {
+ // Intentional noop
+ }
+}
@Nonnull <T extends Mutable<?,?,?>> Prerequisite<T> mutatesEffectiveCtx(T stmt);
- @Nonnull <K,E extends EffectiveStatement<?,?>,N extends StatementNamespace<K, ?, ? extends E>> Prerequisite<Mutable<?,?,E>> mutatesEffectiveCtx(StmtContext<?,?,?> context,Class<N> namespace, K key);
+ @Nonnull <K,E extends EffectiveStatement<?,?>, N extends IdentifierNamespace<K, ? extends StmtContext<?, ?, ?>>> Prerequisite<Mutable<?,?,E>> mutatesEffectiveCtx(StmtContext<?,?,?> context,Class<N> namespace, K key);
void apply(InferenceAction action) throws InferenceException;
public abstract class NamespaceBehaviour<K, V, N extends IdentifierNamespace<K, V>> implements Identifiable<Class<N>> {
public enum StorageNodeType {
- GLOBAL, SOURCE_LOCAL_SPECIAL, STATEMENT_LOCAL,
+ GLOBAL, SOURCE_LOCAL_SPECIAL, STATEMENT_LOCAL, ROOT_STATEMENT_LOCAL
}
public interface Registry {
@Override
public V getFrom(final NamespaceStorageNode storage, final K key) {
- NamespaceStorageNode current = storage;
- while (current.getStorageNodeType() != storageType) {
- current = current.getParentNamespaceStorage();
- }
+ NamespaceStorageNode current = findClosestTowardsRoot(storage, storageType);
return getFromLocalStorage(current, key);
}
@Override
public void addTo(NamespaceBehaviour.NamespaceStorageNode storage, K key, V value) {
- NamespaceStorageNode current = storage;
- while (current.getStorageNodeType() != storageType) {
- current = current.getParentNamespaceStorage();
- }
+ NamespaceStorageNode current = findClosestTowardsRoot(storage, storageType);
addToStorage(current, key, value);
}
}
}
+
+ protected static NamespaceStorageNode findClosestTowardsRoot(NamespaceStorageNode storage, StorageNodeType type) {
+ NamespaceStorageNode current = storage;
+ while(current != null && current.getStorageNodeType() != type) {
+ current = current.getParentNamespaceStorage();
+ }
+ return current;
+ }
}
import com.google.common.base.Preconditions;
import com.google.common.base.Throwables;
+import com.google.common.base.Verify;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import java.util.ArrayList;
import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
+import org.opendaylight.yangtools.yang.parser.spi.meta.DerivedNamespaceBehaviour;
import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour;
import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.NamespaceStorageNode;
if (potential == null) {
NamespaceBehaviour<K, V, N> potentialRaw = supports.get(currentPhase).getNamespaceBehaviour(type);
if(potentialRaw != null) {
- potential = new NamespaceBehaviourWithListeners<>(potentialRaw);
+ potential = createNamespaceContext(potentialRaw);
supportedNamespaces.put(type, potential);
+ } else {
+ throw new NamespaceNotAvailableException(
+ "Namespace " + type + " is not available in phase " + currentPhase);
}
}
- if (potential != null) {
- Preconditions.checkState(type.equals(potential.getIdentifier()));
+ Verify.verify(type.equals(potential.getIdentifier()));
/*
- * Safe cast, previous checkState checks equivalence of key from
- * which type argument are derived
- */
- return (NamespaceBehaviourWithListeners<K, V, N>) potential;
+ * Safe cast, previous checkState checks equivalence of key from which type argument are
+ * derived
+ */
+ return (NamespaceBehaviourWithListeners<K, V, N>) potential;
+ }
+
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ private <K, V, N extends IdentifierNamespace<K, V>> NamespaceBehaviourWithListeners<K, V, N> createNamespaceContext(
+ NamespaceBehaviour<K, V, N> potentialRaw) {
+ if (potentialRaw instanceof DerivedNamespaceBehaviour) {
+ VirtualNamespaceContext derivedContext =
+ new VirtualNamespaceContext<>(potentialRaw);
+ getNamespaceBehaviour(((DerivedNamespaceBehaviour) potentialRaw).getDerivedFrom())
+ .addDerivedNamespace(derivedContext);
+ return derivedContext;
}
- throw new NamespaceNotAvailableException("Namespace " + type + " is not available in phase " + currentPhase);
+ return new SimpleNamespaceContext<>(potentialRaw);
}
public StatementDefinitionContext<?, ?, ?> getStatementDefinition(final QName name) {
import static org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase.EFFECTIVE_MODEL;
import static org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase.FULL_DECLARATION;
+
import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import java.util.HashSet;
return new IllegalStateException("Source exception during registering prerequisite. This is probably bug.",e);
}
- private void tryToResolve() throws InferenceException {
- if(action == null || isApplied()) {
- // Action was not yet defined
- return;
- }
- if(removeSatisfied()) {
- applyAction();
- }
- }
-
private boolean removeSatisfied() {
Iterator<AbstractPrerequisite<?>> prereq = unsatisfied.iterator();
boolean allSatisfied = true;
}
private void applyAction() throws InferenceException {
-
- try {
- action.apply();
- } catch (InferenceException e) {
- actionApplied = false;
- return;
- }
- // Â Mark all mutations as performed, so context node could move to next.
+ Preconditions.checkState(!actionApplied);
+ action.apply();
actionApplied = true;
}
}
@SuppressWarnings({ "rawtypes", "unchecked" })
- private <K, C extends StmtContext.Mutable<?, ?, ?> , N extends StatementNamespace<K, ?, ? >> AbstractPrerequisite<C> mutatesCtxImpl(
+ private <K, C extends StmtContext.Mutable<?, ?, ?> , N extends IdentifierNamespace<K, ? extends StmtContext<?, ?, ?>>> AbstractPrerequisite<C> mutatesCtxImpl(
final StmtContext<?, ?, ?> context, final Class<N> namespace, final K key, final ModelProcessingPhase phase) {
try {
PhaseModificationInNamespace<C> mod = new PhaseModificationInNamespace<C>(phase);
+ addReq(mod);
addMutation(mod);
contextImpl(context).onNamespaceItemAddedAction((Class) namespace,key,mod);
return mod;
}
}
- private static StatementContextBase<?,?,?> contextImpl(final StmtContext<?,?,?> context) {
- Preconditions.checkArgument(context instanceof StatementContextBase,"Supplied context was not provided by this reactor.");
- return StatementContextBase.class.cast(context);
+ private static StatementContextBase<?,?,?> contextImpl(final Object value) {
+ Preconditions.checkArgument(value instanceof StatementContextBase,"Supplied context was not provided by this reactor.");
+ return StatementContextBase.class.cast(value);
+ }
+
+ boolean tryApply() {
+ Preconditions.checkState(action != null, "Action was not defined yet.");
+
+ if (removeSatisfied()) {
+ applyAction();
+ return true;
+ }
+ return false;
}
@Override
@Override
- public <K, E extends EffectiveStatement<?, ?>, N extends StatementNamespace<K, ?, ? extends E>> AbstractPrerequisite<Mutable<?, ?, E>> mutatesEffectiveCtx(
+ public <K, E extends EffectiveStatement<?, ?>, N extends IdentifierNamespace<K, ? extends StmtContext<?, ?, ?>>> AbstractPrerequisite<Mutable<?, ?, E>> mutatesEffectiveCtx(
final StmtContext<?, ?, ?> context, final Class<N> namespace, final K key) {
return mutatesCtxImpl(context, namespace, key, EFFECTIVE_MODEL);
}
@Override
public void apply(final InferenceAction action) throws InferenceException {
this.action = Preconditions.checkNotNull(action);
- tryToResolve();
}
private abstract class AbstractPrerequisite<T> implements Prerequisite<T> {
protected boolean resolvePrereq(final T value) throws InferenceException {
this.value = value;
this.done = true;
- tryToResolve();
return isApplied();
}
@Override
public void namespaceItemAdded(final StatementContextBase<?, ?, ?> context, final Class<?> namespace, final Object key,
final Object value) throws SourceException {
- context.addMutation(modPhase,this);
- resolvePrereq((C) context);
+ StatementContextBase<?, ?, ?> targetCtx = contextImpl(value);
+ targetCtx.addMutation(modPhase,this);
+ resolvePrereq((C) targetCtx);
}
@Override
*/
package org.opendaylight.yangtools.yang.parser.stmt.reactor;
-import com.google.common.base.Optional;
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.Multimap;
-import java.util.Collection;
+import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
-import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
-import org.opendaylight.yangtools.yang.parser.builder.impl.ModuleIdentifierImpl;
import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour;
-final class NamespaceBehaviourWithListeners<K,V, N extends IdentifierNamespace<K, V>> extends NamespaceBehaviour<K, V, N> {
+abstract class NamespaceBehaviourWithListeners<K, V, N extends IdentifierNamespace<K, V>>
+ extends NamespaceBehaviour<K, V, N> {
- abstract static class ValueAddedListener {
+ abstract static class ValueAddedListener<K> {
private final NamespaceStorageNode ctxNode;
+ private K key;
- public ValueAddedListener(final NamespaceStorageNode contextNode) {
+ public ValueAddedListener(final NamespaceStorageNode contextNode, K key) {
this.ctxNode = contextNode;
+ this.key = key;
+ }
+
+ public NamespaceStorageNode getCtxNode() {
+ return ctxNode;
+ }
+
+ public K getKey() {
+ return key;
}
abstract void onValueAdded(Object key, Object value);
}
private final NamespaceBehaviour<K, V, N> delegate;
- private final Multimap<K, ValueAddedListener> listeners = HashMultimap.create();
+ private final List<VirtualNamespaceContext<?, V, ?>> derivedNamespaces = new ArrayList<>();
+
protected NamespaceBehaviourWithListeners(final NamespaceBehaviour<K, V, N> delegate) {
super(delegate.getIdentifier());
this.delegate = delegate;
}
+ protected abstract void addListener(K key, ValueAddedListener<K> listener);
+
+ protected abstract Iterator<ValueAddedListener<K>> getMutableListeners(K key);
+
+ protected abstract boolean isRequestedValue(ValueAddedListener<K> listener, NamespaceStorageNode storage, V value);
+
@Override
public void addTo(final NamespaceStorageNode storage, final K key, final V value) {
delegate.addTo(storage, key, value);
- Iterator<ValueAddedListener> keyListeners = listeners.get(key).iterator();
+ Iterator<ValueAddedListener<K>> keyListeners = getMutableListeners(key);
+ List<ValueAddedListener<K>> toNotify = new ArrayList<>();
while (keyListeners.hasNext()) {
- ValueAddedListener listener = keyListeners.next();
- if (listener.ctxNode == storage || hasIdentiticalValue(listener.ctxNode,key,value)) {
+ ValueAddedListener<K> listener = keyListeners.next();
+ if (isRequestedValue(listener, storage, value)) {
keyListeners.remove();
- listener.onValueAdded(key, value);
+ toNotify.add(listener);
}
}
-
- if (key instanceof ModuleIdentifier && !listeners.isEmpty()) {
- Collection<ValueAddedListener> defaultImportListeners = getDefaultImportListeners((ModuleIdentifier) key);
- Iterator<ValueAddedListener> defaultImportsIterator = defaultImportListeners.iterator();
- while (defaultImportsIterator.hasNext()) {
- ValueAddedListener listener = defaultImportsIterator.next();
- if(listener.ctxNode == storage || hasIdentiticalValue(listener.ctxNode,key,value)) {
- defaultImportsIterator.remove();
- listener.onValueAdded(key, value);
- }
- }
+ for(ValueAddedListener<K> listener : toNotify) {
+ listener.onValueAdded(key, value);
+ }
+ for (VirtualNamespaceContext<?, V, ?> derived : derivedNamespaces) {
+ derived.addTo(storage, null, value);
}
}
- private Collection<ValueAddedListener> getDefaultImportListeners(final ModuleIdentifier key) {
- ModuleIdentifier defaultImportKey = new ModuleIdentifierImpl(key.getName(),
- Optional.fromNullable(key.getNamespace()), Optional.of(SimpleDateFormatUtil.DEFAULT_DATE_IMP));
- return listeners.get((K)defaultImportKey);
- }
-
- private boolean hasIdentiticalValue(final NamespaceStorageNode ctxNode, final K key, final V value) {
- return getFrom(ctxNode, key) == value;
+ final void addValueListener(final ValueAddedListener<K> listener) {
+ addListener(listener.key, listener);
}
- void addValueListener(final K key, final ValueAddedListener listener) {
- listeners.put(key, listener);
+ final void addDerivedNamespace(VirtualNamespaceContext<?, V, ?> namespace) {
+ derivedNamespaces.add(namespace);
}
@Override
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.NamespaceStorageNode;
import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.Registry;
+import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.StorageNodeType;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
return sourceContext;
}
+ @Override
+ public StorageNodeType getStorageNodeType() {
+ return StorageNodeType.ROOT_STATEMENT_LOCAL;
+ }
/**
* @return this as its own root
*/
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. 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.stmt.reactor;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
+import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour;
+
+final class SimpleNamespaceContext<K, V, N extends IdentifierNamespace<K, V>>
+ extends NamespaceBehaviourWithListeners<K, V, N> {
+
+ // FIXME: Change this to Multimap, once issue with modules
+ // is resolved.
+ private final List<NamespaceBehaviourWithListeners.ValueAddedListener<K>> listeners = new ArrayList<>();
+ public SimpleNamespaceContext(NamespaceBehaviour<K, V, N> delegate) {
+ super(delegate);
+ }
+
+ protected boolean isRequestedValue(NamespaceBehaviourWithListeners.ValueAddedListener<K> listener, NamespaceStorageNode storage, V value) {
+ NamespaceStorageNode listenerCtx = listener.getCtxNode();
+ return value == getFrom(listenerCtx, listener.getKey());
+ }
+
+ @Override
+ protected void addListener(K key, NamespaceBehaviourWithListeners.ValueAddedListener<K> listener) {
+ listeners.add(listener);
+ }
+
+ @Override
+ protected Iterator<NamespaceBehaviourWithListeners.ValueAddedListener<K>> getMutableListeners(K key) {
+ return listeners.iterator();
+ }
+}
\ No newline at end of file
PhaseCompletionProgress tryToCompletePhase(final ModelProcessingPhase phase) throws SourceException {
Collection<ModifierImpl> currentPhaseModifiers = modifiers.get(phase);
- boolean hasProgressed = hasProgress(currentPhaseModifiers);
+ boolean hasProgressed = tryToProgress(currentPhaseModifiers);
boolean phaseCompleted = root.tryToCompletePhase(phase);
- hasProgressed = (hasProgress(currentPhaseModifiers) | hasProgressed);
+ hasProgressed = (tryToProgress(currentPhaseModifiers) | hasProgressed);
if (phaseCompleted && (currentPhaseModifiers.isEmpty())) {
finishedPhase = phase;
}
- private static boolean hasProgress(final Collection<ModifierImpl> currentPhaseModifiers) {
+ private static boolean tryToProgress(final Collection<ModifierImpl> currentPhaseModifiers) {
Iterator<ModifierImpl> modifier = currentPhaseModifiers.iterator();
boolean hasProgressed = false;
while (modifier.hasNext()) {
- if (modifier.next().isApplied()) {
+ if (modifier.next().tryApply()) {
modifier.remove();
hasProgressed = true;
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.reactor;
-import java.util.LinkedList;
-
-import java.util.List;
import com.google.common.base.Preconditions;
import com.google.common.base.Throwables;
import com.google.common.collect.HashMultimap;
import java.util.EventListener;
import java.util.Iterator;
import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Map;
import javax.annotation.Nonnull;
import org.opendaylight.yangtools.concepts.Identifiable;
NamespaceBehaviour<K, V, N> behaviour = getBehaviourRegistry().getNamespaceBehaviour(type);
if (behaviour instanceof NamespaceBehaviourWithListeners) {
NamespaceBehaviourWithListeners<K, V, N> casted = (NamespaceBehaviourWithListeners<K, V, N>) behaviour;
- casted.addValueListener(key, new ValueAddedListener(this) {
+ casted.addValueListener(new ValueAddedListener<K>(this, key) {
@Override
void onValueAdded(Object key, Object value) {
try {
} else {
this.argument = original.argument;
}
-
- copyDeclaredStmts(original, newQNameModule, typeOfCopy);
-
- copyEffectiveStmts(original, newQNameModule, typeOfCopy);
}
private void copyDeclaredStmts(SubstatementContext<A, D, E> original,
}
definition().onStatementAdded(copy);
+
+ copy.copyDeclaredStmts(this, newQNameModule, typeOfCopy);
+ copy.copyEffectiveStmts(this, newQNameModule, typeOfCopy);
return copy;
}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. 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.stmt.reactor;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
+import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour;
+
+final class VirtualNamespaceContext<K, V, N extends IdentifierNamespace<K, V>>
+ extends NamespaceBehaviourWithListeners<K, V, N> {
+
+ private final List<NamespaceBehaviourWithListeners.ValueAddedListener<K>> listeners = new ArrayList<>(20);
+
+ public VirtualNamespaceContext(NamespaceBehaviour<K, V, N> delegate) {
+ super(delegate);
+ }
+
+ protected boolean isRequestedValue(NamespaceBehaviourWithListeners.ValueAddedListener<K> listener, NamespaceStorageNode storage, V value) {
+ return value == getFrom(listener.getCtxNode(), listener.getKey());
+ }
+
+ @Override
+ protected void addListener(K key, NamespaceBehaviourWithListeners.ValueAddedListener<K> listener) {
+ listeners.add(listener);
+ }
+
+ @Override
+ protected Iterator<NamespaceBehaviourWithListeners.ValueAddedListener<K>> getMutableListeners(K key) {
+ return listeners.iterator();
+ }
+}
\ No newline at end of file
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
import org.opendaylight.yangtools.yang.parser.spi.meta.ModelActionBuilder;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ModelActionBuilder.Prerequisite;
import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.AugmentEffectiveStatementImpl;
}
final ModelActionBuilder augmentAction = augmentNode
- .newInferenceAction(ModelProcessingPhase.FULL_DECLARATION);
+ .newInferenceAction(ModelProcessingPhase.EFFECTIVE_MODEL);
final ModelActionBuilder.Prerequisite<StmtContext<SchemaNodeIdentifier, AugmentStatement, EffectiveStatement<SchemaNodeIdentifier, AugmentStatement>>> sourceCtxPrereq = augmentAction
- .requiresCtx(augmentNode,
- ModelProcessingPhase.FULL_DECLARATION);
-
+ .requiresCtx(augmentNode, ModelProcessingPhase.EFFECTIVE_MODEL);
+ final Prerequisite<Mutable<?, ?, EffectiveStatement<?, ?>>> target = augmentAction.mutatesEffectiveCtx(getSearchRoot(augmentNode), SchemaNodeIdentifierBuildNamespace.class, augmentNode.getStatementArgument());
augmentAction.apply(new ModelActionBuilder.InferenceAction() {
@Override
public void apply() throws InferenceException {
- final StatementContextBase<?, ?, ?> augmentTargetCtx = AugmentUtils
- .getAugmentTargetCtx(augmentNode);
-
- if (augmentTargetCtx == null) {
- throw new InferenceException(
- "Augment target not found: "
- + augmentNode.getStatementArgument(),
- augmentNode.getStatementSourceReference());
- }
+ final StatementContextBase<?, ?, ?> augmentTargetCtx = (StatementContextBase<?, ?, ?>) target.get();
if (!AugmentUtils.isSupportedAugmentTarget(augmentTargetCtx) || StmtContextUtils.isInExtensionBody(augmentTargetCtx)) {
augmentNode.setIsSupportedToBuildEffective(false);
return;
}
-
final StatementContextBase<?, ?, ?> augmentSourceCtx = (StatementContextBase<?, ?, ?>) augmentNode;
-
try {
AugmentUtils.copyFromSourceToTarget(augmentSourceCtx,
augmentTargetCtx);
}
});
}
+
+ private Mutable<?, ?, ?> getSearchRoot(Mutable<?, ?, ?> augmentContext) {
+ Mutable<?, ?, ?> parent = augmentContext.getParentContext();
+ // Augment is in uses - we need to augment instantiated nodes in parent.
+ if(Rfc6020Mapping.USES.equals(parent.getPublicDefinition())) {
+ return parent.getParentContext();
+ }
+ return parent;
+ }
}
@Nonnull
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList.Builder;
import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.regex.Pattern;
-import javax.annotation.Nullable;
import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.QNameModule;
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
-import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.AugmentStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.DataDefinitionStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.MandatoryStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier;
import org.opendaylight.yangtools.yang.model.api.stmt.UsesStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.WhenStatement;
-import org.opendaylight.yangtools.yang.parser.spi.NamespaceToModule;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.TypeOfCopy;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
-import org.opendaylight.yangtools.yang.parser.spi.source.ModuleCtxToModuleQName;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
import org.opendaylight.yangtools.yang.parser.spi.validation.ValidationBundlesNamespace;
import org.opendaylight.yangtools.yang.parser.spi.validation.ValidationBundlesNamespace.ValidationBundleType;
import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+// FIXME: Move this to the AugmentStatementDefinition#ApplyAction
public final class AugmentUtils {
- private static final Logger LOG = LoggerFactory.getLogger(AugmentUtils.class);
private static final Pattern PATH_REL_PATTERN1 = Pattern.compile("\\.\\.?\\s*/(.+)");
private static final Pattern PATH_REL_PATTERN2 = Pattern.compile("//.*");
private AugmentUtils() {
- throw new UnsupportedOperationException();
}
public static Iterable<QName> parseAugmentPath(final StmtContext<?, ?, ?> ctx, final String path) {
Preconditions.checkArgument(!PATH_REL_PATTERN1.matcher(path).matches()
&& !PATH_REL_PATTERN2.matcher(path).matches(),
- "An argument for augment can be only absolute path; or descendant if used in uses");
-
+ "An argument for augment can be only absolute path; or descendant if used in uses");
return Utils.parseXPath(ctx, path);
}
public static void copyFromSourceToTarget(final StatementContextBase<?, ?, ?> sourceCtx,
final StatementContextBase<?, ?, ?> targetCtx) throws SourceException {
-
copyDeclaredStmts(sourceCtx, targetCtx);
copyEffectiveStmts(sourceCtx, targetCtx);
}
- public static void copyDeclaredStmts(final StatementContextBase<?, ?, ?> sourceCtx,
+ // FIXME: Declared statements should not be copied.
+ private static void copyDeclaredStmts(final StatementContextBase<?, ?, ?> sourceCtx,
final StatementContextBase<?, ?, ?> targetCtx) throws SourceException {
final List<StatementContextBase<?, ?, ?>> subStatements = new Builder<StatementContextBase<?, ?, ?>>()
}
}
- public static void copyEffectiveStmts(final StatementContextBase<?, ?, ?> sourceCtx,
+ private static void copyEffectiveStmts(final StatementContextBase<?, ?, ?> sourceCtx,
final StatementContextBase<?, ?, ?> targetCtx) throws SourceException {
final List<StatementContextBase<?, ?, ?>> subStatements = new Builder<StatementContextBase<?, ?, ?>>()
}
private static void validateNodeCanBeCopiedByAugment(final StatementContextBase<?, ?, ?> sourceCtx,
- final Iterable<StatementContextBase<?, ?, ?>> targetSubStatements,
- final boolean sourceAndTargetInSameModule) {
+ final List<StatementContextBase<?, ?, ?>> targetSubStatements, final boolean sourceAndTargetInSameModule) {
- if (WhenStatement.class.equals(sourceCtx.getPublicDefinition().getDeclaredRepresentationClass())) {
+ if (sourceCtx.getPublicDefinition().getDeclaredRepresentationClass().equals(WhenStatement.class)) {
return;
}
if (!sourceAndTargetInSameModule) {
- for (final StatementContextBase<?, ?, ?> sourceSubStatement :
- Iterables.concat(sourceCtx.declaredSubstatements(), sourceCtx.effectiveSubstatements())) {
- Preconditions.checkArgument(!MandatoryStatement.class.equals(
- sourceSubStatement.getPublicDefinition().getDeclaredRepresentationClass()),
- "An augment cannot add node '%s' because it is mandatory and in module different from target",
- sourceCtx.rawStatementArgument());
+ final List<StatementContextBase<?, ?, ?>> sourceSubStatements = new Builder<StatementContextBase<?, ?, ?>>()
+ .addAll(sourceCtx.declaredSubstatements()).addAll(sourceCtx.effectiveSubstatements()).build();
+
+ for (final StatementContextBase<?, ?, ?> sourceSubStatement : sourceSubStatements) {
+ if (sourceSubStatement.getPublicDefinition().getDeclaredRepresentationClass()
+ .equals(MandatoryStatement.class)) {
+ throw new IllegalArgumentException(
+ String.format(
+ "An augment cannot add node '%s' because it is mandatory and in module different from target",
+ sourceCtx.rawStatementArgument()));
+ }
}
}
for (final StatementContextBase<?, ?, ?> subStatement : targetSubStatements) {
- final boolean sourceIsDataNode = DataDefinitionStatement.class.isAssignableFrom(
- sourceCtx.getPublicDefinition().getDeclaredRepresentationClass());
- final boolean targetIsDataNode = DataDefinitionStatement.class.isAssignableFrom(
- subStatement.getPublicDefinition().getDeclaredRepresentationClass());
- Preconditions.checkState(!sourceIsDataNode || !targetIsDataNode
- || !Objects.equals(sourceCtx.getStatementArgument(), subStatement.getStatementArgument()),
- "An augment cannot add node named '%s' because this name is already used in target",
- sourceCtx.rawStatementArgument());
- }
- }
-
- public static QNameModule getNewQNameModule(final StatementContextBase<?, ?, ?> targetCtx,
- final StatementContextBase<?, ?, ?> sourceCtx) {
- Object targetStmtArgument = targetCtx.getStatementArgument();
-
- final StatementContextBase<?, ?, ?> root = sourceCtx.getRoot();
- final QNameModule sourceQNameModule = root.getFromNamespace(ModuleCtxToModuleQName.class, root);
-
- if (targetStmtArgument instanceof QName) {
- QName targetQName = (QName) targetStmtArgument;
- QNameModule targetQNameModule = targetQName.getModule();
-
- if (targetQNameModule.equals(sourceQNameModule)) {
- return null;
- } else {
- return targetQNameModule;
+ final boolean sourceIsDataNode = DataDefinitionStatement.class.isAssignableFrom(sourceCtx
+ .getPublicDefinition().getDeclaredRepresentationClass());
+ final boolean targetIsDataNode = DataDefinitionStatement.class.isAssignableFrom(subStatement
+ .getPublicDefinition().getDeclaredRepresentationClass());
+ boolean qNamesEqual = sourceIsDataNode && targetIsDataNode
+ && Objects.equals(sourceCtx.getStatementArgument(), subStatement.getStatementArgument());
+
+ if (qNamesEqual) {
+ throw new IllegalStateException(String.format(
+ "An augment cannot add node named '%s' because this name is already used in target",
+ sourceCtx.rawStatementArgument()));
}
- } else {
- return null;
}
}
return REUSED_DEF_SET.contains(stmtContext.getPublicDefinition());
}
- public static StatementContextBase<?, ?, ?> getAugmentTargetCtx(
- final Mutable<SchemaNodeIdentifier, AugmentStatement, EffectiveStatement<SchemaNodeIdentifier, AugmentStatement>> augmentNode) {
-
- final SchemaNodeIdentifier augmentTargetNode = augmentNode.getStatementArgument();
- Preconditions.checkArgument(augmentTargetNode != null,
- "Augment argument null, something bad happened in some of previous parsing phases");
-
- List<StatementContextBase<?, ?, ?>> rootStatementCtxList = new ArrayList<>();
- if (augmentTargetNode.isAbsolute()) {
-
- QNameModule module = augmentTargetNode.getPathFromRoot().iterator().next().getModule();
-
- StatementContextBase<?, ?, ?> rootStatementCtx =
- (StatementContextBase<?, ?, ?>) augmentNode.getFromNamespace(NamespaceToModule.class, module);
- rootStatementCtxList.add(rootStatementCtx);
-
- final Map<?, ?> subModules = rootStatementCtx.getAllFromNamespace(IncludedModuleContext.class);
- if (subModules != null) {
- rootStatementCtxList.addAll((Collection<? extends StatementContextBase<?, ?, ?>>) subModules.values());
- }
-
- } else {
- StatementContextBase<?, ?, ?> parent = (StatementContextBase<?, ?, ?>) augmentNode.getParentContext();
- if (StmtContextUtils.producesDeclared(parent, UsesStatement.class)) {
- rootStatementCtxList.add(parent.getParentContext());
- } else {
- // error
- }
- }
-
- StatementContextBase<?, ?, ?> augmentTargetCtx = null;
- for (final StatementContextBase<?, ?, ?> rootStatementCtx : rootStatementCtxList) {
- augmentTargetCtx = findCtxOfNodeInRoot(rootStatementCtx, augmentTargetNode);
- if (augmentTargetCtx != null) {
- break;
- }
- }
-
- return augmentTargetCtx;
- }
-
- @Nullable
- public static StatementContextBase<?, ?, ?> findCtxOfNodeInSubstatements(final StatementContextBase<?, ?, ?> rootStmtCtx,
- final Iterable<QName> path) {
-
- StatementContextBase<?, ?, ?> parent = rootStmtCtx;
-
- Iterator<QName> pathIter = path.iterator();
- while (pathIter.hasNext()) {
- QName nextPathQName = pathIter.next();
- StatementContextBase<?, ?, ?> foundSubstatement = getSubstatementByQName(parent, nextPathQName);
-
- if (foundSubstatement == null) {
- return null;
- }
- if (!pathIter.hasNext()) {
- return foundSubstatement;
- }
-
- parent = foundSubstatement;
- }
-
- return null;
- }
-
- public static StatementContextBase<?, ?, ?> getSubstatementByQName(final StatementContextBase<?, ?, ?> parent,
- final QName nextPathQName) {
-
- Collection<StatementContextBase<?, ?, ?>> declaredSubstatement = parent.declaredSubstatements();
- Collection<StatementContextBase<?, ?, ?>> effectiveSubstatement = parent.effectiveSubstatements();
-
- for (StatementContextBase<?, ?, ?> substatement : Iterables.concat(declaredSubstatement, effectiveSubstatement)) {
- Object substatementArgument = substatement.getStatementArgument();
- QName substatementQName;
- if (substatementArgument instanceof QName) {
- substatementQName = (QName) substatementArgument;
-
- if (nextPathQName.getLocalName().equals(
- substatementQName.getLocalName())) {
- if (isSupportedAugmentTarget(substatement)) {
- return substatement;
- } else if (Utils.isUnknownNode(substatement)) {
- LOG.warn("Module '{}': augment into unknown node '{}'.",
- substatement.getRoot().getStatementArgument(), substatementArgument);
- return substatement;
- }
- }
- }
- }
-
- return null;
- }
-
- public static boolean isSupportedAugmentTarget(final StatementContextBase<?, ?, ?> substatementCtx) {
+ static boolean isSupportedAugmentTarget(final StatementContextBase<?, ?, ?> substatementCtx) {
/*
* :TODO Substatement must be allowed augment target type e.g. Container, etc... and must be not for example
return allowedAugmentTargets == null || allowedAugmentTargets.isEmpty()
|| allowedAugmentTargets.contains(substatementCtx.getPublicDefinition());
}
-
- @Nullable
- public static StatementContextBase<?, ?, ?> findCtxOfNodeInRoot(final StatementContextBase<?, ?, ?> rootStmtCtx,
- final SchemaNodeIdentifier node) {
- return findCtxOfNodeInSubstatements(rootStmtCtx, node.getPathFromRoot());
- }
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import java.util.Map;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour;
import org.opendaylight.yangtools.yang.parser.spi.meta.StatementNamespace;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
/**
* Statement local namespace, which holds direct schema node descendants.
* @param <D>
* @param <E>
*/
-public interface ChildSchemaNodes<D extends DeclaredStatement<QName>,E extends EffectiveStatement<QName, D>> extends StatementNamespace<QName, D, E>{
+public class ChildSchemaNodes<D extends DeclaredStatement<QName>,E extends EffectiveStatement<QName, D>>
+ extends NamespaceBehaviour<QName, StmtContext<?, D, E>, ChildSchemaNodes<D, E>>
+ implements StatementNamespace<QName, D, E>{
+ protected ChildSchemaNodes() {
+ super((Class<ChildSchemaNodes<D,E>>) (Class) ChildSchemaNodes.class);
+ }
+
+ @Override
+ public StmtContext<?, D, E> get(QName key) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public StmtContext<?, D, E> getFrom(NamespaceStorageNode storage, QName key) {
+ return globalOrStatementSpecific(storage).getFromLocalStorage(getIdentifier(), key);
+ }
+
+ @Override
+ public Map<QName, StmtContext<?, D, E>> getAllFrom(NamespaceStorageNode storage) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void addTo(NamespaceBehaviour.NamespaceStorageNode storage, QName key, StmtContext<?, D, E> value) {
+ globalOrStatementSpecific(storage).addToLocalStorage(ChildSchemaNodes.class, key, value);
+ }
+
+ private NamespaceStorageNode globalOrStatementSpecific(NamespaceBehaviour.NamespaceStorageNode storage) {
+ NamespaceStorageNode current = storage;
+ while(current.getStorageNodeType() != StorageNodeType.STATEMENT_LOCAL && current.getStorageNodeType() != StorageNodeType.GLOBAL) {
+ current = current.getParentNamespaceStorage();
+ }
+ return current;
+ }
}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. 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.stmt.rfc6020;
+
+import java.util.Iterator;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
+import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier;
+import org.opendaylight.yangtools.yang.parser.spi.meta.DerivedNamespaceBehaviour;
+import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+class SchemaNodeIdentifierBuildNamespace extends
+ DerivedNamespaceBehaviour<SchemaNodeIdentifier, StmtContext.Mutable<?, ?, EffectiveStatement<?, ?>>, SchemaNodeIdentifierBuildNamespace, ChildSchemaNodes<?, ?>>
+ implements IdentifierNamespace<SchemaNodeIdentifier, StmtContext.Mutable<?, ?, EffectiveStatement<?, ?>>> {
+
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ protected SchemaNodeIdentifierBuildNamespace() {
+ super(SchemaNodeIdentifierBuildNamespace.class, (Class) ChildSchemaNodes.class);
+ }
+
+ @Override
+ public StmtContext.Mutable<?, ?, EffectiveStatement<?, ?>> get(
+ SchemaNodeIdentifier key) {
+ throw new UnsupportedOperationException("Direct access to namespace is not supported");
+ }
+
+ @Override
+ public StmtContext.Mutable<?, ?, EffectiveStatement<?, ?>> getFrom(NamespaceStorageNode storage, SchemaNodeIdentifier key) {
+
+ final NamespaceStorageNode lookupStartStorage;
+ if(key.isAbsolute() || storage.getStorageNodeType() == StorageNodeType.ROOT_STATEMENT_LOCAL) {
+ lookupStartStorage = NamespaceBehaviour.findClosestTowardsRoot(storage, StorageNodeType.GLOBAL);
+ } else {
+ lookupStartStorage = storage;
+ }
+ Iterator<QName> iterator = key.getPathFromRoot().iterator();
+ if(!iterator.hasNext()) {
+ if(lookupStartStorage instanceof StmtContext<?, ?, ?>) {
+ return (StmtContext.Mutable<?, ?, EffectiveStatement<?, ?>>) lookupStartStorage;
+ } else {
+ return null;
+ }
+ }
+ StmtContext.Mutable<?, ?, EffectiveStatement<?, ?>> current = (StmtContext.Mutable<?, ?, EffectiveStatement<?, ?>>) lookupStartStorage.getFromLocalStorage(ChildSchemaNodes.class, iterator.next());
+ while(current != null && iterator.hasNext()) {
+ current = (StmtContext.Mutable<?, ?, EffectiveStatement<?, ?>>) current.getFromNamespace(ChildSchemaNodes.class, iterator.next());
+ }
+ return current;
+ }
+
+}
import org.opendaylight.yangtools.yang.parser.spi.meta.ModelActionBuilder;
import org.opendaylight.yangtools.yang.parser.spi.meta.ModelActionBuilder.InferenceAction;
import org.opendaylight.yangtools.yang.parser.spi.meta.ModelActionBuilder.Prerequisite;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase;
return;
}
- ModelActionBuilder usesAction = usesNode.newInferenceAction(FULL_DECLARATION);
+ ModelActionBuilder usesAction = usesNode.newInferenceAction(ModelProcessingPhase.EFFECTIVE_MODEL);
final QName groupingName = usesNode.getStatementArgument();
final Prerequisite<StmtContext<?, ?, ?>> sourceGroupingPre = usesAction.requiresCtx(usesNode,
- GroupingNamespace.class, groupingName, FULL_DECLARATION);
- final Prerequisite<? extends StmtContext.Mutable<?, ?, ?>> targetNodePre = usesAction.mutatesCtx(
- usesNode.getParentContext(), FULL_DECLARATION);
+ GroupingNamespace.class, groupingName, ModelProcessingPhase.EFFECTIVE_MODEL);
+ final Prerequisite<? extends StmtContext.Mutable<?, ?, ?>> targetNodePre = usesAction.mutatesEffectiveCtx(
+ usesNode.getParentContext());
usesAction.apply(new InferenceAction() {
}
@Nullable
- public static StatementContextBase<?, ?, ?> findNode(final StatementContextBase<?, ?, ?> rootStmtCtx,
+ public static StatementContextBase<?, ?, ?> findNode(final StmtContext<?, ?, ?> rootStmtCtx,
final SchemaNodeIdentifier node) {
- StatementContextBase<?, ?, ?> current = rootStmtCtx;
- Iterator<QName> arguments = node.getPathFromRoot().iterator();
- while(current != null && arguments.hasNext()) {
- current = (StatementContextBase<?, ?, ?>) current.getFromNamespace(ChildSchemaNodes.class, arguments.next());
- }
- return current;
+ return (StatementContextBase<?, ?, ?>) rootStmtCtx.getFromNamespace(SchemaNodeIdentifierBuildNamespace.class, node);
}
public static SchemaPath getSchemaPath(final StmtContext<?, ?, ?> ctx) {
.addSupport(new YinElementStatementImpl.Definition())
.addSupport(new ArgumentStatementImpl.Definition())
.addSupport(new ExtensionStatementImpl.Definition())
- .addSupport(global(ChildSchemaNodes.class))
+ .addSupport(new ChildSchemaNodes())
+ .addSupport(new SchemaNodeIdentifierBuildNamespace())
.addSupport(global(ExtensionNamespace.class))
.addSupport(new TypedefStatementImpl.Definition())
.addSupport(treeScoped(TypeNamespace.class))
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.meta.ModelStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
MULTIPLE_AUGMENT_SUBMODULE);
EffectiveSchemaContext result = null;
- try {
- result = reactor.buildEffective();
- } catch (Exception e) {
- log(e, "");
- }
+ result = reactor.buildEffective();
assertNotNull(result);
}
addSources(reactor, MULTIPLE_AUGMENT);
EffectiveSchemaContext result = null;
- try {
- result = reactor.buildEffective();
- } catch (Exception e) {
- log(e, "");
- }
+ result = reactor.buildEffective();
assertNotNull(result);
}
- @Test
+ @Test(expected=SomeModifiersUnresolvedException.class)
public void multipleAugmentIncorrectPathTest() throws SourceException,
ReactorException {
CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
addSources(reactor, MULTIPLE_AUGMENT_INCORRECT);
EffectiveSchemaContext result = null;
- try {
- result = reactor.buildEffective();
- } catch (Exception e) {
- log(e, "");
- }
-
+ result = reactor.buildEffective();
assertNull(result);
}
- @Test
+ @Test(expected=SomeModifiersUnresolvedException.class)
public void multipleAugmentIncorrectPathAndGrpTest()
throws SourceException, ReactorException {
CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
.newBuild();
addSources(reactor, MULTIPLE_AUGMENT_INCORRECT2);
-
EffectiveSchemaContext result = null;
- try {
- result = reactor.buildEffective();
- } catch (Exception e) {
- log(e, "");
- }
-
+ result = reactor.buildEffective();
assertNull(result);
}
- private void log(final Throwable e, final String indent) {
- System.out.println(indent + e.getMessage());
- Throwable[] suppressed = e.getSuppressed();
- for (Throwable throwable : suppressed) {
- log(throwable, indent + " ");
- }
- }
@Test
public void readAndParseYangFileTest() throws SourceException,
status obsolete;
}
- augment "/br:interfaces/br:ifEntry/br:augment-holder" {
+ augment "/br:interfaces/br:ifEntry/bz:augment-holder" {
when "if:ifType='ds0'";
leaf ds0ChannelNumber {
type string;
status obsolete;
}
- augment "/br:interfaces/br:ifEntry/br:augment-holder" {
+ augment "/br:interfaces/br:ifEntry/bz:augment-holder" {
when "if:ifType='ds0'";
leaf subleaf {
type string;
namespace "multiple-augment-imported";
prefix imp;
- augment /root-container/container-from-grp1/sub-container-from-grp1/container-in-uses-augment/sub-container-from-augment2/sub-container-from-augment3 {
- container sub-container-from-augment4 {
- }
- }
container root-container {
uses grp1 {
}
}
- augment /root-container/added-container-1 {
- container added-container-2 {
- }
- }
-
grouping grp2 {
container container-from-grp2 {
container sub-container-from-grp2 {
container sub-container-from-augment2 {
}
}
-
+
grouping grp-from-import {
container container-from-grp-from-import {
-
+
}
}
}
prefix root;
import multiple-augment-imported { prefix imp; revision-date 1970-01-01; }
-
+
include multiple-augment-submodule { revision-date 1970-01-01; }
augment /imp:root-container/imp:container-from-grp1/imp:sub-container-from-grp1/imp:container-in-uses-augment/imp:sub-container-from-augment2 {
}
}
- augment /imp:root-container/imp:container-from-grp1/imp:sub-container-from-grp1/imp:container-from-grp2/imp:sub-container-from-grp2/imp:sub-container-from-augment5 {
+ augment /imp:root-container/imp:container-from-grp1/imp:sub-container-from-grp1/imp:container-from-grp2/imp:sub-container-from-grp2/sub-container-from-augment5 {
container sub-container-from-augment7 {
}
}
container added-container-1 {
}
}
-
+
container container-with-multiple-uses {
uses imp:grp-from-import{
augment container-from-grp-from-import {