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

Unified Diff: pkg/csslib/lib/src/messages.dart

Issue 814113004: Pull args, intl, logging, shelf, and source_maps out of the SDK. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Also csslib. Created 6 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
« no previous file with comments | « pkg/csslib/lib/src/css_printer.dart ('k') | pkg/csslib/lib/src/options.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/csslib/lib/src/messages.dart
diff --git a/pkg/csslib/lib/src/messages.dart b/pkg/csslib/lib/src/messages.dart
deleted file mode 100644
index 92f8451b7ab2d9b44266929c5143872e088c898d..0000000000000000000000000000000000000000
--- a/pkg/csslib/lib/src/messages.dart
+++ /dev/null
@@ -1,127 +0,0 @@
-// Copyright (c) 2012, 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.
-
-library csslib.src.messages;
-
-import 'package:logging/logging.dart' show Level;
-import 'package:source_span/source_span.dart';
-
-import 'options.dart';
-
-// TODO(terry): Remove the global messages, use some object that tracks
-// compilation state.
-
-/** The global [Messages] for tracking info/warnings/messages. */
-Messages messages;
-
-// Color constants used for generating messages.
-final String GREEN_COLOR = '\u001b[32m';
-final String RED_COLOR = '\u001b[31m';
-final String MAGENTA_COLOR = '\u001b[35m';
-final String NO_COLOR = '\u001b[0m';
-
-/** Map between error levels and their display color. */
-final Map<Level, String> _ERROR_COLORS = (() {
- var colorsMap = new Map<Level, String>();
- colorsMap[Level.SEVERE] = RED_COLOR;
- colorsMap[Level.WARNING] = MAGENTA_COLOR;
- colorsMap[Level.INFO] = GREEN_COLOR;
- return colorsMap;
-})();
-
-/** Map between error levels and their friendly name. */
-final Map<Level, String> _ERROR_LABEL = (() {
- var labels = new Map<Level, String>();
- labels[Level.SEVERE] = 'error';
- labels[Level.WARNING] = 'warning';
- labels[Level.INFO] = 'info';
- return labels;
-})();
-
-/** A single message from the compiler. */
-class Message {
- final Level level;
- final String message;
- final SourceSpan span;
- final bool useColors;
-
- Message(this.level, this.message, {SourceSpan span, bool useColors: false})
- : this.span = span, this.useColors = useColors;
-
- String toString() {
- var output = new StringBuffer();
- bool colors = useColors && _ERROR_COLORS.containsKey(level);
- var levelColor = colors ? _ERROR_COLORS[level] : null;
- if (colors) output.write(levelColor);
- output..write(_ERROR_LABEL[level])..write(' ');
- if (colors) output.write(NO_COLOR);
-
- if (span == null) {
- output.write(message);
- } else {
- output.write('on ');
- output.write(span.message(message, color: levelColor));
- }
-
- return output.toString();
- }
-}
-
-typedef void PrintHandler(Message obj);
-
-/**
- * This class tracks and prints information, warnings, and errors emitted by the
- * compiler.
- */
-class Messages {
- /** Called on every error. Set to blank function to supress printing. */
- final PrintHandler printHandler;
-
- final PreprocessorOptions options;
-
- final List<Message> messages = <Message>[];
-
- Messages({PreprocessorOptions options, this.printHandler: print})
- : options = options != null ? options : new PreprocessorOptions();
-
- /** Report a compile-time CSS error. */
- void error(String message, SourceSpan span) {
- var msg = new Message(Level.SEVERE, message, span: span,
- useColors: options.useColors);
-
- messages.add(msg);
-
- printHandler(msg);
- }
-
- /** Report a compile-time CSS warning. */
- void warning(String message, SourceSpan span) {
- if (options.warningsAsErrors) {
- error(message, span);
- } else {
- var msg = new Message(Level.WARNING, message, span: span,
- useColors: options.useColors);
-
- messages.add(msg);
- }
- }
-
- /** Report and informational message about what the compiler is doing. */
- void info(String message, SourceSpan span) {
- var msg = new Message(Level.INFO, message, span: span,
- useColors: options.useColors);
-
- messages.add(msg);
-
- if (options.verbose) printHandler(msg);
- }
-
- /** Merge [newMessages] to this message lsit. */
- void mergeMessages(Messages newMessages) {
- messages.addAll(newMessages.messages);
- newMessages.messages.where((message) =>
- message.level.value == Level.SEVERE || options.verbose)
- .forEach((message) { printHandler(message); });
- }
-}
« no previous file with comments | « pkg/csslib/lib/src/css_printer.dart ('k') | pkg/csslib/lib/src/options.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698