]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/markdown/html/SCLDocumentationExtensionNodeHandler.java
Replace System.err and System.out with SLF4J Logging
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / markdown / html / SCLDocumentationExtensionNodeHandler.java
index bec138283039b19b42582922c70cf9aec23a717f..d9e65e28c39208b575234aae41e3a94000702912 100644 (file)
@@ -23,6 +23,8 @@ import org.simantics.scl.compiler.types.TPred;
 import org.simantics.scl.compiler.types.TVar;
 import org.simantics.scl.compiler.types.Types;
 import org.simantics.scl.compiler.types.util.TypeUnparsingContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import gnu.trove.map.hash.THashMap;
 import gnu.trove.procedure.TObjectProcedure;
@@ -30,6 +32,7 @@ import gnu.trove.set.hash.THashSet;
 
 public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandler {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(SCLDocumentationExtensionNodeHandler.class);
     final ModuleRepository moduleRepository;
     final String documentationName;
     
@@ -56,7 +59,7 @@ public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandle
                 if(name.isEmpty())
                     continue;
                 if(!documentedValues.add(name))
-                    System.err.println("Value '" + name + "' has already been documented in " + documentationName + ".");
+                    LOGGER.warn("Value '" + name + "' has already been documented in " + documentationName + ".");
                 generateValueDocumentation(container, name);
             }
             return container;
@@ -69,7 +72,7 @@ public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandle
                 if(name.isEmpty())
                     continue;
                 if(!documentedClasses.add(name))
-                    System.err.println("Class '" + name + "' has already been documented in " + documentationName + ".");
+                    LOGGER.warn("Class '" + name + "' has already been documented in " + documentationName + ".");
                 generateClassDocumentation(container, name);
             }
             return container;
@@ -82,7 +85,7 @@ public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandle
                 if(name.isEmpty())
                     continue;
                 if(!documentedTypeConstructors.add(name))
-                    System.err.println("Type constructor '" + name + "' has already been documented in " + documentationName + ".");
+                    LOGGER.warn("Type constructor '" + name + "' has already been documented in " + documentationName + ".");
                 generateDataDocumentation(container, name);
             }
             return container;
@@ -122,7 +125,7 @@ public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandle
         if(relatedModule == null) {
             relatedModule = moduleRepository.getModule(documentationName);
             if(!relatedModule.didSucceed())
-                System.err.println("Couldn't load the module " + documentationName);
+                LOGGER.warn("Couldn't load the module " + documentationName);
         }
         if(relatedModule.didSucceed())
             return relatedModule.getResult();
@@ -136,7 +139,7 @@ public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandle
             fm = moduleRepository.getModule(moduleName);
             moduleCache.put(moduleName, fm);
             if(!fm.didSucceed())
-                System.err.println("Couldn't load the module " + moduleName);
+                LOGGER.warn("Couldn't load the module " + moduleName);
         }
         if(fm.didSucceed())
             return fm.getResult();
@@ -165,12 +168,12 @@ public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandle
         if(value == null) {
             StringBuilder error = new StringBuilder();
             error.append("Didn't find the value '" + name + "'.");
-            System.err.println(error);
+            LOGGER.error(error.toString());
             container.addChild(new CodeBlockNode(error));
             return;
         }
         if(value.isPrivate())
-            System.err.println("Documentation " + documentationName + " refers to a private value " + name + ".");
+            LOGGER.warn("Documentation " + documentationName + " refers to a private value " + name + ".");
         
         StringBuilder signature = new StringBuilder();
         signature.append("<div id=\"")
@@ -194,7 +197,7 @@ public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandle
             container.addChild(parser.parseDocument(value.documentation));
         }
         else
-            System.out.println(name);
+            LOGGER.info(name);
         container.addChild(new HtmlNode("</div></div>"));
     }
     
@@ -221,7 +224,7 @@ public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandle
         if(typeClass == null) {
             StringBuilder error = new StringBuilder();
             error.append("Didn't find the type class '" + name + "'.");
-            System.err.println(error);
+            LOGGER.error(error.toString());
             container.addChild(new CodeBlockNode(error));
             return;
         }
@@ -255,11 +258,11 @@ public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandle
             container.addChild(parser.parseDocument(typeClass.documentation));
         }
         else
-            System.out.println(name);
+            LOGGER.info(name);
         
         for(String methodName : typeClass.methodNames) {
             if(!documentedValues.add(methodName))
-                System.err.println("Method '" + methodName + "' has already been documented in " + documentationName + ".");
+                LOGGER.warn("Method '" + methodName + "' has already been documented in " + documentationName + ".");
             generateValueDocumentation(container, module, methodName, new TypeUnparsingContext(tuc));
         }
         container.addChild(new HtmlNode("</div></div>"));
@@ -311,12 +314,12 @@ public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandle
             container.addChild(parser.parseDocument(typeDescriptor.getDocumentation()));
         }
         else
-            System.out.println(name);
+            LOGGER.info(name);
         
         if(typeDescriptor instanceof TypeConstructor) {
             for(Constructor constructor : ((TypeConstructor)typeDescriptor).constructors) {
                 if(!documentedValues.add(constructor.name.name))
-                    System.err.println("Method '" + constructor.name.name + "' has already been documented in " + documentationName + ".");
+                    LOGGER.warn("Method '" + constructor.name.name + "' has already been documented in " + documentationName + ".");
                 generateValueDocumentation(container, module, constructor.name.name, new TypeUnparsingContext(tuc));
             }
         }