BUG-994: use SchemaPath.getPathTowardRoot() 80/8380/5
authorRobert Varga <rovarga@cisco.com>
Thu, 26 Jun 2014 17:43:13 +0000 (19:43 +0200)
committerRobert Varga <rovarga@cisco.com>
Tue, 1 Jul 2014 12:36:15 +0000 (14:36 +0200)
Instead of dereferencing the old API, use the new API, which gives the
same information more conveniently.

Change-Id: I485bae608bfb4aa1f6dae9838458a58ff4b23793
Signed-off-by: Robert Varga <rovarga@cisco.com>
code-generator/maven-sal-api-gen-plugin/src/main/java/org/opendaylight/yangtools/yang/unified/doc/generator/GeneratorImpl.xtend
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/SchemaContextUtil.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/ParserListenerUtils.java

index 3225300ebb8f15ed87e9e5f442fade10abcaa0ae..01f94dff04685700333ab605828ba2f746977c22 100644 (file)
@@ -766,7 +766,7 @@ class GeneratorImpl {
 
     def CharSequence printUses(UsesNode usesNode) {
         return '''
-            «strong(listItem("uses", typeAnchorLink(usesNode.groupingPath, usesNode.groupingPath.path.last.localName)))»
+            «strong(listItem("uses", typeAnchorLink(usesNode.groupingPath, usesNode.groupingPath.pathTowardsRoot.iterator.next.localName)))»
             <ul>
             <li>refines:
                 <ul>
index fc98c1daf0aef88d6e202743d0db8e3fcb56576d..6305dd7c88b42d3708830a1760169c3c04cd0ae9 100644 (file)
@@ -81,7 +81,7 @@ public final class SchemaContextUtil {
         Preconditions.checkArgument(context != null, "Schema Context reference cannot be NULL");
         Preconditions.checkArgument(schemaPath != null, "Schema Path reference cannot be NULL");
 
-        final List<QName> prefixedPath = (schemaPath.getPath());
+        final Iterable<QName> prefixedPath = schemaPath.getPathFromRoot();
         if (prefixedPath == null) {
             LOG.debug("Schema path {} has null path", schemaPath);
             return null;
@@ -518,7 +518,7 @@ public final class SchemaContextUtil {
     }
 
     private static DataSchemaNode findCorrectTargetFromGrouping(final DataSchemaNode node, final SchemaContext ctx) {
-        if (node.getPath().getPath().size() != 1) {
+        if (Iterables.size(node.getPath().getPathTowardsRoot()) != 1) {
             QName currentName = node.getQName();
             // tmpPath is used to track level of nesting
             List<QName> tmpPath = new ArrayList<>();
index 69ca39668c312798e05ae1270958d820efbff963..49f4178731f59221fa5660efd59a1816ba210efc 100644 (file)
@@ -400,7 +400,7 @@ public final class ParserListenerUtils {
         }
 
         EnumPairImpl result = new EnumPairImpl();
-        result.qname = path.getPath().get(path.getPath().size() - 1);
+        result.qname = path.getPathTowardsRoot().iterator().next();
         result.path = path;
         result.description = description;
         result.reference = reference;
@@ -913,7 +913,7 @@ public final class ParserListenerUtils {
         }
 
         final List<UnknownSchemaNode> unknownNodes = Collections.emptyList();
-        return new BitImpl(position, schemaPath.getPath().get(schemaPath.getPath().size() - 1), schemaPath,
+        return new BitImpl(position, schemaPath.getPathTowardsRoot().iterator().next(), schemaPath,
                 description, reference, status, unknownNodes);
     }