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

Unified Diff: frog/minfrog

Issue 8823010: frog: life is better with colors :) (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: '' 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: frog/minfrog
diff --git a/frog/minfrog b/frog/minfrog
index 69cd4ef05de2e902d6d249d0f978b177e4436ca7..39a6082ae7f77659c4f869eccf109fa3bacb3561 100755
--- a/frog/minfrog
+++ b/frog/minfrog
@@ -6268,14 +6268,23 @@ SourceFile.prototype.getLocationMessage = function(message, start, end, includeT
else {
textLine = this.get$text().substring(this._lineStarts.$index(line)) + '\n';
}
- buf.add$1(textLine);
- var i = 0;
- for (; i < column; i++) {
- buf.add$1(' ');
- }
var toColumn = Math.min(column + (end - start), textLine.length);
- for (; i < toColumn; i++) {
- buf.add$1('^');
+ if ($globals.options.useColors) {
+ buf.add$1(textLine.substring$2(0, column));
+ buf.add$1($globals._RED_COLOR);
+ buf.add$1(textLine.substring$2(column, toColumn));
+ buf.add$1($globals._NO_COLOR);
+ buf.add$1(textLine.substring$1(toColumn));
+ }
+ else {
+ buf.add$1(textLine);
+ var i = 0;
+ for (; i < column; i++) {
+ buf.add$1(' ');
+ }
+ for (; i < toColumn; i++) {
+ buf.add$1('^');
+ }
}
}
return buf.toString$0();
@@ -12546,7 +12555,7 @@ World.prototype._message = function(message, span, span1, span2, throwing) {
}
World.prototype.error = function(message, span, span1, span2) {
this.errors++;
- this._message(('error: ' + message), span, span1, span2, $globals.options.throwOnErrors);
+ this._message($globals.options.useColors ? ('' + $globals._RED_COLOR + 'error' + $globals._NO_COLOR + ': ' + message) : ('error: ' + message), span, span1, span2, $globals.options.throwOnErrors);
}
World.prototype.warning = function(message, span, span1, span2) {
if ($globals.options.warningsAsErrors) {
@@ -12555,13 +12564,13 @@ World.prototype.warning = function(message, span, span1, span2) {
}
this.warnings++;
if ($globals.options.showWarnings) {
- this._message(('warning: ' + message), span, span1, span2, $globals.options.throwOnWarnings);
+ this._message($globals.options.useColors ? ('' + $globals._MAGENTA_COLOR + 'warning' + $globals._NO_COLOR + ': ' + message) : ('warning: ' + message), span, span1, span2, $globals.options.throwOnWarnings);
}
}
World.prototype.fatal = function(message, span, span1, span2) {
this.errors++;
this.seenFatal = true;
- this._message(('fatal: ' + message), span, span1, span2, $globals.options.throwOnFatal || $globals.options.throwOnErrors);
+ this._message($globals.options.useColors ? ('' + $globals._RED_COLOR + 'fatal' + $globals._NO_COLOR + ': ' + message) : ('fatal: ' + message), span, span1, span2, $globals.options.throwOnFatal || $globals.options.throwOnErrors);
}
World.prototype.internalError = function(message, span, span1, span2) {
this._message(('We are sorry, but... ' + message), span, span1, span2, true);
@@ -12623,6 +12632,7 @@ function FrogOptions(homedir, args, files) {
this.throwOnFatal = false
this.showInfo = false
this.showWarnings = true
+ this.useColors = true
// Initializers done
if ($eq(this.config, 'dev')) {
this.libDir = joinPaths(homedir, '/lib');
@@ -12719,6 +12729,11 @@ function FrogOptions(homedir, args, files) {
this.forceDynamic = true;
continue loop;
+ case '--no_colors':
+
+ this.useColors = false;
+ continue loop;
+
default:
if (arg.endsWith$1('.dart')) {
@@ -13071,6 +13086,12 @@ function main() {
var homedir = path.dirname(fs.realpathSync(process.argv.$index(1)));
var argv = ListFactory.ListFactory$from$factory(process.argv);
if (compile(homedir, argv, new NodeFileSystem())) {
+ if ($globals.options.outfile != null) {
+ print(('Compilation succeded. Code generated in ' + $globals.options.outfile));
+ }
+ else {
+ print('Compilation succeded.');
+ }
var code = $globals.world.getGeneratedCode();
if (!$globals.options.compileOnly) {
process.argv = [argv.$index(0), argv.$index(1)];
@@ -13095,6 +13116,9 @@ $inheritsMembers(_DoubleLinkedQueueEntrySentinel_E, DoubleLinkedQueueEntry_E);
$inheritsMembers(_DoubleLinkedQueueEntrySentinel_KeyValuePair_K$V, DoubleLinkedQueueEntry_KeyValuePair_K$V);
// ********** Globals **************
function $static_init(){
+ $globals._MAGENTA_COLOR = '\u001b[35m';
+ $globals._NO_COLOR = '\u001b[0m';
+ $globals._RED_COLOR = '\u001b[31m';
}
var const$0 = new NoMoreElementsException()/*const NoMoreElementsException()*/;
var const$2 = new EmptyQueueException()/*const EmptyQueueException()*/;

Powered by Google App Engine
This is Rietveld 408576698