| 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 library mock_compiler; | 5 library mock_compiler; |
| 6 | 6 |
| 7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 import 'dart:collection'; | 9 import 'dart:collection'; |
| 10 | 10 |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 | 356 |
| 357 // The mock compiler does not split the program in output units. | 357 // The mock compiler does not split the program in output units. |
| 358 class MockDeferredLoadTask extends DeferredLoadTask { | 358 class MockDeferredLoadTask extends DeferredLoadTask { |
| 359 MockDeferredLoadTask(Compiler compiler) : super(compiler); | 359 MockDeferredLoadTask(Compiler compiler) : super(compiler); |
| 360 | 360 |
| 361 OutputUnit getElementOutputUnit(dynamic dependency) { | 361 OutputUnit getElementOutputUnit(dynamic dependency) { |
| 362 return mainOutputUnit; | 362 return mainOutputUnit; |
| 363 } | 363 } |
| 364 } | 364 } |
| 365 | 365 |
| 366 api.DiagnosticHandler createHandler(MockCompiler compiler, String text) { | 366 api.DiagnosticHandler createHandler(MockCompiler compiler, String text, |
| 367 {bool verbose: false}) { |
| 367 return (uri, int begin, int end, String message, kind) { | 368 return (uri, int begin, int end, String message, kind) { |
| 369 if (kind == api.Diagnostic.VERBOSE_INFO && !verbose) return; |
| 368 SourceFile sourceFile; | 370 SourceFile sourceFile; |
| 369 if (uri == null) { | 371 if (uri == null) { |
| 370 sourceFile = new StringSourceFile('analysis', text); | 372 sourceFile = new StringSourceFile('analysis', text); |
| 371 } else { | 373 } else { |
| 372 sourceFile = compiler.sourceFiles[uri.toString()]; | 374 sourceFile = compiler.sourceFiles[uri.toString()]; |
| 373 } | 375 } |
| 374 if (sourceFile != null && begin != null && end != null) { | 376 if (sourceFile != null && begin != null && end != null) { |
| 375 print(sourceFile.getLocationMessage(message, begin, end, true, (x) => x)); | 377 print(sourceFile.getLocationMessage(message, begin, end, true, (x) => x)); |
| 376 } else { | 378 } else { |
| 377 print(message); | 379 print(message); |
| 378 } | 380 } |
| 379 }; | 381 }; |
| 380 } | 382 } |
| 381 | 383 |
| 382 class MockElement extends FunctionElementX { | 384 class MockElement extends FunctionElementX { |
| 383 MockElement(Element enclosingElement) | 385 MockElement(Element enclosingElement) |
| 384 : super('', ElementKind.FUNCTION, Modifiers.EMPTY, | 386 : super('', ElementKind.FUNCTION, Modifiers.EMPTY, |
| 385 enclosingElement, false); | 387 enclosingElement, false); |
| 386 | 388 |
| 387 get node => null; | 389 get node => null; |
| 388 | 390 |
| 389 parseNode(_) => null; | 391 parseNode(_) => null; |
| 390 | 392 |
| 391 bool get hasNode => false; | 393 bool get hasNode => false; |
| 392 } | 394 } |
| OLD | NEW |