import org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeAwareEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeEffectiveStatement;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.DataNodeContainerMixin;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
/**
* Base stateless superclass for statements which (logically) always have an associated {@link DeclaredStatement}. This
private final @NonNull ImmutableMap<QName, DataSchemaNode> dataChildren;
private final @NonNull Object substatements;
- protected DefaultDataNodeContainer(final D declared, final StatementSourceReference ref,
+ protected DefaultDataNodeContainer(final D declared,
final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
super(declared);
this.substatements = maskList(substatements);
final DataSchemaNode node = (DataSchemaNode) stmt;
final QName id = node.getQName();
final DataSchemaNode prev = tmp.put(id, node);
- SourceException.throwIf(prev != null, ref,
- "Cannot add child with name %s, a conflicting child already exists", id);
+ if (prev != null) {
+ throw new SubstatementIndexingException(
+ "Cannot add child with name " + id + ", a conflicting child already exists");
+ }
}
}
private final @NonNull Object substatements;
protected WithSubstatements(final D declared,
- final ImmutableList<? extends EffectiveStatement<?, ?>> substatements,
- final StatementSourceReference ref) {
- super(declared, substatements, ref);
+ final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+ super(declared, substatements);
this.substatements = maskList(substatements);
}
private final @NonNull D declared;
protected DefaultWithSchemaTree(final D declared,
- final ImmutableList<? extends EffectiveStatement<?, ?>> substatements,
- final StatementSourceReference ref) {
+ final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
this.declared = requireNonNull(declared);
- this.schemaTree = ImmutableMap.copyOf(createSchemaTreeNamespace(ref, substatements));
+ this.schemaTree = ImmutableMap.copyOf(createSchemaTreeNamespace(substatements));
}
@Override
private final @NonNull Object substatements;
protected WithSubstatements(final D declared,
- final ImmutableList<? extends EffectiveStatement<?, ?>> substatements,
- final StatementSourceReference ref) {
- super(declared, substatements, ref);
+ final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+ super(declared, substatements);
this.substatements = maskList(substatements);
}
private final @NonNull D declared;
protected DefaultWithDataTree(final D declared,
- final ImmutableList<? extends EffectiveStatement<?, ?>> substatements,
- final StatementSourceReference ref) {
+ final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
this.declared = requireNonNull(declared);
- final Map<QName, SchemaTreeEffectiveStatement<?>> schema = createSchemaTreeNamespace(ref, substatements);
+ final Map<QName, SchemaTreeEffectiveStatement<?>> schema = createSchemaTreeNamespace(substatements);
this.schemaTree = ImmutableMap.copyOf(schema);
- this.dataTree = createDataTreeNamespace(ref, schema.values(), schemaTree);
+ this.dataTree = createDataTreeNamespace(schema.values(), schemaTree);
}
@Override
protected AbstractEffectiveModule(final Current<UnqualifiedQName, D> stmt,
final ImmutableList<? extends EffectiveStatement<?, ?>> substatements, final String prefix) {
- super(stmt.declared(), substatements, stmt.sourceReference());
+ super(stmt.declared(), substatements);
+ // FIXME: this seems to duplicate superclass logic
// This check is rather weird, but comes from our desire to lower memory footprint while providing both
// EffectiveStatements and SchemaNode interfaces -- which do not overlap completely where child lookups are
// concerned. This ensures that we have SchemaTree index available for use with child lookups.
- final Map<QName, SchemaTreeEffectiveStatement<?>> schemaTree =
- createSchemaTreeNamespace(stmt.sourceReference(), effectiveSubstatements());
+ final Map<QName, SchemaTreeEffectiveStatement<?>> schemaTree = createSchemaTreeNamespace(substatements);
schemaTreeNamespace = ImmutableMap.copyOf(schemaTree);
// Data tree check, not currently used
- createDataTreeNamespace(stmt.sourceReference(), schemaTree.values(), schemaTreeNamespace);
+ createDataTreeNamespace(schemaTree.values(), schemaTreeNamespace);
this.prefix = requireNonNull(prefix);
import org.opendaylight.yangtools.yang.model.api.stmt.ChoiceEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.DataTreeEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeEffectiveStatement;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
/**
* Baseline stateless implementation of an EffectiveStatement. This class adds a few default implementations and
// TODO: below methods need to find a better place, this is just a temporary hideout as their public class is on
// its way out
static @NonNull Map<QName, SchemaTreeEffectiveStatement<?>> createSchemaTreeNamespace(
- final StatementSourceReference ref, final Collection<? extends EffectiveStatement<?, ?>> substatements) {
+ final Collection<? extends EffectiveStatement<?, ?>> substatements) {
final Map<QName, SchemaTreeEffectiveStatement<?>> schemaChildren = new LinkedHashMap<>();
substatements.stream().filter(SchemaTreeEffectiveStatement.class::isInstance)
- .forEach(child -> putChild(schemaChildren, (SchemaTreeEffectiveStatement<?>) child, ref, "schema"));
+ .forEach(child -> putChild(schemaChildren, (SchemaTreeEffectiveStatement<?>) child, "schema"));
return schemaChildren;
}
static @NonNull ImmutableMap<QName, DataTreeEffectiveStatement<?>> createDataTreeNamespace(
- final StatementSourceReference ref,
final Collection<SchemaTreeEffectiveStatement<?>> schemaTreeStatements,
// Note: this dance is needed to not retain ImmutableMap$Values
final ImmutableMap<QName, SchemaTreeEffectiveStatement<?>> schemaTreeNamespace) {
for (SchemaTreeEffectiveStatement<?> child : schemaTreeStatements) {
if (child instanceof DataTreeEffectiveStatement) {
- putChild(dataChildren, (DataTreeEffectiveStatement<?>) child, ref, "data");
+ putChild(dataChildren, (DataTreeEffectiveStatement<?>) child, "data");
} else {
sameAsSchema = false;
- putChoiceDataChildren(dataChildren, ref, child);
+ putChoiceDataChildren(dataChildren, child);
}
}
return sameAsSchema ? (ImmutableMap) schemaTreeNamespace : ImmutableMap.copyOf(dataChildren);
}
- private static <T extends SchemaTreeEffectiveStatement<?>> void putChild(final Map<QName, T> map,
- final T child, final StatementSourceReference ref, final String tree) {
+ private static <T extends SchemaTreeEffectiveStatement<?>> void putChild(final Map<QName, T> map, final T child,
+ final String tree) {
final QName id = child.getIdentifier();
final T prev = map.putIfAbsent(id, child);
- SourceException.throwIf(prev != null, ref,
- "Cannot add %s tree child with name %s, a conflicting child already exists", tree, id);
+ if (prev != null) {
+ throw new SubstatementIndexingException(
+ "Cannot add " + tree + " tree child with name " + id + ", a conflicting child already exists");
+ }
}
private static void putChoiceDataChildren(final Map<QName, DataTreeEffectiveStatement<?>> map,
- final StatementSourceReference ref, final SchemaTreeEffectiveStatement<?> child) {
+ final SchemaTreeEffectiveStatement<?> child) {
// For choice statements go through all their cases and fetch their data children
if (child instanceof ChoiceEffectiveStatement) {
child.streamEffectiveSubstatements(CaseEffectiveStatement.class).forEach(
caseStmt -> caseStmt.streamEffectiveSubstatements(SchemaTreeEffectiveStatement.class).forEach(stmt -> {
if (stmt instanceof DataTreeEffectiveStatement) {
- putChild(map, (DataTreeEffectiveStatement<?>) stmt, ref, "data");
+ putChild(map, (DataTreeEffectiveStatement<?>) stmt, "data");
} else {
- putChoiceDataChildren(map, ref, stmt);
+ putChoiceDataChildren(map, stmt);
}
}));
}
import org.opendaylight.yangtools.yang.model.api.stmt.DataTreeEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeAwareEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeEffectiveStatement;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
@Beta
public abstract class AbstractUndeclaredEffectiveStatement<A, D extends DeclaredStatement<A>>
E extends SchemaTreeAwareEffectiveStatement<A, D>> extends DefaultWithSchemaTree<A, D, E> {
private final @NonNull Object substatements;
- protected WithSubstatements(final ImmutableList<? extends EffectiveStatement<?, ?>> substatements,
- final StatementSourceReference ref) {
- super(substatements, ref);
+ protected WithSubstatements(final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+ super(substatements);
this.substatements = maskList(substatements);
}
private final @NonNull ImmutableMap<QName, SchemaTreeEffectiveStatement<?>> schemaTree;
- protected DefaultWithSchemaTree(final ImmutableList<? extends EffectiveStatement<?, ?>> substatements,
- final StatementSourceReference ref) {
- this.schemaTree = ImmutableMap.copyOf(createSchemaTreeNamespace(ref, substatements));
+ protected DefaultWithSchemaTree(final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+ this.schemaTree = ImmutableMap.copyOf(createSchemaTreeNamespace(substatements));
}
@Override
E extends DataTreeAwareEffectiveStatement<A, D>> extends DefaultWithDataTree<A, D, E> {
private final @NonNull Object substatements;
- protected WithSubstatements(final ImmutableList<? extends EffectiveStatement<?, ?>> substatements,
- final StatementSourceReference ref) {
- super(substatements, ref);
+ protected WithSubstatements(final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+ super(substatements);
this.substatements = maskList(substatements);
}
private final @NonNull ImmutableMap<QName, SchemaTreeEffectiveStatement<?>> schemaTree;
private final @NonNull ImmutableMap<QName, DataTreeEffectiveStatement<?>> dataTree;
- protected DefaultWithDataTree(final ImmutableList<? extends EffectiveStatement<?, ?>> substatements,
- final StatementSourceReference ref) {
- final Map<QName, SchemaTreeEffectiveStatement<?>> schema = createSchemaTreeNamespace(ref, substatements);
+ protected DefaultWithDataTree(final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+ final Map<QName, SchemaTreeEffectiveStatement<?>> schema = createSchemaTreeNamespace(substatements);
this.schemaTree = ImmutableMap.copyOf(schema);
- this.dataTree = createDataTreeNamespace(ref, schema.values(), schemaTree);
+ this.dataTree = createDataTreeNamespace(schema.values(), schemaTree);
}
@Override
import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
/**
* Specialization of {@link BaseQNameStatementSupport} for {@code input} and {@code output} statements.
@Override
protected final @NonNull E createDeclaredEffective(final Current<QName, D> stmt,
final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
- return createDeclaredEffective(historyAndStatusFlags(stmt.history(), substatements), stmt, substatements);
+ try {
+ return createDeclaredEffective(historyAndStatusFlags(stmt.history(), substatements), stmt, substatements);
+ } catch (SubstatementIndexingException e) {
+ throw new SourceException(e.getMessage(), stmt.sourceReference(), e);
+ }
}
protected abstract @NonNull E createDeclaredEffective(int flags, @NonNull Current<QName, D> stmt,
--- /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.rfc7950.stmt;
+
+import static java.util.Objects.requireNonNull;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * Exception thrown when indexing of substatements of a {@link AbstractDeclaredEffectiveStatement} fails.
+ */
+@Beta
+public final class SubstatementIndexingException extends IllegalArgumentException {
+ private static final long serialVersionUID = 1L;
+
+ public SubstatementIndexingException(final String message) {
+ super(requireNonNull(message));
+ }
+}
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractDeclaredEffectiveStatement.DefaultWithDataTree.WithSubstatements;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.CopyableMixin;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.OperationDefinitionMixin;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
final class ActionEffectiveStatementImpl extends WithSubstatements<QName, ActionStatement, ActionEffectiveStatement>
implements ActionDefinition, ActionEffectiveStatement, OperationDefinitionMixin<ActionStatement>,
private final int flags;
ActionEffectiveStatementImpl(final ActionStatement declared, final SchemaPath path, final int flags,
- final ImmutableList<? extends EffectiveStatement<?, ?>> substatements, final StatementSourceReference ref) {
- super(declared, substatements, ref);
+ final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+ super(declared, substatements);
this.path = requireNonNull(path);
this.flags = flags;
}
import org.opendaylight.yangtools.yang.model.api.stmt.InputStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.OutputStatement;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseSchemaTreeStatementSupport;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.SubstatementIndexingException;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.input.InputStatementRFC7950Support;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.output.OutputStatementRFC7950Support;
import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
SourceException.throwIf(StmtContextUtils.hasParentOfType(stmt, YangStmtMapping.MODULE), ref,
"Action %s is defined at the top level of a module", argument);
- return new ActionEffectiveStatementImpl(stmt.declared(), stmt.getSchemaPath(),
- historyAndStatusFlags(stmt.history(), substatements), substatements, stmt.sourceReference());
+ try {
+ return new ActionEffectiveStatementImpl(stmt.declared(), stmt.getSchemaPath(),
+ historyAndStatusFlags(stmt.history(), substatements), substatements);
+ } catch (SubstatementIndexingException e) {
+ throw new SourceException(e.getMessage(), stmt.sourceReference(), e);
+ }
}
}
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.ArgumentUtils;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStatementSupport;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.EffectiveStatementWithFlags.FlagsBuilder;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.SubstatementIndexingException;
import org.opendaylight.yangtools.yang.parser.spi.SchemaTreeNamespace;
import org.opendaylight.yangtools.yang.parser.spi.meta.CopyType;
import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
.setStatus(findFirstArgument(substatements, StatusEffectiveStatement.class, Status.CURRENT))
.toFlags();
- return new AugmentEffectiveStatementImpl(stmt.declared(), stmt.getArgument(), flags,
- StmtContextUtils.getRootModuleQName(stmt.caerbannog()), substatements, stmt.sourceReference(),
- (AugmentationSchemaNode) stmt.original());
+ try {
+ return new AugmentEffectiveStatementImpl(stmt.declared(), stmt.getArgument(), flags,
+ StmtContextUtils.getRootModuleQName(stmt.caerbannog()), substatements,
+ (AugmentationSchemaNode) stmt.original());
+ } catch (SubstatementIndexingException e) {
+ throw new SourceException(e.getMessage(), stmt.sourceReference(), e);
+ }
}
private static StmtContext<?, ?, ?> getSearchRoot(final StmtContext<?, ?, ?> augmentContext) {
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.DocumentedNodeMixin;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.NotificationNodeContainerMixin;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.WhenConditionMixin;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
final class AugmentEffectiveStatementImpl extends DefaultDataNodeContainer<SchemaNodeIdentifier, AugmentStatement>
implements AugmentEffectiveStatement, AugmentationSchemaNode, QNameModuleAware,
AugmentEffectiveStatementImpl(final AugmentStatement declared, final SchemaNodeIdentifier argument, final int flags,
final QNameModule rootModuleQName, final ImmutableList<? extends EffectiveStatement<?, ?>> substatements,
- final StatementSourceReference ref, final @Nullable AugmentationSchemaNode original) {
- super(declared, ref, substatements);
+ final @Nullable AugmentationSchemaNode original) {
+ super(declared, substatements);
this.argument = requireNonNull(argument);
this.rootModuleQName = requireNonNull(rootModuleQName);
this.flags = flags;
import org.opendaylight.yangtools.yang.model.api.stmt.StatusEffectiveStatement;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseImplicitStatementSupport;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.EffectiveStatementWithFlags.FlagsBuilder;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.SubstatementIndexingException;
import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
abstract class AbstractCaseStatementSupport
extends BaseImplicitStatementSupport<CaseStatement, CaseEffectiveStatement> {
@Override
protected final CaseEffectiveStatement createDeclaredEffective(final Current<QName, CaseStatement> stmt,
final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
- return new DeclaredCaseEffectiveStatement(stmt.declared(), substatements, stmt.sourceReference(),
- computeFlags(stmt, substatements), stmt.getSchemaPath(), findOriginal(stmt));
+ try {
+ return new DeclaredCaseEffectiveStatement(stmt.declared(), substatements, computeFlags(stmt, substatements),
+ stmt.getSchemaPath(), findOriginal(stmt));
+ } catch (SubstatementIndexingException e) {
+ throw new SourceException(e.getMessage(), stmt.sourceReference(), e);
+ }
}
@Override
protected final CaseEffectiveStatement createUndeclaredEffective(final Current<QName, CaseStatement> stmt,
final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
- return new UndeclaredCaseEffectiveStatement(substatements, stmt.sourceReference(),
- computeFlags(stmt, substatements), stmt.getSchemaPath(), findOriginal(stmt));
+ try {
+ return new UndeclaredCaseEffectiveStatement(substatements, computeFlags(stmt, substatements),
+ stmt.getSchemaPath(), findOriginal(stmt));
+ } catch (SubstatementIndexingException e) {
+ throw new SourceException(e.getMessage(), stmt.sourceReference(), e);
+ }
}
private static @Nullable CaseSchemaNode findOriginal(final Current<?, ?> stmt) {
import org.opendaylight.yangtools.yang.model.api.stmt.CaseEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.CaseStatement;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractDeclaredEffectiveStatement.DefaultWithSchemaTree.WithSubstatements;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
final class DeclaredCaseEffectiveStatement extends WithSubstatements<QName, CaseStatement, CaseEffectiveStatement>
implements CaseEffectiveStatementMixin {
private final int flags;
DeclaredCaseEffectiveStatement(final CaseStatement declared,
- final ImmutableList<? extends EffectiveStatement<?, ?>> substatements, final StatementSourceReference ref,
- final int flags, final SchemaPath path, final @Nullable CaseSchemaNode original) {
- super(declared, substatements, ref);
+ final ImmutableList<? extends EffectiveStatement<?, ?>> substatements, final int flags,
+ final SchemaPath path, final @Nullable CaseSchemaNode original) {
+ super(declared, substatements);
this.flags = flags;
this.path = requireNonNull(path);
this.original = original;
import org.opendaylight.yangtools.yang.model.api.stmt.CaseEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.CaseStatement;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractUndeclaredEffectiveStatement.DefaultWithSchemaTree.WithSubstatements;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
final class UndeclaredCaseEffectiveStatement extends WithSubstatements<QName, CaseStatement, CaseEffectiveStatement>
implements CaseEffectiveStatementMixin {
private final int flags;
UndeclaredCaseEffectiveStatement(final ImmutableList<? extends EffectiveStatement<?, ?>> substatements,
- final StatementSourceReference ref, final int flags, final SchemaPath path,
- final @Nullable CaseSchemaNode original) {
- super(substatements, ref);
+ final int flags, final SchemaPath path, final @Nullable CaseSchemaNode original) {
+ super(substatements);
this.path = requireNonNull(path);
this.flags = flags;
this.original = original;
import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.YangValidationBundles;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseSchemaTreeStatementSupport;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.EffectiveStatementWithFlags.FlagsBuilder;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.SubstatementIndexingException;
import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
import org.opendaylight.yangtools.yang.parser.spi.meta.ImplicitParentAwareStatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
.setConfiguration(stmt.effectiveConfig())
.setMandatory(findFirstArgument(substatements, MandatoryEffectiveStatement.class, Boolean.FALSE))
.toFlags();
-
- return new ChoiceEffectiveStatementImpl(stmt.declared(), substatements, stmt.sourceReference(), flags,
- stmt.getSchemaPath(), defaultCase, (ChoiceSchemaNode) stmt.original());
+ try {
+ return new ChoiceEffectiveStatementImpl(stmt.declared(), substatements, flags, stmt.getSchemaPath(),
+ defaultCase, (ChoiceSchemaNode) stmt.original());
+ } catch (SubstatementIndexingException e) {
+ throw new SourceException(e.getMessage(), stmt.sourceReference(), e);
+ }
}
abstract StatementSupport<?, ?, ?> implictCase();
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.AugmentationTargetMixin;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.DataSchemaNodeMixin;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.MandatoryMixin;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
final class ChoiceEffectiveStatementImpl extends WithSubstatements<QName, ChoiceStatement, ChoiceEffectiveStatement>
implements ChoiceEffectiveStatement, ChoiceSchemaNode, DerivableSchemaNode,
private final int flags;
ChoiceEffectiveStatementImpl(final ChoiceStatement declared,
- final ImmutableList<? extends EffectiveStatement<?, ?>> substatements, final StatementSourceReference ref,
- final int flags, final SchemaPath path, final @Nullable CaseSchemaNode defaultCase,
+ final ImmutableList<? extends EffectiveStatement<?, ?>> substatements, final int flags,
+ final SchemaPath path, final @Nullable CaseSchemaNode defaultCase,
final @Nullable ChoiceSchemaNode original) {
- super(declared, substatements, ref);
+ super(declared, substatements);
this.path = requireNonNull(path);
this.flags = flags;
this.defaultCase = defaultCase;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseSchemaTreeStatementSupport;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.EffectiveStatementWithFlags.FlagsBuilder;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStmtUtils;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.SubstatementIndexingException;
import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
abstract class AbstractContainerStatementSupport
extends BaseSchemaTreeStatementSupport<ContainerStatement, ContainerEffectiveStatement> {
EffectiveStmtUtils.checkUniqueTypedefs(stmt, substatements);
EffectiveStmtUtils.checkUniqueUses(stmt, substatements);
- return new ContainerEffectiveStatementImpl(stmt.declared(), substatements, stmt.sourceReference(), flags, path,
- original);
+ try {
+ return new ContainerEffectiveStatementImpl(stmt.declared(), substatements, flags, path, original);
+ } catch (SubstatementIndexingException e) {
+ throw new SourceException(e.getMessage(), stmt.sourceReference(), e);
+ }
}
}
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.MustConstraintMixin;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.NotificationNodeContainerMixin;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.PresenceMixin;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
final class ContainerEffectiveStatementImpl
extends WithSubstatements<QName, ContainerStatement, ContainerEffectiveStatement>
private final @Nullable ContainerSchemaNode original;
ContainerEffectiveStatementImpl(final ContainerStatement declared,
- final ImmutableList<? extends EffectiveStatement<?, ?>> substatements, final StatementSourceReference ref,
- final int flags, final SchemaPath path, final ContainerSchemaNode original) {
- super(declared, substatements, ref);
+ final ImmutableList<? extends EffectiveStatement<?, ?>> substatements, final int flags,
+ final SchemaPath path, final ContainerSchemaNode original) {
+ super(declared, substatements);
this.path = requireNonNull(path);
this.original = original;
this.flags = flags;
import org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.GroupingStatement;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseQNameStatementSupport;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.SubstatementIndexingException;
import org.opendaylight.yangtools.yang.parser.spi.GroupingNamespace;
import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
@Override
protected GroupingEffectiveStatement createEffective(final Current<QName, GroupingStatement> stmt,
final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
- return new GroupingEffectiveStatementImpl(stmt.declared(), substatements, stmt.sourceReference(),
- historyAndStatusFlags(stmt.history(), substatements), stmt.getSchemaPath());
+ try {
+ return new GroupingEffectiveStatementImpl(stmt.declared(), substatements,
+ historyAndStatusFlags(stmt.history(), substatements), stmt.getSchemaPath());
+ } catch (SubstatementIndexingException e) {
+ throw new SourceException(e.getMessage(), stmt.sourceReference(), e);
+ }
}
private static void checkDeclaredConflict(final StmtContext<QName, ?, ?> ctx) {
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.DataNodeContainerMixin;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.NotificationNodeContainerMixin;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.SchemaNodeMixin;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
final class GroupingEffectiveStatementImpl
extends WithSubstatements<QName, GroupingStatement, GroupingEffectiveStatement>
private final int flags;
GroupingEffectiveStatementImpl(final GroupingStatement declared,
- final ImmutableList<? extends EffectiveStatement<?, ?>> substatements, final StatementSourceReference ref,
- final int flags, final SchemaPath path) {
- super(declared, substatements, ref);
+ final ImmutableList<? extends EffectiveStatement<?, ?>> substatements, final int flags,
+ final SchemaPath path) {
+ super(declared, substatements);
this.path = requireNonNull(path);
this.flags = flags;
}
import org.opendaylight.yangtools.yang.model.api.stmt.InputEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.InputStatement;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseOperationContainerStatementSupport;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.SubstatementIndexingException;
import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
abstract class AbstractInputStatementSupport
extends BaseOperationContainerStatementSupport<InputStatement, InputEffectiveStatement> {
protected final InputEffectiveStatement createDeclaredEffective(final int flags,
final Current<QName, InputStatement> stmt,
final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
- return new DeclaredInputEffectiveStatement(flags, stmt.declared(), substatements, stmt.sourceReference(),
- stmt.getSchemaPath());
+ return new DeclaredInputEffectiveStatement(flags, stmt.declared(), substatements, stmt.getSchemaPath());
}
@Override
protected final InputEffectiveStatement createUndeclaredEffective(final int flags,
final Current<QName, InputStatement> stmt,
final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
- return new UndeclaredInputEffectiveStatement(flags, substatements, stmt.sourceReference(),
- stmt.getSchemaPath());
+ try {
+ return new UndeclaredInputEffectiveStatement(flags, substatements, stmt.getSchemaPath());
+ } catch (SubstatementIndexingException e) {
+ throw new SourceException(e.getMessage(), stmt.sourceReference(), e);
+ }
}
}
import org.opendaylight.yangtools.yang.model.api.stmt.InputStatement;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractDeclaredEffectiveStatement.DefaultWithDataTree.WithSubstatements;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.OperationContainerMixin;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
final class DeclaredInputEffectiveStatement extends WithSubstatements<QName, InputStatement, InputEffectiveStatement>
implements InputEffectiveStatement, InputSchemaNode, OperationContainerMixin<InputStatement> {
private final int flags;
DeclaredInputEffectiveStatement(final int flags, final InputStatement declared,
- final ImmutableList<? extends EffectiveStatement<?, ?>> substatements, final StatementSourceReference ref,
- final SchemaPath path) {
- super(declared, substatements, ref);
+ final ImmutableList<? extends EffectiveStatement<?, ?>> substatements, final SchemaPath path) {
+ super(declared, substatements);
this.flags = flags;
this.path = requireNonNull(path);
}
import org.opendaylight.yangtools.yang.model.api.stmt.InputStatement;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractUndeclaredEffectiveStatement.DefaultWithDataTree.WithSubstatements;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.OperationContainerMixin;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
final class UndeclaredInputEffectiveStatement
extends WithSubstatements<QName, InputStatement, InputEffectiveStatement>
private final int flags;
UndeclaredInputEffectiveStatement(final int flags,
- final ImmutableList<? extends EffectiveStatement<?, ?>> substatements,
- final StatementSourceReference ref, final SchemaPath path) {
- super(substatements, ref);
+ final ImmutableList<? extends EffectiveStatement<?, ?>> substatements, final SchemaPath path) {
+ super(substatements);
this.path = requireNonNull(path);
this.flags = flags;
}
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.NotificationNodeContainerMixin;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.UserOrderedMixin;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.WhenConditionMixin;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStmtUtils;
-import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
abstract class AbstractListEffectiveStatement
extends DefaultWithDataTree<QName, ListStatement, ListEffectiveStatement>
private final @NonNull SchemaPath path;
private final @NonNull Object keyDefinition;
- AbstractListEffectiveStatement(final Current<QName, ListStatement> stmt, final SchemaPath path,
- final int flags, final ImmutableList<? extends EffectiveStatement<?, ?>> substatements,
+ AbstractListEffectiveStatement(final ListStatement declared, final SchemaPath path, final int flags,
+ final ImmutableList<? extends EffectiveStatement<?, ?>> substatements,
final ImmutableList<QName> keyDefinition) {
- super(stmt.declared(), substatements, stmt.sourceReference());
-
- EffectiveStmtUtils.checkUniqueGroupings(stmt, substatements);
- EffectiveStmtUtils.checkUniqueTypedefs(stmt, substatements);
- EffectiveStmtUtils.checkUniqueUses(stmt, substatements);
+ super(declared, substatements);
this.substatements = maskList(substatements);
this.path = requireNonNull(path);
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseSchemaTreeStatementSupport;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.EffectiveStatementWithFlags.FlagsBuilder;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStmtUtils;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.SubstatementIndexingException;
import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx;
import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Parent;
import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
final Optional<ElementCountConstraint> elementCountConstraint =
EffectiveStmtUtils.createElementCountConstraint(substatements);
- return original == null && !elementCountConstraint.isPresent()
- ? new EmptyListEffectiveStatement(stmt, path, flags, substatements, keyDefinition)
- : new RegularListEffectiveStatement(stmt, path, flags, substatements, keyDefinition,
- elementCountConstraint.orElse(null), original);
+
+ EffectiveStmtUtils.checkUniqueGroupings(stmt, substatements);
+ EffectiveStmtUtils.checkUniqueTypedefs(stmt, substatements);
+ EffectiveStmtUtils.checkUniqueUses(stmt, substatements);
+
+ try {
+ return original == null && !elementCountConstraint.isPresent()
+ ? new EmptyListEffectiveStatement(stmt.declared(), path, flags, substatements, keyDefinition)
+ : new RegularListEffectiveStatement(stmt.declared(), path, flags, substatements, keyDefinition,
+ elementCountConstraint.orElse(null), original);
+ } catch (SubstatementIndexingException e) {
+ throw new SourceException(e.getMessage(), stmt.sourceReference(), e);
+ }
}
private static void warnConfigList(final @NonNull Current<QName, ListStatement> stmt) {
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.ListStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
final class EmptyListEffectiveStatement extends AbstractListEffectiveStatement {
- EmptyListEffectiveStatement(final Current<QName, ListStatement> stmt, final SchemaPath path,
- final int flags, final ImmutableList<? extends EffectiveStatement<?, ?>> substatements,
+ EmptyListEffectiveStatement(final ListStatement declared, final SchemaPath path, final int flags,
+ final ImmutableList<? extends EffectiveStatement<?, ?>> substatements,
final ImmutableList<QName> keyDefinition) {
- super(stmt, path, flags, substatements, keyDefinition);
+ super(declared, path, flags, substatements, keyDefinition);
}
@Override
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.ListStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
final class RegularListEffectiveStatement extends AbstractListEffectiveStatement {
private final ElementCountConstraint elementCountConstraint;
private final ListSchemaNode original;
- RegularListEffectiveStatement(final Current<QName, ListStatement> stmt, final SchemaPath path,
- final int flags, final ImmutableList<? extends EffectiveStatement<?, ?>> substatements,
+ RegularListEffectiveStatement(final ListStatement declared, final SchemaPath path, final int flags,
+ final ImmutableList<? extends EffectiveStatement<?, ?>> substatements,
final ImmutableList<QName> keyDefinition, final ElementCountConstraint elementCountConstraint,
final ListSchemaNode original) {
- super(stmt, path, flags, substatements, keyDefinition);
+ super(declared, path, flags, substatements, keyDefinition);
this.elementCountConstraint = elementCountConstraint;
this.original = original;
}
import org.opendaylight.yangtools.yang.model.repo.api.SemVerSourceIdentifier;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStatementSupport;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.SubstatementIndexingException;
import org.opendaylight.yangtools.yang.parser.spi.ModuleNamespace;
import org.opendaylight.yangtools.yang.parser.spi.NamespaceToModule;
import org.opendaylight.yangtools.yang.parser.spi.PreLinkageModuleNamespace;
submodules.add((Submodule) submodule);
}
- return new ModuleEffectiveStatementImpl(stmt, substatements, submodules);
+ try {
+ return new ModuleEffectiveStatementImpl(stmt, substatements, submodules);
+ } catch (SubstatementIndexingException e) {
+ throw new SourceException(e.getMessage(), stmt.sourceReference(), e);
+ }
}
private static Collection<StmtContext<?, ?, ?>> submoduleContexts(final Current<?, ?> stmt) {
import org.opendaylight.yangtools.yang.model.api.stmt.NotificationEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.NotificationStatement;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseSchemaTreeStatementSupport;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.SubstatementIndexingException;
import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
abstract class AbstractNotificationStatementSupport
extends BaseSchemaTreeStatementSupport<NotificationStatement, NotificationEffectiveStatement> {
final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
checkEffective(stmt);
- return new NotificationEffectiveStatementImpl(stmt.declared(), substatements, stmt.sourceReference(),
+ try {
+ return new NotificationEffectiveStatementImpl(stmt.declared(), substatements,
historyAndStatusFlags(stmt.history(), substatements), stmt.getSchemaPath());
+ } catch (SubstatementIndexingException e) {
+ throw new SourceException(e.getMessage(), stmt.sourceReference(), e);
+ }
}
abstract void checkEffective(Current<QName, NotificationStatement> stmt);
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.DataNodeContainerMixin;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.MustConstraintMixin;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.SchemaNodeMixin;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
final class NotificationEffectiveStatementImpl
extends WithSubstatements<QName, NotificationStatement, NotificationEffectiveStatement>
private final int flags;
NotificationEffectiveStatementImpl(final NotificationStatement declared,
- final ImmutableList<? extends EffectiveStatement<?, ?>> substatements, final StatementSourceReference ref,
- final int flags, final SchemaPath path) {
- super(declared, substatements, ref);
+ final ImmutableList<? extends EffectiveStatement<?, ?>> substatements, final int flags,
+ final SchemaPath path) {
+ super(declared, substatements);
this.path = requireNonNull(path);
this.flags = flags;
}
import org.opendaylight.yangtools.yang.model.api.stmt.OutputEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.OutputStatement;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseOperationContainerStatementSupport;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.SubstatementIndexingException;
import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
abstract class AbstractOutputStatementSupport
extends BaseOperationContainerStatementSupport<OutputStatement, OutputEffectiveStatement> {
protected final OutputEffectiveStatement createDeclaredEffective(final int flags,
final Current<QName, OutputStatement> stmt,
final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
- return new DeclaredOutputEffectiveStatement(flags, stmt.declared(), substatements, stmt.sourceReference(),
- stmt.getSchemaPath());
+ return new DeclaredOutputEffectiveStatement(flags, stmt.declared(), substatements, stmt.getSchemaPath());
}
@Override
protected final OutputEffectiveStatement createUndeclaredEffective(final int flags,
final Current<QName, OutputStatement> stmt,
final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
- return new UndeclaredOutputEffectiveStatement(flags, substatements, stmt.sourceReference(),
- stmt.getSchemaPath());
+ try {
+ return new UndeclaredOutputEffectiveStatement(flags, substatements, stmt.getSchemaPath());
+ } catch (SubstatementIndexingException e) {
+ throw new SourceException(e.getMessage(), stmt.sourceReference(), e);
+ }
}
}
import org.opendaylight.yangtools.yang.model.api.stmt.OutputStatement;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractDeclaredEffectiveStatement.DefaultWithDataTree.WithSubstatements;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.OperationContainerMixin;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
final class DeclaredOutputEffectiveStatement extends WithSubstatements<QName, OutputStatement, OutputEffectiveStatement>
implements OutputEffectiveStatement, OutputSchemaNode, OperationContainerMixin<OutputStatement> {
private final int flags;
DeclaredOutputEffectiveStatement(final int flags, final OutputStatement declared,
- final ImmutableList<? extends EffectiveStatement<?, ?>> substatements, final StatementSourceReference ref,
- final SchemaPath path) {
- super(declared, substatements, ref);
+ final ImmutableList<? extends EffectiveStatement<?, ?>> substatements, final SchemaPath path) {
+ super(declared, substatements);
this.flags = flags;
this.path = requireNonNull(path);
}
import org.opendaylight.yangtools.yang.model.api.stmt.OutputStatement;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractUndeclaredEffectiveStatement.DefaultWithDataTree.WithSubstatements;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.OperationContainerMixin;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
final class UndeclaredOutputEffectiveStatement
extends WithSubstatements<QName, OutputStatement, OutputEffectiveStatement>
private final int flags;
UndeclaredOutputEffectiveStatement(final int flags,
- final ImmutableList<? extends EffectiveStatement<?, ?>> substatements,
- final StatementSourceReference ref, final SchemaPath path) {
- super(substatements, ref);
+ final ImmutableList<? extends EffectiveStatement<?, ?>> substatements, final SchemaPath path) {
+ super(substatements);
this.path = requireNonNull(path);
this.flags = flags;
}
import org.opendaylight.yangtools.yang.model.api.stmt.StatusEffectiveStatement;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseSchemaTreeStatementSupport;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.EffectiveStatementWithFlags.FlagsBuilder;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.SubstatementIndexingException;
import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupport;
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.StmtContextUtils;
import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase;
abstract class AbstractRpcStatementSupport extends BaseSchemaTreeStatementSupport<RpcStatement, RpcEffectiveStatement> {
final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
checkState(!substatements.isEmpty(), "Missing implicit input/output statements at %s", stmt.sourceReference());
- return new RpcEffectiveStatementImpl(stmt.declared(), substatements, stmt.sourceReference(),
- computeFlags(substatements), stmt.getSchemaPath());
+ try {
+ return new RpcEffectiveStatementImpl(stmt.declared(), substatements, computeFlags(substatements),
+ stmt.getSchemaPath());
+ } catch (SubstatementIndexingException e) {
+ throw new SourceException(e.getMessage(), stmt.sourceReference(), e);
+ }
}
abstract StatementSupport<?, ?, ?> implictInput();
import org.opendaylight.yangtools.yang.model.api.stmt.RpcStatement;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractDeclaredEffectiveStatement.DefaultWithDataTree.WithSubstatements;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.OperationDefinitionMixin;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
final class RpcEffectiveStatementImpl extends WithSubstatements<QName, RpcStatement, RpcEffectiveStatement>
implements RpcDefinition, RpcEffectiveStatement, OperationDefinitionMixin<RpcStatement> {
private final int flags;
RpcEffectiveStatementImpl(final RpcStatement declared,
- final ImmutableList<? extends EffectiveStatement<?, ?>> substatements, final StatementSourceReference ref,
- final int flags, final SchemaPath path) {
- super(declared, substatements, ref);
+ final ImmutableList<? extends EffectiveStatement<?, ?>> substatements, final int flags, final SchemaPath path) {
+ super(declared, substatements);
this.path = requireNonNull(path);
this.flags = flags;
}
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStatementSupport;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.SubstatementIndexingException;
import org.opendaylight.yangtools.yang.parser.spi.SubmoduleNamespace;
import org.opendaylight.yangtools.yang.parser.spi.meta.CommonStmtCtx;
import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
if (substatements.isEmpty()) {
throw noBelongsTo(stmt);
}
- return new SubmoduleEffectiveStatementImpl(stmt, substatements);
+ try {
+ return new SubmoduleEffectiveStatementImpl(stmt, substatements);
+ } catch (SubstatementIndexingException e) {
+ throw new SourceException(e.getMessage(), stmt.sourceReference(), e);
+ }
}
private static SourceException noBelongsTo(final CommonStmtCtx stmt) {
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.SubstatementIndexingException;
import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
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;
public class YangParserNegativeTest {
fail("Duplicate leaf not detected");
} catch (SomeModifiersUnresolvedException e) {
final Throwable rootCause = Throwables.getRootCause(e);
- assertThat(rootCause, isA(SourceException.class));
+ assertThat(rootCause, isA(SubstatementIndexingException.class));
assertThat(rootCause.getMessage(), containsString("Cannot add schema tree child with name "
+ "(urn:simple.augment2.demo?revision=2014-06-02)delta, a conflicting child already exists"));