|
12 | 12 | /** |
13 | 13 | * Utilities to report error messages. |
14 | 14 | * |
15 | | - * <p> |
16 | | - * NOTE(olafur): this class exists because I couldn't find compiler APIs to |
17 | | - * report diagnostics. This class can be removed if the Java compiler has APIs |
18 | | - * to report info/warning/error messages. |
| 15 | + * <p>NOTE(olafur): this class exists because I couldn't find compiler APIs to report diagnostics. |
| 16 | + * This class can be removed if the Java compiler has APIs to report info/warning/error messages. |
19 | 17 | */ |
20 | 18 | public class SemanticdbReporter { |
21 | | - private final Trees trees; |
22 | | - |
23 | | - public SemanticdbReporter(Trees trees) { |
24 | | - this.trees = trees; |
25 | | - } |
26 | | - |
27 | | - public void exception(Throwable e, Tree tree, CompilationUnitTree root) { |
28 | | - ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
29 | | - PrintWriter writer = new PrintWriter(baos); |
30 | | - e.printStackTrace(writer); |
31 | | - writer.println( |
32 | | - "Please report a bug to https://github.com/sourcegraph/semanticdb-java with the stack trace above."); |
33 | | - trees.printMessage(Diagnostic.Kind.ERROR, baos.toString(), tree, root); |
34 | | - } |
35 | | - |
36 | | - private void info(String message, TaskEvent e) { |
37 | | - trees.printMessage(Diagnostic.Kind.NOTE, "semanticdb-javac: " + message, e.getCompilationUnit(), |
38 | | - e.getCompilationUnit()); |
39 | | - } |
40 | | - |
41 | | - public void error(String message, TaskEvent e) { |
42 | | - trees.printMessage(Diagnostic.Kind.ERROR, "semanticdb-javac: " + message, e.getCompilationUnit(), |
43 | | - e.getCompilationUnit()); |
44 | | - } |
45 | | - |
46 | | - } |
47 | | - |
48 | | - public void error(String message, Tree tree, CompilationUnitTree root) { |
49 | | - // NOTE(olafur): ideally, this message should be reported as a compiler |
50 | | - // diagnostic, but I dind't |
51 | | - // find |
52 | | - // the reporter API so the message goes to stderr instead for now. |
53 | | - trees.printMessage(Diagnostic.Kind.ERROR, String.format("semanticdb-javac: %s", message), tree, root); |
54 | | - } |
| 19 | + private final Trees trees; |
| 20 | + |
| 21 | + public SemanticdbReporter(Trees trees) { |
| 22 | + this.trees = trees; |
| 23 | + } |
| 24 | + |
| 25 | + public void exception(Throwable e, Tree tree, CompilationUnitTree root) { |
| 26 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
| 27 | + PrintWriter writer = new PrintWriter(baos); |
| 28 | + e.printStackTrace(writer); |
| 29 | + writer.println( |
| 30 | + "Please report a bug to https://github.com/sourcegraph/semanticdb-java with the stack trace above."); |
| 31 | + trees.printMessage(Diagnostic.Kind.ERROR, baos.toString(), tree, root); |
| 32 | + } |
| 33 | + |
| 34 | + public void info(String message, TaskEvent e) { |
| 35 | + trees.printMessage( |
| 36 | + Diagnostic.Kind.NOTE, |
| 37 | + "semanticdb-javac: " + message, |
| 38 | + e.getCompilationUnit(), |
| 39 | + e.getCompilationUnit()); |
| 40 | + } |
| 41 | + |
| 42 | + public void error(String message, TaskEvent e) { |
| 43 | + trees.printMessage( |
| 44 | + Diagnostic.Kind.ERROR, |
| 45 | + "semanticdb-javac: " + message, |
| 46 | + e.getCompilationUnit(), |
| 47 | + e.getCompilationUnit()); |
| 48 | + } |
| 49 | + |
| 50 | + public void error(String message, Tree tree, CompilationUnitTree root) { |
| 51 | + // NOTE(olafur): ideally, this message should be reported as a compiler |
| 52 | + // diagnostic, but I dind't |
| 53 | + // find |
| 54 | + // the reporter API so the message goes to stderr instead for now. |
| 55 | + trees.printMessage( |
| 56 | + Diagnostic.Kind.ERROR, String.format("semanticdb-javac: %s", message), tree, root); |
| 57 | + } |
55 | 58 | } |
0 commit comments