Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: tests/compiler/dart2js/mock_compiler.dart

Issue 16019002: Merge the dart:uri library into dart:core and update the Uri class (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Final cleanup Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/compiler/dart2js/mirrors_test.dart ('k') | tests/compiler/dart2js/parser_helper.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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:collection'; 8 import 'dart:collection';
9 import 'dart:uri';
10 9
11 import '../../../sdk/lib/_internal/compiler/compiler.dart' as api; 10 import '../../../sdk/lib/_internal/compiler/compiler.dart' as api;
12 import '../../../sdk/lib/_internal/compiler/implementation/elements/elements.dar t'; 11 import '../../../sdk/lib/_internal/compiler/implementation/elements/elements.dar t';
13 import '../../../sdk/lib/_internal/compiler/implementation/resolution/resolution .dart'; 12 import '../../../sdk/lib/_internal/compiler/implementation/resolution/resolution .dart';
14 import '../../../sdk/lib/_internal/compiler/implementation/source_file.dart'; 13 import '../../../sdk/lib/_internal/compiler/implementation/source_file.dart';
15 import '../../../sdk/lib/_internal/compiler/implementation/tree/tree.dart'; 14 import '../../../sdk/lib/_internal/compiler/implementation/tree/tree.dart';
16 import '../../../sdk/lib/_internal/compiler/implementation/util/util.dart'; 15 import '../../../sdk/lib/_internal/compiler/implementation/util/util.dart';
17 import 'parser_helper.dart'; 16 import 'parser_helper.dart';
18 17
19 import '../../../sdk/lib/_internal/compiler/implementation/elements/modelx.dart' 18 import '../../../sdk/lib/_internal/compiler/implementation/elements/modelx.dart'
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 */ 239 */
241 void registerSource(Uri uri, String source) { 240 void registerSource(Uri uri, String source) {
242 sourceFiles[uri.toString()] = new MockFile(source); 241 sourceFiles[uri.toString()] = new MockFile(source);
243 } 242 }
244 243
245 /** 244 /**
246 * Used internally to create a library from a source text. The created library 245 * Used internally to create a library from a source text. The created library
247 * is fixed to export its top-level declarations. 246 * is fixed to export its top-level declarations.
248 */ 247 */
249 LibraryElement createLibrary(String name, String source) { 248 LibraryElement createLibrary(String name, String source) {
250 Uri uri = new Uri.fromComponents(scheme: "dart", path: name); 249 Uri uri = new Uri(scheme: "dart", path: name);
251 var script = new Script(uri, new MockFile(source)); 250 var script = new Script(uri, new MockFile(source));
252 var library = new LibraryElementX(script); 251 var library = new LibraryElementX(script);
253 parseScript(source, library); 252 parseScript(source, library);
254 library.setExports(library.localScope.values.toList()); 253 library.setExports(library.localScope.values.toList());
255 registerSource(uri, source); 254 registerSource(uri, source);
256 libraries.putIfAbsent(uri.toString(), () => library); 255 libraries.putIfAbsent(uri.toString(), () => library);
257 return library; 256 return library;
258 } 257 }
259 258
260 void reportWarning(Node node, var message) { 259 void reportWarning(Node node, var message) {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 void importLibrary(LibraryElement target, LibraryElement imported, 394 void importLibrary(LibraryElement target, LibraryElement imported,
396 Compiler compiler) { 395 Compiler compiler) {
397 for (var element in imported.localMembers) { 396 for (var element in imported.localMembers) {
398 compiler.withCurrentElement(element, () { 397 compiler.withCurrentElement(element, () {
399 target.addToScope(element, compiler); 398 target.addToScope(element, compiler);
400 }); 399 });
401 } 400 }
402 } 401 }
403 402
404 LibraryElement mockLibrary(Compiler compiler, String source) { 403 LibraryElement mockLibrary(Compiler compiler, String source) {
405 Uri uri = new Uri.fromComponents(scheme: "source"); 404 Uri uri = new Uri(scheme: "source");
406 var library = new LibraryElementX(new Script(uri, new MockFile(source))); 405 var library = new LibraryElementX(new Script(uri, new MockFile(source)));
407 importLibrary(library, compiler.coreLibrary, compiler); 406 importLibrary(library, compiler.coreLibrary, compiler);
408 return library; 407 return library;
409 } 408 }
410 409
411 class CollectingTreeElements extends TreeElementMapping { 410 class CollectingTreeElements extends TreeElementMapping {
412 final Map<Node, Element> map = new LinkedHashMap<Node, Element>(); 411 final Map<Node, Element> map = new LinkedHashMap<Node, Element>();
413 412
414 CollectingTreeElements(Element currentElement) : super(currentElement); 413 CollectingTreeElements(Element currentElement) : super(currentElement);
415 414
416 operator []=(Node node, Element element) { 415 operator []=(Node node, Element element) {
417 map[node] = element; 416 map[node] = element;
418 } 417 }
419 418
420 operator [](Node node) => map[node]; 419 operator [](Node node) => map[node];
421 420
422 void remove(Node node) { 421 void remove(Node node) {
423 map.remove(node); 422 map.remove(node);
424 } 423 }
425 } 424 }
426 425
427 class MockDeferredLoadTask extends DeferredLoadTask { 426 class MockDeferredLoadTask extends DeferredLoadTask {
428 MockDeferredLoadTask(Compiler compiler) : super(compiler); 427 MockDeferredLoadTask(Compiler compiler) : super(compiler);
429 428
430 void registerMainApp(LibraryElement mainApp) { 429 void registerMainApp(LibraryElement mainApp) {
431 // Do nothing. 430 // Do nothing.
432 } 431 }
433 } 432 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/mirrors_test.dart ('k') | tests/compiler/dart2js/parser_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698