From: Felix Dörre Date: Sun, 4 Sep 2016 11:53:10 +0000 (+0200) Subject: fix: print error messages for translation extraction to stderr X-Git-Url: https://code.wpia.club/?p=gigi.git;a=commitdiff_plain;h=4ea1f0f52d5a245dd561416c4564d3dcf75051ed fix: print error messages for translation extraction to stderr Change-Id: I26c6294d93463575ce02a5a0752a37814eb47a0d --- diff --git a/util-testing/org/cacert/gigi/localisation/TranslationCollectingVisitor.java b/util-testing/org/cacert/gigi/localisation/TranslationCollectingVisitor.java index 3f8b858d..a7b69418 100644 --- a/util-testing/org/cacert/gigi/localisation/TranslationCollectingVisitor.java +++ b/util-testing/org/cacert/gigi/localisation/TranslationCollectingVisitor.java @@ -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; } } diff --git a/util-testing/org/cacert/gigi/localisation/TranslationCollector.java b/util-testing/org/cacert/gigi/localisation/TranslationCollector.java index 2592f3a7..9b4f2a9f 100644 --- a/util-testing/org/cacert/gigi/localisation/TranslationCollector.java +++ b/util-testing/org/cacert/gigi/localisation/TranslationCollector.java @@ -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 trs = new TreeSet<>(translations.values()); writePOFile(out, trs); } @@ -111,7 +111,7 @@ public class TranslationCollector { } private void scanCode(LinkedList 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(), ".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);