OLD | NEW |
1 library java.engine; | 1 library java.engine; |
2 | 2 |
3 import 'java_core.dart'; | 3 import 'java_core.dart'; |
4 | 4 |
5 /** | 5 /** |
6 * A predicate is a one-argument function that returns a boolean value. | 6 * A predicate is a one-argument function that returns a boolean value. |
7 */ | 7 */ |
8 typedef bool Predicate<E>(E argument); | 8 typedef bool Predicate<E>(E argument); |
9 | 9 |
10 class StringUtilities { | 10 class StringUtilities { |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 static int combineHashCodes(int first, int second) => first * 31 + second; | 195 static int combineHashCodes(int first, int second) => first * 31 + second; |
196 } | 196 } |
197 | 197 |
198 class UUID { | 198 class UUID { |
199 static int __nextId = 0; | 199 static int __nextId = 0; |
200 final String id; | 200 final String id; |
201 UUID(this.id); | 201 UUID(this.id); |
202 String toString() => id; | 202 String toString() => id; |
203 static UUID randomUUID() => new UUID((__nextId).toString()); | 203 static UUID randomUUID() => new UUID((__nextId).toString()); |
204 } | 204 } |
| 205 |
| 206 |
| 207 /** |
| 208 * Instances of the class `AnalysisException` represent an exception that |
| 209 * occurred during the analysis of one or more sources. |
| 210 */ |
| 211 class AnalysisException implements Exception { |
| 212 /** |
| 213 * The message that explains why the exception occurred. |
| 214 */ |
| 215 final String message; |
| 216 |
| 217 /** |
| 218 * The exception that caused this exception, or `null` if this exception was |
| 219 * not caused by another exception. |
| 220 */ |
| 221 final CaughtException cause; |
| 222 |
| 223 /** |
| 224 * Initialize a newly created exception to have the given [message] and |
| 225 * [cause]. |
| 226 */ |
| 227 AnalysisException([this.message = 'Exception', this.cause = null]); |
| 228 } |
| 229 |
| 230 |
| 231 /** |
| 232 * Instances of the class `CaughtException` represent an exception that was |
| 233 * caught and has an associated stack trace. |
| 234 */ |
| 235 class CaughtException implements Exception { |
| 236 /** |
| 237 * The exception that was caught. |
| 238 */ |
| 239 final Exception exception; |
| 240 |
| 241 /** |
| 242 * The stack trace associated with the exception. |
| 243 */ |
| 244 StackTrace stackTrace; |
| 245 |
| 246 /** |
| 247 * Initialize a newly created caught exception to have the given [exception] |
| 248 * and [stackTrace]. |
| 249 */ |
| 250 CaughtException(this.exception, stackTrace) { |
| 251 if (stackTrace == null) { |
| 252 try { |
| 253 throw this; |
| 254 } catch (_, st) { |
| 255 stackTrace = st; |
| 256 } |
| 257 } |
| 258 this.stackTrace = stackTrace; |
| 259 } |
| 260 |
| 261 @override |
| 262 String toString() { |
| 263 StringBuffer buffer = new StringBuffer(); |
| 264 _writeOn(buffer); |
| 265 return buffer.toString(); |
| 266 } |
| 267 |
| 268 /** |
| 269 * Write a textual representation of the caught exception and its associated |
| 270 * stack trace. |
| 271 */ |
| 272 void _writeOn(StringBuffer buffer) { |
| 273 if (exception is AnalysisException) { |
| 274 AnalysisException analysisException = exception; |
| 275 buffer.writeln(analysisException.message); |
| 276 if (stackTrace != null) { |
| 277 buffer.writeln(stackTrace.toString()); |
| 278 } |
| 279 CaughtException cause = analysisException.cause; |
| 280 if (cause != null) { |
| 281 buffer.write('Caused by '); |
| 282 cause._writeOn(buffer); |
| 283 } |
| 284 } else { |
| 285 buffer.writeln(exception.toString()); |
| 286 buffer.writeln(stackTrace.toString()); |
| 287 } |
| 288 } |
| 289 } |
OLD | NEW |