import static java.util.Objects.requireNonNull;
import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import java.util.ArrayList;
import java.util.Collection;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
+import org.opendaylight.yangtools.yang.parser.spi.SchemaTreeNamespace;
import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
import org.opendaylight.yangtools.yang.parser.spi.meta.MutableStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.NamespaceStorageNode;
import org.opendaylight.yangtools.yang.parser.spi.meta.RootStmtContext;
import org.opendaylight.yangtools.yang.parser.spi.source.IncludedModuleContext;
import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Root statement class for a YANG source. All statements defined in that YANG source are mapped underneath an instance
*/
public final class RootStatementContext<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>>
extends AbstractResumedStatement<A, D, E> implements RootStmtContext.Mutable<A, D, E> {
-
public static final YangVersion DEFAULT_VERSION = YangVersion.VERSION_1;
+ private static final Logger LOG = LoggerFactory.getLogger(RootStatementContext.class);
+ // These namespaces are well-known and not needed after the root is cleaned up
+ private static final Map<Class<?>, SweptNamespace> SWEPT_NAMESPACES = ImmutableMap.of(
+ // FIXME: somehow these two end up being referenced post-sweep
+ // this probably means we have a cross-module reference we do not account for
+// GroupingNamespace.class, new SweptNamespace(GroupingNamespace.class),
+// TypeNamespace.class, new SweptNamespace(TypeNamespace.class),
+ SchemaTreeNamespace.class, new SweptNamespace(SchemaTreeNamespace.class));
+
private final @NonNull SourceSpecificContext sourceContext;
private final A argument;
StatementContextBase<A, D, E> reparent(final StatementContextBase<?, ?, ?> newParent) {
throw new UnsupportedOperationException("Root statement cannot be reparented to" + newParent);
}
+
+ @Override
+ void sweepNamespaces() {
+ LOG.trace("Sweeping root {}", this);
+ sweepNamespaces(SWEPT_NAMESPACES);
+ }
}