import com.google.common.annotations.Beta;
import com.google.common.collect.ImmutableList;
import java.util.Collection;
-import java.util.Optional;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.common.Revision;
+import org.opendaylight.yangtools.yang.common.UnresolvedQName.Unqualified;
import org.opendaylight.yangtools.yang.common.YangVersion;
import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
import org.opendaylight.yangtools.yang.model.api.meta.DeclarationReference;
import org.opendaylight.yangtools.yang.model.api.stmt.IncludeEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.IncludeStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.RevisionDateStatement;
-import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
+import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
import org.opendaylight.yangtools.yang.model.ri.stmt.DeclaredStatementDecorators;
import org.opendaylight.yangtools.yang.model.ri.stmt.DeclaredStatements;
import org.opendaylight.yangtools.yang.model.ri.stmt.EffectiveStatements;
import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
import org.opendaylight.yangtools.yang.parser.spi.SubmoduleNamespace;
-import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStringStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractUnqualifiedStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.BoundStmtCtx;
import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
import org.opendaylight.yangtools.yang.parser.spi.meta.ModelActionBuilder;
@Beta
public final class IncludeStatementSupport
- extends AbstractStringStatementSupport<IncludeStatement, IncludeEffectiveStatement> {
+ extends AbstractUnqualifiedStatementSupport<IncludeStatement, IncludeEffectiveStatement> {
private static final SubstatementValidator RFC6020_VALIDATOR =
SubstatementValidator.builder(YangStmtMapping.INCLUDE)
.addOptional(YangStmtMapping.REVISION_DATE)
}
@Override
- public void onPreLinkageDeclared(final Mutable<String, IncludeStatement, IncludeEffectiveStatement> stmt) {
- final StmtContext<Revision, ?, ?> revision = findFirstDeclaredSubstatement(stmt,
- RevisionDateStatement.class);
- stmt.addRequiredSource(revision == null ? RevisionSourceIdentifier.create(stmt.argument())
- : RevisionSourceIdentifier.create(stmt.argument(), revision.argument()));
+ public void onPreLinkageDeclared(final Mutable<Unqualified, IncludeStatement, IncludeEffectiveStatement> stmt) {
+ final var revision = findFirstDeclaredSubstatement(stmt, RevisionDateStatement.class);
+ stmt.addRequiredSource(
+ new SourceIdentifier(stmt.getArgument(), revision != null ? revision.getArgument() : null));
}
@Override
- public void onLinkageDeclared(final Mutable<String, IncludeStatement, IncludeEffectiveStatement> stmt) {
- final String submoduleName = stmt.getArgument();
+ public void onLinkageDeclared(final Mutable<Unqualified, IncludeStatement, IncludeEffectiveStatement> stmt) {
+ final Unqualified submoduleName = stmt.getArgument();
final StmtContext<Revision, ?, ?> revision = findFirstDeclaredSubstatement(stmt, RevisionDateStatement.class);
final ModelActionBuilder includeAction = stmt.newInferenceAction(SOURCE_LINKAGE);
NamespaceKeyCriterion.latestRevisionModule(submoduleName), SOURCE_LINKAGE);
} else {
requiresCtxPrerequisite = includeAction.requiresCtx(stmt, SubmoduleNamespace.class,
- RevisionSourceIdentifier.create(submoduleName, Optional.of(revision.argument())), SOURCE_LINKAGE);
+ new SourceIdentifier(submoduleName, revision.argument()), SOURCE_LINKAGE);
}
includeAction.apply(new InferenceAction() {
"Cannot include a version %s submodule in a version %s module", subVersion, modVersion);
}
- stmt.addToNs(IncludedModuleContext.class, revision != null
- ? RevisionSourceIdentifier.create(submoduleName, revision.argument())
- : RevisionSourceIdentifier.create(submoduleName), includedSubModuleContext);
+ stmt.addToNs(IncludedModuleContext.class,
+ new SourceIdentifier(submoduleName, revision != null ? revision.getArgument() : null),
+ includedSubModuleContext);
stmt.addToNs(IncludedSubmoduleNameToModuleCtx.class, stmt.argument(), includedSubModuleContext);
}
}
@Override
- protected IncludeStatement createDeclared(final StmtContext<String, IncludeStatement, ?> ctx,
- final ImmutableList<? extends DeclaredStatement<?>> substatements) {
- return DeclaredStatements.createInclude(ctx.getRawArgument(), ctx.getArgument(), substatements);
+ protected IncludeStatement createDeclared(final BoundStmtCtx<Unqualified> ctx,
+ final ImmutableList<DeclaredStatement<?>> substatements) {
+ return DeclaredStatements.createInclude(ctx.getArgument(), substatements);
}
@Override
}
@Override
- protected IncludeEffectiveStatement createEffective(final Current<String, IncludeStatement> stmt,
+ protected IncludeEffectiveStatement createEffective(final Current<Unqualified, IncludeStatement> stmt,
final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
return EffectiveStatements.createInclude(stmt.declared(), substatements);
}