StmtContext should not care about semantic versions
[yangtools.git] / yang / yang-parser-reactor / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / reactor / BuildGlobalContext.java
index aca640a1a124d79eef3fd3f683778ebce449c278..cd8604df4061d0530c6a55d7ad1d994d524f4fa2 100644 (file)
@@ -38,7 +38,6 @@ import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
 import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
 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.MutableStatement;
@@ -85,37 +84,20 @@ final class BuildGlobalContext extends NamespaceStorageSupport implements Regist
     private final ImmutableMap<ModelProcessingPhase, StatementSupportBundle> supports;
     private final Set<SourceSpecificContext> sources = new HashSet<>();
     private final ImmutableSet<YangVersion> supportedVersions;
-    private final boolean enabledSemanticVersions;
 
     private Set<SourceSpecificContext> libSources = new HashSet<>();
     private ModelProcessingPhase currentPhase = ModelProcessingPhase.INIT;
     private ModelProcessingPhase finishedPhase = ModelProcessingPhase.INIT;
 
     BuildGlobalContext(final ImmutableMap<ModelProcessingPhase, StatementSupportBundle> supports,
-            final ImmutableMap<ValidationBundleType, Collection<?>> supportedValidation,
-            final StatementParserMode statementParserMode) {
+            final ImmutableMap<ValidationBundleType, Collection<?>> supportedValidation) {
         this.supports = requireNonNull(supports, "BuildGlobalContext#supports cannot be null");
 
-        switch (statementParserMode) {
-            case DEFAULT_MODE:
-                enabledSemanticVersions = false;
-                break;
-            case SEMVER_MODE:
-                enabledSemanticVersions = true;
-                break;
-            default:
-                throw new IllegalArgumentException("Unhandled parser mode " + statementParserMode);
-        }
-
         addToNamespace(ValidationBundlesNamespace.class, supportedValidation);
 
         this.supportedVersions = ImmutableSet.copyOf(supports.get(ModelProcessingPhase.INIT).getSupportedVersions());
     }
 
-    boolean isEnabledSemanticVersioning() {
-        return enabledSemanticVersions;
-    }
-
     StatementSupportBundle getSupportsForPhase(final ModelProcessingPhase phase) {
         return supports.get(phase);
     }
@@ -125,8 +107,6 @@ final class BuildGlobalContext extends NamespaceStorageSupport implements Regist
     }
 
     void addLibSource(final @NonNull StatementStreamSource libSource) {
-        checkState(!isEnabledSemanticVersioning(),
-            "Library sources are not supported in semantic version mode currently.");
         checkState(currentPhase == ModelProcessingPhase.INIT,
                 "Add library source is allowed in ModelProcessingPhase.INIT only");
         libSources.add(new SourceSpecificContext(this, libSource));
@@ -382,7 +362,8 @@ final class BuildGlobalContext extends NamespaceStorageSupport implements Regist
             while (currentSource.hasNext()) {
                 final SourceSpecificContext nextSourceCtx = currentSource.next();
                 try {
-                    final PhaseCompletionProgress sourceProgress = nextSourceCtx.tryToCompletePhase(currentPhase);
+                    final PhaseCompletionProgress sourceProgress =
+                        nextSourceCtx.tryToCompletePhase(currentPhase.executionOrder());
                     switch (sourceProgress) {
                         case FINISHED:
                             currentSource.remove();