| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** The one true [World]. */ | 5 /** The one true [World]. */ |
| 6 World world; | 6 World world; |
| 7 | 7 |
| 8 typedef void MessageHandler(String prefix, String message, SourceSpan span); | 8 typedef void MessageHandler(String prefix, String message, SourceSpan span); |
| 9 typedef void PrintHandler(String message); | 9 typedef void PrintHandler(String message); |
| 10 | 10 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 // TODO(jimhug): Multiple spans cleaner... | 65 // TODO(jimhug): Multiple spans cleaner... |
| 66 messageHandler(prefix, message, span); | 66 messageHandler(prefix, message, span); |
| 67 if (span1 != null) { | 67 if (span1 != null) { |
| 68 messageHandler(prefix, message, span1); | 68 messageHandler(prefix, message, span1); |
| 69 } | 69 } |
| 70 if (span2 != null) { | 70 if (span2 != null) { |
| 71 messageHandler(prefix, message, span2); | 71 messageHandler(prefix, message, span2); |
| 72 } | 72 } |
| 73 } else { | 73 } else { |
| 74 final messageWithPrefix = options.useColors | 74 final messageWithPrefix = options.useColors |
| 75 ? (color + prefix + _NO_COLOR + message) : (prefix + message); | 75 ? "$color$prefix$_NO_COLOR$message" : "$prefix$message"; |
| 76 | 76 |
| 77 var text = messageWithPrefix; | 77 var text = messageWithPrefix; |
| 78 if (span != null) { | 78 if (span != null) { |
| 79 text = span.toMessageString(messageWithPrefix); | 79 text = span.toMessageString(messageWithPrefix); |
| 80 } | 80 } |
| 81 | 81 |
| 82 String span1Text = span1 != null ? | 82 String span1Text = span1 != null ? |
| 83 span1.toMessageString(messageWithPrefix) : ""; | 83 span1.toMessageString(messageWithPrefix) : ""; |
| 84 String span2Text = span2 != null ? | 84 String span2Text = span2 != null ? |
| 85 span2.toMessageString(messageWithPrefix) : ""; | 85 span2.toMessageString(messageWithPrefix) : ""; |
| 86 | 86 |
| 87 if (printHandler == null) { | 87 if (printHandler == null) { |
| 88 print(text); | 88 print(text); |
| 89 if (span1 != null) { | 89 if (span1 != null) { |
| 90 print(span1Text); | 90 print(span1Text); |
| 91 } | 91 } |
| 92 if (span2 != null) { | 92 if (span2 != null) { |
| 93 print(span2Text); | 93 print(span2Text); |
| 94 } | 94 } |
| 95 } else { | 95 } else { |
| 96 printHandler("${text}\r${span1Text}\r${span2Text}"); | 96 printHandler("${text}\r${span1Text}\r${span2Text}"); |
| 97 } | 97 } |
| 98 } | 98 } |
| 99 | 99 |
| 100 if (throwing) { | 100 if (throwing) { |
| 101 throw new CompilerException(prefix + message, span); | 101 throw new CompilerException("$prefix$message", span); |
| 102 } | 102 } |
| 103 } | 103 } |
| 104 | 104 |
| 105 /** [message] is considered a static compile-time error by the Dart lang. */ | 105 /** [message] is considered a static compile-time error by the Dart lang. */ |
| 106 void error(String message, | 106 void error(String message, |
| 107 [SourceSpan span, SourceSpan span1, SourceSpan span2]) { | 107 [SourceSpan span, SourceSpan span1, SourceSpan span2]) { |
| 108 errors++; | 108 errors++; |
| 109 _message(_RED_COLOR, 'error: ', message, | 109 _message(_RED_COLOR, 'error: ', message, |
| 110 span, span1, span2, options.throwOnErrors); | 110 span, span1, span2, options.throwOnErrors); |
| 111 } | 111 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 sw.stop(); | 160 sw.stop(); |
| 161 info('$name in ${sw.elapsedInMs()}msec'); | 161 info('$name in ${sw.elapsedInMs()}msec'); |
| 162 return result; | 162 return result; |
| 163 } | 163 } |
| 164 } | 164 } |
| 165 | 165 |
| 166 String _GREEN_COLOR = '\u001b[32m'; | 166 String _GREEN_COLOR = '\u001b[32m'; |
| 167 String _RED_COLOR = '\u001b[31m'; | 167 String _RED_COLOR = '\u001b[31m'; |
| 168 String _MAGENTA_COLOR = '\u001b[35m'; | 168 String _MAGENTA_COLOR = '\u001b[35m'; |
| 169 String _NO_COLOR = '\u001b[0m'; | 169 String _NO_COLOR = '\u001b[0m'; |
| OLD | NEW |