| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 class MessageKind { | 5 class MessageKind { |
| 6 final String template; | 6 final String template; |
| 7 const MessageKind(this.template); | 7 const MessageKind(this.template); |
| 8 | 8 |
| 9 static final GENERIC = const MessageKind('#{1}'); | 9 static final GENERIC = const MessageKind('#{1}'); |
| 10 | 10 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 final List arguments; | 135 final List arguments; |
| 136 String message; | 136 String message; |
| 137 | 137 |
| 138 Message(this.kind, this.arguments); | 138 Message(this.kind, this.arguments); |
| 139 | 139 |
| 140 String toString() { | 140 String toString() { |
| 141 if (message === null) { | 141 if (message === null) { |
| 142 message = kind.template; | 142 message = kind.template; |
| 143 int position = 1; | 143 int position = 1; |
| 144 for (var argument in arguments) { | 144 for (var argument in arguments) { |
| 145 message = message.replaceAll('#{${position++}}', argument.toString()); | 145 String string = slowToString(argument); |
| 146 message = message.replaceAll('#{${position++}}', string); |
| 146 } | 147 } |
| 147 } | 148 } |
| 148 return message; | 149 return message; |
| 149 } | 150 } |
| 150 | 151 |
| 151 bool operator==(other) { | 152 bool operator==(other) { |
| 152 if (other is !Message) return false; | 153 if (other is !Message) return false; |
| 153 return (kind == other.kind) && (toString() == other.toString()); | 154 return (kind == other.kind) && (toString() == other.toString()); |
| 154 } | 155 } |
| 156 |
| 157 String slowToString(object) { |
| 158 if (object is SourceString) { |
| 159 return object.slowToString(); |
| 160 } else { |
| 161 return object.toString(); |
| 162 } |
| 163 } |
| 155 } | 164 } |
| 156 | 165 |
| 157 class TypeWarning { | 166 class TypeWarning { |
| 158 final Message message; | 167 final Message message; |
| 159 TypeWarning.message(this.message); | 168 TypeWarning.message(this.message); |
| 160 TypeWarning(MessageKind kind, List<Type> arguments) | 169 TypeWarning(MessageKind kind, List<Type> arguments) |
| 161 : message = new Message(kind, arguments); | 170 : message = new Message(kind, arguments); |
| 162 String toString() => message.toString(); | 171 String toString() => message.toString(); |
| 163 } | 172 } |
| 164 | 173 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 178 String toString() => message.toString(); | 187 String toString() => message.toString(); |
| 179 } | 188 } |
| 180 | 189 |
| 181 class CompileTimeConstantError { | 190 class CompileTimeConstantError { |
| 182 final Message message; | 191 final Message message; |
| 183 CompileTimeConstantError.message(this.message); | 192 CompileTimeConstantError.message(this.message); |
| 184 CompileTimeConstantError(MessageKind kind, List<Type> arguments) | 193 CompileTimeConstantError(MessageKind kind, List<Type> arguments) |
| 185 : message = new Message(kind, arguments); | 194 : message = new Message(kind, arguments); |
| 186 String toString() => message.toString(); | 195 String toString() => message.toString(); |
| 187 } | 196 } |
| OLD | NEW |