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

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

Issue 20722006: Removed compiler/ directory from repository (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 5 months 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: dart/compiler/java/com/google/dart/compiler/DefaultErrorFormatter.java
diff --git a/dart/compiler/java/com/google/dart/compiler/DefaultErrorFormatter.java b/dart/compiler/java/com/google/dart/compiler/DefaultErrorFormatter.java
deleted file mode 100644
index a908369d1b6c326cd4dca4ee9bb1cd0696e21d6a..0000000000000000000000000000000000000000
--- a/dart/compiler/java/com/google/dart/compiler/DefaultErrorFormatter.java
+++ /dev/null
@@ -1,93 +0,0 @@
-// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-package com.google.dart.compiler;
-
-import com.google.common.base.Objects;
-import com.google.dart.compiler.CompilerConfiguration.ErrorFormat;
-
-import java.io.PrintStream;
-
-/**
- * An error formatter that simply prints the file name with the line and column
- * location.
- */
-public class DefaultErrorFormatter implements ErrorFormatter {
- protected final PrintStream outputStream;
- protected final ErrorFormat errorFormat;
-
- public DefaultErrorFormatter(PrintStream outputStream, ErrorFormat errorFormat) {
- this.outputStream = outputStream;
- this.errorFormat = errorFormat;
- }
-
- @Override
- public void format(DartCompilationError event) {
- StringBuilder buf = new StringBuilder();
- appendError(buf, event);
- outputStream.print(buf);
- outputStream.print("\n");
- }
-
- protected void appendError(StringBuilder buf, DartCompilationError error) {
- Source source = error.getSource();
- String sourceName = getSourceName(source);
- int line = error.getLineNumber();
- int col = error.getColumnNumber();
- int length = error.getLength();
- if (errorFormat == ErrorFormat.MACHINE) {
- buf.append(String.format(
- "%s|%s|%s|%s|%d|%d|%d|%s",
- escapePipe(error.getErrorCode().getErrorSeverity().toString()),
- escapePipe(error.getErrorCode().getSubSystem().toString()),
- escapePipe(error.getErrorCode().toString()),
- escapePipe(sourceName),
- line,
- col,
- length,
- escapePipe(error.getMessage())));
- } else {
- String includeFrom = getImportString(source);
- buf.append(String.format(
- "%s:%d:%d: %s%s",
- sourceName,
- line,
- col,
- error.getMessage(),
- includeFrom));
- }
- }
-
- protected static String getImportString(Source sourceFile) {
- String includeFrom = "";
- if (sourceFile instanceof DartSource) {
- LibrarySource lib = ((DartSource) sourceFile).getLibrary();
- if (lib != null && !Objects.equal(sourceFile.getUri(), lib.getUri())) {
- includeFrom = " (sourced from " + lib.getUri() + ")";
- }
- }
- return includeFrom;
- }
-
- protected static String getSourceName(Source source) {
- if (source instanceof UrlDartSource) {
- return source.getUri().toString();
- }
- if (source != null) {
- return source.getName();
- }
- return "<unknown-source-file>";
- }
-
- protected static String escapePipe(String input) {
- StringBuilder result = new StringBuilder();
- for (char c : input.toCharArray()) {
- if (c == '\\' || c == '|') {
- result.append('\\');
- }
- result.append(c);
- }
- return result.toString();
- }
-}

Powered by Google App Engine
This is Rietveld 408576698