]> WPIA git - gigi.git/commitdiff
fix: print error messages for translation extraction to stderr
authorFelix Dörre <felix@dogcraft.de>
Sun, 4 Sep 2016 11:53:10 +0000 (13:53 +0200)
committerFelix Dörre <felix@dogcraft.de>
Tue, 6 Sep 2016 21:14:28 +0000 (23:14 +0200)
Change-Id: I26c6294d93463575ce02a5a0752a37814eb47a0d

util-testing/org/cacert/gigi/localisation/TranslationCollectingVisitor.java
util-testing/org/cacert/gigi/localisation/TranslationCollector.java

index 3f8b858d61c275716659b8079f3661cbb8693577..a7b69418f63429a1dbe26081a93cb7cd6cbd2205 100644 (file)
@@ -105,7 +105,7 @@ public final class TranslationCollectingVisitor extends ASTVisitor {
                     ags = anonymousConstructorCall.peek().arguments;
                 }
                 if (ags == null) {
-                    System.out.println(explicitConstructor);
+                    System.err.println(explicitConstructor);
                     return true;
                 }
                 Expression e = ags[t0.getTgt()];
@@ -119,7 +119,7 @@ public final class TranslationCollectingVisitor extends ASTVisitor {
     @Override
     public boolean visit(org.eclipse.jdt.internal.compiler.ast.MessageSend call, org.eclipse.jdt.internal.compiler.lookup.BlockScope scope) {
         if (call.binding == null) {
-            System.out.println("Unbound:" + call + " in " + call.sourceStart());
+            System.err.println("Unbound:" + call + " in " + call.sourceStart());
             return true;
         }
         // System.out.println("Message");
@@ -129,7 +129,7 @@ public final class TranslationCollectingVisitor extends ASTVisitor {
             if (t0.equals(t)) {
                 Expression[] ags = call.arguments;
                 if (ags == null) {
-                    System.out.println(call);
+                    System.err.println(call);
                     return true;
                 }
                 Expression e = ags[t0.getTgt()];
@@ -168,12 +168,12 @@ public final class TranslationCollectingVisitor extends ASTVisitor {
             }
             if (m2.receiver.resolvedType.isCompatibleWith(scope.getJavaLangEnum())) {
                 testEnum(m2.receiver, m2.binding);
-                System.out.println("ENUM-SRC: !" + m2.receiver);
+                System.err.println("ENUM-SRC: !" + m2.receiver);
             }
         }
         if (e.resolvedType.isCompatibleWith(scope.getJavaLangEnum())) {
             // TODO ?
-            System.out.println("ENUM-Not-Hanled");
+            System.err.println("ENUM-Not-Hanled");
         }
 
         TaintSource b = cm == null ? null : new TaintSource(cm);
@@ -188,35 +188,35 @@ public final class TranslationCollectingVisitor extends ASTVisitor {
             return;
         }
 
-        System.out.println();
+        System.err.println();
 
-        System.out.println(new String(scope.enclosingClassScope().referenceType().compilationResult.fileName));
-        System.out.println("Cannot Handle: " + e + " in " + (call == null ? "constructor" : call.sourceStart) + " => " + caller);
-        System.out.println(e.getClass());
-        System.out.println("To ignore: " + (b == null ? "don't know" : b.toConfLine()));
+        System.err.println(new String(scope.enclosingClassScope().referenceType().compilationResult.fileName));
+        System.err.println("Cannot Handle: " + e + " in " + (call == null ? "constructor" : call.sourceStart) + " => " + caller);
+        System.err.println(e.getClass());
+        System.err.println("To ignore: " + (b == null ? "don't know" : b.toConfLine()));
         hadErrors = true;
     }
 
     private void testEnum(Expression e, MethodBinding binding) {
         if (binding.parameters.length != 0) {
-            System.out.println("ERROR: meth");
+            System.err.println("ERROR: meth");
             return;
         }
-        System.out.println(e.resolvedType.getClass());
+        System.err.println(e.resolvedType.getClass());
         String s2 = new String(e.resolvedType.qualifiedPackageName()) + "." + (new String(e.resolvedType.qualifiedSourceName()).replace('.', '$'));
         try {
             Class<?> c = Class.forName(s2);
             Enum<?>[] e1 = (Enum[]) c.getMethod("values").invoke(null);
             Method m = c.getMethod(new String(binding.selector));
             for (int j = 0; j < e1.length; j++) {
-                System.out.println(m.invoke(e1[j]));
+                System.err.println(m.invoke(e1[j]));
             }
         } catch (ClassNotFoundException e1) {
             e1.printStackTrace();
         } catch (ReflectiveOperationException e1) {
             e1.printStackTrace();
         }
-        System.out.println("ENUM-done: " + e + "!");
+        System.err.println("ENUM-done: " + e + "!");
         return;
     }
 }
index 2592f3a733d1cffbf037ef0513175117c960f292..9b4f2a9fee3ceb21e5d910d486f65d7bbef7bc19 100644 (file)
@@ -93,7 +93,7 @@ public class TranslationCollector {
         scanTemplates();
         scanCode(taint);
 
-        System.out.println("Total Translatable Strings: " + translations.size());
+        System.err.println("Total Translatable Strings: " + translations.size());
         TreeSet<TranslationEntry> trs = new TreeSet<>(translations.values());
         writePOFile(out, trs);
     }
@@ -111,7 +111,7 @@ public class TranslationCollector {
     }
 
     private void scanCode(LinkedList<TaintSource> taint) throws Error {
-        PrintWriter out = new PrintWriter(System.out);
+        PrintWriter out = new PrintWriter(System.err);
         Main m = new Main(out, out, false, null, null);
         File[] fs = recurse(new File(new File(new File(base, "src"), "org"), "cacert"), new LinkedList<File>(), ".java").toArray(new File[0]);
         String[] t = new String[fs.length + 3];
@@ -179,12 +179,12 @@ public class TranslationCollector {
                         err++;
                     }
                     if (OUTPUT_WARNINGS || problem.isError()) {
-                        System.out.println(problem);
+                        System.err.println(problem);
                         StringBuilder prob = new StringBuilder();
                         prob.append(parsedUnit.compilationResult.fileName);
                         prob.append(":");
                         prob.append(problem.getSourceLineNumber());
-                        System.out.println(prob.toString());
+                        System.err.println(prob.toString());
                     }
                 }
                 if (err > 0) {
@@ -193,7 +193,7 @@ public class TranslationCollector {
             }
 
             if (parsedUnit.types == null) {
-                System.out.println("No types");
+                System.err.println("No types");
 
             } else {
                 TranslationCollectingVisitor v = new TranslationCollectingVisitor(parsedUnit, taint.toArray(new TaintSource[taint.size()]), this);