Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Unified Diff: compiler/java/com/google/dart/compiler/DefaultErrorFormatter.java

Issue 8949055: Issue 250: Allow for GNU formatted errors (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Tweaks to drop 'gnu' and stuff library in message format Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: compiler/java/com/google/dart/compiler/DefaultErrorFormatter.java
diff --git a/compiler/java/com/google/dart/compiler/DefaultErrorFormatter.java b/compiler/java/com/google/dart/compiler/DefaultErrorFormatter.java
index 898cb322e9b0f4a40e9447932747680394fc43de..9ed637d6ab8446a8066362d8ef62e314a216e531 100644
--- a/compiler/java/com/google/dart/compiler/DefaultErrorFormatter.java
+++ b/compiler/java/com/google/dart/compiler/DefaultErrorFormatter.java
@@ -4,6 +4,8 @@
package com.google.dart.compiler;
+import com.google.dart.compiler.CompilerConfiguration.ErrorFormat;
+
import java.io.PrintStream;
/**
@@ -12,18 +14,38 @@ import java.io.PrintStream;
*/
public class DefaultErrorFormatter implements ErrorFormatter {
protected final PrintStream outputStream;
+ protected final ErrorFormat errorFormat;
- public DefaultErrorFormatter(PrintStream outputStream) {
+ public DefaultErrorFormatter(PrintStream outputStream, ErrorFormat errorFormat) {
this.outputStream = outputStream;
+ this.errorFormat = errorFormat;
}
@Override
public void format(DartCompilationError event) {
- outputStream.printf("%s:%d:%d: %s\n",
- (event.getSource() != null)
- ? event.getSource().getName() : "<unknown-source-file>",
+ String sourceName = "<unknown-source-file>";
+ Source sourceFile = event.getSource();
+ String includeFrom = getImportString(sourceFile);
+
+ if (sourceFile != null) {
+ sourceName = sourceFile.getUri().toString();
+ }
+ outputStream.printf("%s:%d:%d: %s%s\n",
+ sourceName,
event.getLineNumber(),
event.getColumnNumber(),
- event.getMessage());
+ event.getMessage(),
+ includeFrom);
+ }
+
+ public String getImportString(Source sourceFile) {
+ String includeFrom = "";
+ if (sourceFile instanceof DartSource) {
+ LibrarySource lib = ((DartSource) sourceFile).getLibrary();
+ if (!sourceFile.getUri().equals(lib.getUri())) {
+ includeFrom = " (sourced from library " + lib.getUri() + ")";
zundel 2011/12/22 15:32:31 for the sake of brevity, could we drop the word 'l
codefu 2011/12/22 15:38:20 Sure thing.
ahe 2011/12/22 15:38:33 FWIW, I agree.
+ }
+ }
+ return includeFrom;
}
}

Powered by Google App Engine
This is Rietveld 408576698