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 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 compiler.withCurrentElement(element, () { | 460 compiler.withCurrentElement(element, () { |
461 target.addToScope(element, compiler); | 461 target.addToScope(element, compiler); |
462 }); | 462 }); |
463 } | 463 } |
464 } | 464 } |
465 | 465 |
466 LibraryElement mockLibrary(Compiler compiler, String source) { | 466 LibraryElement mockLibrary(Compiler compiler, String source) { |
467 Uri uri = new Uri(scheme: "source"); | 467 Uri uri = new Uri(scheme: "source"); |
468 var library = new LibraryElementX(new Script(uri, new MockFile(source))); | 468 var library = new LibraryElementX(new Script(uri, new MockFile(source))); |
469 importLibrary(library, compiler.coreLibrary, compiler); | 469 importLibrary(library, compiler.coreLibrary, compiler); |
| 470 library.setExports(<Element>[]); |
470 return library; | 471 return library; |
471 } | 472 } |
472 | 473 |
473 class CollectingTreeElements extends TreeElementMapping { | 474 class CollectingTreeElements extends TreeElementMapping { |
474 final Map<Node, Element> map = new LinkedHashMap<Node, Element>(); | 475 final Map<Node, Element> map = new LinkedHashMap<Node, Element>(); |
475 | 476 |
476 CollectingTreeElements(Element currentElement) : super(currentElement); | 477 CollectingTreeElements(Element currentElement) : super(currentElement); |
477 | 478 |
478 operator []=(Node node, Element element) { | 479 operator []=(Node node, Element element) { |
479 map[node] = element; | 480 map[node] = element; |
(...skipping 22 matching lines...) Expand all Loading... |
502 } else { | 503 } else { |
503 sourceFile = compiler.sourceFiles[uri.toString()]; | 504 sourceFile = compiler.sourceFiles[uri.toString()]; |
504 } | 505 } |
505 if (sourceFile != null && begin != null && end != null) { | 506 if (sourceFile != null && begin != null && end != null) { |
506 print(sourceFile.getLocationMessage(message, begin, end, true, (x) => x)); | 507 print(sourceFile.getLocationMessage(message, begin, end, true, (x) => x)); |
507 } else { | 508 } else { |
508 print(message); | 509 print(message); |
509 } | 510 } |
510 }; | 511 }; |
511 } | 512 } |
OLD | NEW |