Bug 3670 (part 1/5): Use of new statement parser in yang-maven-plugin
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / rfc6020 / effective / EffectiveSchemaContext.java
index ff89f81d14b05ea6d86a49df5f2ff5fc9cbd66fb..2f885e788bd620d8d5c23d955541a39edfcb58fc 100644 (file)
@@ -7,6 +7,8 @@
  */
 package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
 
+import org.opendaylight.yangtools.yang.parser.util.ModuleDependencySort;
+
 import java.util.HashSet;
 import com.google.common.collect.ImmutableList;
 import java.util.List;
@@ -49,7 +51,10 @@ public class EffectiveSchemaContext extends AbstractEffectiveSchemaContext {
                 modulesInit.add(module);
             }
         }
-        this.modules = ImmutableSet.copyOf(modulesInit);
+
+        Module[] moduleArray = new Module[modulesInit.size()];
+        List<Module> sortedModuleList = ModuleDependencySort.sort(modulesInit.toArray(moduleArray));
+        this.modules = ImmutableSet.copyOf(sortedModuleList);
 
         final SetMultimap<URI, Module> nsMap = Multimaps.newSetMultimap(
                 new TreeMap<URI, Collection<Module>>(), MODULE_SET_SUPPLIER);