Fix references to Any{Data,Xml}SchemaNode
[mdsal.git] / binding / maven-sal-api-gen-plugin / src / main / java / org / opendaylight / mdsal / binding / yang / unified / doc / generator / GeneratorImpl.xtend
index 45fb65da6dc74c046263cd95ca2dee5ac04f6acf..5ba6138f1c818120c21872142d97882a0488b9c7 100644 (file)
@@ -23,10 +23,11 @@ import java.util.List
 import java.util.Map
 import java.util.Optional
 import java.util.Set
+import org.gaul.modernizer_maven_annotations.SuppressModernizer
 import org.opendaylight.yangtools.yang.common.QName
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates
-import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode
+import org.opendaylight.yangtools.yang.model.api.AnyxmlSchemaNode
 import org.opendaylight.yangtools.yang.model.api.AugmentationTarget
 import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode
 import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode
@@ -62,37 +63,38 @@ import org.opendaylight.yangtools.yang.model.api.type.Uint64TypeDefinition
 import org.slf4j.Logger
 import org.slf4j.LoggerFactory
 import org.sonatype.plexus.build.incremental.BuildContext
-import org.sonatype.plexus.build.incremental.DefaultBuildContext
 
+@SuppressModernizer
 class GeneratorImpl {
 
-    File path
     static val Logger LOG = LoggerFactory.getLogger(GeneratorImpl)
-    static val BuildContext CTX = new DefaultBuildContext();
-    var Module currentModule;
+
     val Map<String, String> imports = new HashMap();
+    var Module currentModule;
     var SchemaContext ctx;
+    var File path
 
     StringBuilder augmentChildNodesAsString
 
     DataSchemaNode lastNodeInTargetPath = null
 
-    def generate(SchemaContext context, File targetPath, Set<Module> modulesToGen) throws IOException {
+    def generate(BuildContext buildContext, SchemaContext context, File targetPath, Set<Module> modulesToGen)
+            throws IOException {
         path = targetPath;
         path.mkdirs();
         val it = new HashSet;
         for (module : modulesToGen) {
-            add(generateDocumentation(module, context));
+            add(generateDocumentation(buildContext, module, context));
         }
         return it;
     }
 
-    def generateDocumentation(Module module, SchemaContext ctx) {
+    def generateDocumentation(BuildContext buildContext, Module module, SchemaContext ctx) {
         val destination = new File(path, '''«module.name».html''')
         this.ctx = ctx;
         module.imports.forEach[importModule | this.imports.put(importModule.prefix, importModule.moduleName)]
         try {
-            val fw = new OutputStreamWriter(CTX.newFileOutputStream(destination), StandardCharsets.UTF_8)
+            val fw = new OutputStreamWriter(buildContext.newFileOutputStream(destination), StandardCharsets.UTF_8)
             val bw = new BufferedWriter(fw)
             currentModule = module;
             bw.append(generate(module, ctx));
@@ -362,7 +364,7 @@ class GeneratorImpl {
                 }
             }
         }
-        if(! nodes.empty) {
+        if (!nodes.empty) {
             lastNodeInTargetPath = nodes.get(nodes.size() - 1)
         }
 
@@ -414,7 +416,7 @@ class GeneratorImpl {
         «IF child instanceof ContainerSchemaNode»
             «printContainerNode(child)»
         «ENDIF»
-        «IF child instanceof AnyXmlSchemaNode»
+        «IF child instanceof AnyxmlSchemaNode»
             «printAnyXmlNode(child)»
         «ENDIF»
         «IF child instanceof LeafSchemaNode»
@@ -472,7 +474,7 @@ class GeneratorImpl {
         '''
     }
 
-    private def printAnyXmlNode(AnyXmlSchemaNode anyXmlNode) {
+    private def printAnyXmlNode(AnyxmlSchemaNode anyXmlNode) {
         return
         '''
             &lt;«anyXmlNode.QName.localName»&gt;. . .&lt;/«anyXmlNode.QName.localName»&gt;
@@ -892,7 +894,7 @@ class GeneratorImpl {
                 «printInfo(node, "container")»
                 </ul>
             '''
-        } else if(node instanceof AnyXmlSchemaNode) {
+        } else if(node instanceof AnyxmlSchemaNode) {
             return '''
                 «printInfo(node, "anyxml")»
                 </ul>
@@ -956,7 +958,7 @@ class GeneratorImpl {
     }
 
     def CharSequence printChildren(Iterable<DataSchemaNode> nodes, int level, YangInstanceIdentifier path) {
-        val anyxmlNodes = nodes.filter(AnyXmlSchemaNode)
+        val anyxmlNodes = nodes.filter(AnyxmlSchemaNode)
         val leafNodes = nodes.filter(LeafSchemaNode)
         val leafListNodes = nodes.filter(LeafListSchemaNode)
         val choices = nodes.filter(ChoiceSchemaNode)
@@ -1123,7 +1125,7 @@ class GeneratorImpl {
         '''
     }
 
-    def CharSequence printShortInfo(AnyXmlSchemaNode node, int level, YangInstanceIdentifier path) {
+    def CharSequence printShortInfo(AnyxmlSchemaNode node, int level, YangInstanceIdentifier path) {
         return '''
             <li>«strong((node.QName.localName))» (anyxml)
             <ul>
@@ -1178,7 +1180,7 @@ class GeneratorImpl {
             }
         }
 
-        return identifier.node(new NodeIdentifierWithPredicates(node.QName, keyValues));
+        return identifier.node(NodeIdentifierWithPredicates.of(node.QName, keyValues));
     }
 
 
@@ -1196,7 +1198,7 @@ class GeneratorImpl {
             append(arg.nodeType.localName);
             previous = true;
             if(arg instanceof NodeIdentifierWithPredicates) {
-                for(qname : arg.getKeyValues.keySet) {
+                for(qname : arg.keySet) {
                     append("/{");
                     append(qname.localName)
                     append('}')