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

Side by Side Diff: lib/dartdoc/mirrors/dart2js_mirror.dart

Issue 10823257: Refactored accessors in mirrors from methods to properties. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Missing updates Created 8 years, 4 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 | « lib/dartdoc/dartdoc.dart ('k') | lib/dartdoc/mirrors/mirrors.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('mirrors.dart2js'); 5 #library('mirrors.dart2js');
6 6
7 #import('../../compiler/compiler.dart', prefix: 'diagnostics'); 7 #import('../../compiler/compiler.dart', prefix: 'diagnostics');
8 #import('../../compiler/implementation/elements/elements.dart'); 8 #import('../../compiler/implementation/elements/elements.dart');
9 #import('../../compiler/implementation/apiimpl.dart', prefix: 'api'); 9 #import('../../compiler/implementation/apiimpl.dart', prefix: 'api');
10 #import('../../compiler/implementation/scanner/scannerlib.dart'); 10 #import('../../compiler/implementation/scanner/scannerlib.dart');
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 // TODO(johnniwinther): Detect file not found 351 // TODO(johnniwinther): Detect file not found
352 } 352 }
353 _compiler.runList(librariesUri); 353 _compiler.runList(librariesUri);
354 } 354 }
355 355
356 void addLibrary(String path) { 356 void addLibrary(String path) {
357 var uri = cwd.resolve(nativeToUriPath(path)); 357 var uri = cwd.resolve(nativeToUriPath(path));
358 _compiler.scanner.loadLibrary(uri, null); 358 _compiler.scanner.loadLibrary(uri, null);
359 } 359 }
360 360
361 MirrorSystem mirrors() => new Dart2JsMirrorSystem(_compiler); 361 MirrorSystem get mirrors() => new Dart2JsMirrorSystem(_compiler);
362 362
363 Future<String> compileToJavaScript() => 363 Future<String> compileToJavaScript() =>
364 new Future<String>.immediate(_compiler.assembledCode); 364 new Future<String>.immediate(_compiler.assembledCode);
365 } 365 }
366 366
367 367
368 //------------------------------------------------------------------------------ 368 //------------------------------------------------------------------------------
369 // Dart2Js specific extensions of mirror interfaces 369 // Dart2Js specific extensions of mirror interfaces
370 //------------------------------------------------------------------------------ 370 //------------------------------------------------------------------------------
371 371
(...skipping 15 matching lines...) Expand all
387 387
388 abstract class Dart2JsElementMirror implements Dart2JsMirror { 388 abstract class Dart2JsElementMirror implements Dart2JsMirror {
389 final Dart2JsMirrorSystem system; 389 final Dart2JsMirrorSystem system;
390 final Element _element; 390 final Element _element;
391 391
392 Dart2JsElementMirror(this.system, this._element) { 392 Dart2JsElementMirror(this.system, this._element) {
393 assert (system !== null); 393 assert (system !== null);
394 assert (_element !== null); 394 assert (_element !== null);
395 } 395 }
396 396
397 String simpleName() => _element.name.slowToString(); 397 String get simpleName() => _element.name.slowToString();
398 398
399 Location location() => new Dart2JsLocation( 399 Location get location() => new Dart2JsLocation(
400 _element.getCompilationUnit().script, 400 _element.getCompilationUnit().script,
401 system.compiler.spanFromElement(_element)); 401 system.compiler.spanFromElement(_element));
402 402
403 String toString() => _element.toString(); 403 String toString() => _element.toString();
404 404
405 int hashCode() => qualifiedName().hashCode(); 405 int hashCode() => qualifiedName.hashCode();
406 } 406 }
407 407
408 abstract class Dart2JsProxyMirror implements Dart2JsMirror { 408 abstract class Dart2JsProxyMirror implements Dart2JsMirror {
409 final Dart2JsMirrorSystem system; 409 final Dart2JsMirrorSystem system;
410 410
411 Dart2JsProxyMirror(this.system); 411 Dart2JsProxyMirror(this.system);
412 412
413 int hashCode() => qualifiedName().hashCode(); 413 int hashCode() => qualifiedName.hashCode();
414 } 414 }
415 415
416 //------------------------------------------------------------------------------ 416 //------------------------------------------------------------------------------
417 // Mirror system implementation. 417 // Mirror system implementation.
418 //------------------------------------------------------------------------------ 418 //------------------------------------------------------------------------------
419 419
420 class Dart2JsMirrorSystem implements MirrorSystem, Dart2JsMirror { 420 class Dart2JsMirrorSystem implements MirrorSystem, Dart2JsMirror {
421 final api.Compiler compiler; 421 final api.Compiler compiler;
422 Map<String, Dart2JsLibraryMirror> _libraries; 422 Map<String, Dart2JsLibraryMirror> _libraries;
423 Map<LibraryElement, Dart2JsLibraryMirror> _libraryMap; 423 Map<LibraryElement, Dart2JsLibraryMirror> _libraryMap;
424 424
425 Dart2JsMirrorSystem(this.compiler) 425 Dart2JsMirrorSystem(this.compiler)
426 : _libraryMap = new Map<LibraryElement, Dart2JsLibraryMirror>(); 426 : _libraryMap = new Map<LibraryElement, Dart2JsLibraryMirror>();
427 427
428 void _ensureLibraries() { 428 void _ensureLibraries() {
429 if (_libraries == null) { 429 if (_libraries == null) {
430 _libraries = <Dart2JsLibraryMirror>{}; 430 _libraries = <Dart2JsLibraryMirror>{};
431 compiler.libraries.forEach((_, LibraryElement v) { 431 compiler.libraries.forEach((_, LibraryElement v) {
432 var mirror = new Dart2JsLibraryMirror(system, v); 432 var mirror = new Dart2JsLibraryMirror(system, v);
433 _libraries[mirror.canonicalName] = mirror; 433 _libraries[mirror.canonicalName] = mirror;
434 _libraryMap[v] = mirror; 434 _libraryMap[v] = mirror;
435 }); 435 });
436 } 436 }
437 } 437 }
438 438
439 Map<Object, LibraryMirror> libraries() { 439 Map<Object, LibraryMirror> get libraries() {
440 _ensureLibraries(); 440 _ensureLibraries();
441 return new ImmutableMapWrapper<Object, LibraryMirror>(_libraries); 441 return new ImmutableMapWrapper<Object, LibraryMirror>(_libraries);
442 } 442 }
443 443
444 Dart2JsLibraryMirror getLibrary(LibraryElement element) { 444 Dart2JsLibraryMirror getLibrary(LibraryElement element) {
445 return _libraryMap[element]; 445 return _libraryMap[element];
446 } 446 }
447 447
448 Dart2JsMirrorSystem get system() => this; 448 Dart2JsMirrorSystem get system() => this;
449 449
450 String simpleName() => "mirror"; 450 String get simpleName() => "mirror";
451 String qualifiedName() => simpleName(); 451 String get qualifiedName() => simpleName;
452 452
453 String get canonicalName() => simpleName(); 453 String get canonicalName() => simpleName;
454 454
455 // TODO(johnniwinther): Hack! Dart2JsMirrorSystem need not be a Mirror. 455 // TODO(johnniwinther): Hack! Dart2JsMirrorSystem need not be a Mirror.
456 int hashCode() => qualifiedName().hashCode(); 456 int hashCode() => qualifiedName.hashCode();
457 } 457 }
458 458
459 abstract class Dart2JsObjectMirror extends Dart2JsElementMirror 459 abstract class Dart2JsObjectMirror extends Dart2JsElementMirror
460 implements ObjectMirror { 460 implements ObjectMirror {
461 Dart2JsObjectMirror(Dart2JsMirrorSystem system, Element element) 461 Dart2JsObjectMirror(Dart2JsMirrorSystem system, Element element)
462 : super(system, element); 462 : super(system, element);
463 } 463 }
464 464
465 class Dart2JsLibraryMirror extends Dart2JsObjectMirror 465 class Dart2JsLibraryMirror extends Dart2JsObjectMirror
466 implements LibraryMirror { 466 implements LibraryMirror {
467 Map<String, InterfaceMirror> _types; 467 Map<String, InterfaceMirror> _types;
468 Map<String, MemberMirror> _members; 468 Map<String, MemberMirror> _members;
469 469
470 Dart2JsLibraryMirror(Dart2JsMirrorSystem system, LibraryElement library) 470 Dart2JsLibraryMirror(Dart2JsMirrorSystem system, LibraryElement library)
471 : super(system, library); 471 : super(system, library);
472 472
473 LibraryElement get _library() => _element; 473 LibraryElement get _library() => _element;
474 474
475 LibraryMirror library() => this; 475 LibraryMirror library() => this;
476 476
477 String get canonicalName() => simpleName(); 477 String get canonicalName() => simpleName;
478 478
479 /** 479 /**
480 * Returns the library name (for libraries with a #library tag) or the script 480 * Returns the library name (for libraries with a #library tag) or the script
481 * file name (for scripts without a #library tag). The latter case is used to 481 * file name (for scripts without a #library tag). The latter case is used to
482 * provide a 'library name' for scripts, to use for instance in dartdoc. 482 * provide a 'library name' for scripts, to use for instance in dartdoc.
483 */ 483 */
484 String simpleName() { 484 String get simpleName() {
485 if (_library.libraryTag !== null) { 485 if (_library.libraryTag !== null) {
486 return _library.libraryTag.argument.dartString.slowToString(); 486 return _library.libraryTag.argument.dartString.slowToString();
487 } else { 487 } else {
488 // Use the file name as script name. 488 // Use the file name as script name.
489 String path = _library.script.uri.path; 489 String path = _library.script.uri.path;
490 return path.substring(path.lastIndexOf('/') + 1); 490 return path.substring(path.lastIndexOf('/') + 1);
491 } 491 }
492 } 492 }
493 493
494 String qualifiedName() => simpleName(); 494 String get qualifiedName() => simpleName;
495 495
496 void _ensureTypes() { 496 void _ensureTypes() {
497 if (_types == null) { 497 if (_types == null) {
498 _types = <InterfaceMirror>{}; 498 _types = <InterfaceMirror>{};
499 _library.forEachExport((Element e) { 499 _library.forEachExport((Element e) {
500 if (e.getLibrary() == _library) { 500 if (e.getLibrary() == _library) {
501 if (e.isClass()) { 501 if (e.isClass()) {
502 e.ensureResolved(system.compiler); 502 e.ensureResolved(system.compiler);
503 var type = new Dart2JsInterfaceMirror.fromLibrary(this, e); 503 var type = new Dart2JsInterfaceMirror.fromLibrary(this, e);
504 _types[type.canonicalName] = type; 504 _types[type.canonicalName] = type;
(...skipping 12 matching lines...) Expand all
517 _library.forEachExport((Element e) { 517 _library.forEachExport((Element e) {
518 if (!e.isClass() && !e.isTypedef()) { 518 if (!e.isClass() && !e.isTypedef()) {
519 for (var member in _convertElementMemberToMemberMirrors(this, e)) { 519 for (var member in _convertElementMemberToMemberMirrors(this, e)) {
520 _members[member.canonicalName] = member; 520 _members[member.canonicalName] = member;
521 } 521 }
522 } 522 }
523 }); 523 });
524 } 524 }
525 } 525 }
526 526
527 Map<Object, MemberMirror> declaredMembers() { 527 Map<Object, MemberMirror> get declaredMembers() {
528 _ensureMembers(); 528 _ensureMembers();
529 return new ImmutableMapWrapper<Object, MemberMirror>(_members); 529 return new ImmutableMapWrapper<Object, MemberMirror>(_members);
530 } 530 }
531 531
532 Map<Object, InterfaceMirror> types() { 532 Map<Object, InterfaceMirror> get types() {
533 _ensureTypes(); 533 _ensureTypes();
534 return new ImmutableMapWrapper<Object, InterfaceMirror>(_types); 534 return new ImmutableMapWrapper<Object, InterfaceMirror>(_types);
535 } 535 }
536 536
537 Location location() { 537 Location get location() {
538 var script = _library.getCompilationUnit().script; 538 var script = _library.getCompilationUnit().script;
539 return new Dart2JsLocation( 539 return new Dart2JsLocation(
540 script, 540 script,
541 new SourceSpan(script.uri, 0, script.text.length)); 541 new SourceSpan(script.uri, 0, script.text.length));
542 } 542 }
543 } 543 }
544 544
545 class Dart2JsLocation implements Location { 545 class Dart2JsLocation implements Location {
546 Script _script; 546 Script _script;
547 SourceSpan _span; 547 SourceSpan _span;
548 548
549 Dart2JsLocation(this._script, this._span); 549 Dart2JsLocation(this._script, this._span);
550 550
551 int start() => _span.begin; 551 int get start() => _span.begin;
552 int end() => _span.end;
553 Source source() => new Dart2JsSource(_script);
554 552
555 String text() => _script.text.substring(start(), end()); 553 int get end() => _span.end;
554
555 Source get source() => new Dart2JsSource(_script);
556
557 String get text() => _script.text.substring(start, end);
556 } 558 }
557 559
558 class Dart2JsSource implements Source { 560 class Dart2JsSource implements Source {
559 Script _script; 561 Script _script;
560 562
561 Dart2JsSource(this._script); 563 Dart2JsSource(this._script);
562 564
563 Uri uri() => _script.uri; 565 Uri get uri() => _script.uri;
564 String text() => _script.text; 566
567 String get text() => _script.text;
565 } 568 }
566 569
567 class Dart2JsParameterMirror extends Dart2JsElementMirror 570 class Dart2JsParameterMirror extends Dart2JsElementMirror
568 implements ParameterMirror { 571 implements ParameterMirror {
569 final MethodMirror _method; 572 final MethodMirror _method;
570 final bool _isOptional; 573 final bool isOptional;
571 574
572 factory Dart2JsParameterMirror(Dart2JsMirrorSystem system, 575 factory Dart2JsParameterMirror(Dart2JsMirrorSystem system,
573 MethodMirror method, 576 MethodMirror method,
574 VariableElement element, 577 VariableElement element,
575 bool isOptional) { 578 bool isOptional) {
576 if (element is FieldParameterElement) { 579 if (element is FieldParameterElement) {
577 return new Dart2JsFieldParameterMirror(system, 580 return new Dart2JsFieldParameterMirror(system,
578 method, element, isOptional); 581 method, element, isOptional);
579 } 582 }
580 return new Dart2JsParameterMirror._normal(system, 583 return new Dart2JsParameterMirror._normal(system,
581 method, element, isOptional); 584 method, element, isOptional);
582 } 585 }
583 586
584 Dart2JsParameterMirror._normal(Dart2JsMirrorSystem system, 587 Dart2JsParameterMirror._normal(Dart2JsMirrorSystem system,
585 this._method, 588 this._method,
586 VariableElement element, 589 VariableElement element,
587 this._isOptional) 590 this.isOptional)
588 : super(system, element); 591 : super(system, element);
589 592
590 VariableElement get _variableElement() => _element; 593 VariableElement get _variableElement() => _element;
591 594
592 String get canonicalName() => simpleName(); 595 String get canonicalName() => simpleName;
593 596
594 String qualifiedName() => '${_method.qualifiedName()}#${simpleName()}'; 597 String get qualifiedName() => '${_method.qualifiedName}#${simpleName}';
595 598
596 TypeMirror type() => _convertTypeToTypeMirror(system, 599 TypeMirror get type() => _convertTypeToTypeMirror(system,
597 _variableElement.computeType(system.compiler), 600 _variableElement.computeType(system.compiler),
598 system.compiler.dynamicClass.computeType(system.compiler), 601 system.compiler.dynamicClass.computeType(system.compiler),
599 _variableElement.variables.functionSignature); 602 _variableElement.variables.functionSignature);
600 603
601 String defaultValue() { 604 String get defaultValue() {
602 if (hasDefaultValue()) { 605 if (hasDefaultValue) {
603 SendSet expression = _variableElement.cachedNode.asSendSet(); 606 SendSet expression = _variableElement.cachedNode.asSendSet();
604 return expression.arguments.head.unparse(); 607 return expression.arguments.head.unparse();
605 } 608 }
606 return null; 609 return null;
607 } 610 }
608 bool hasDefaultValue() { 611 bool get hasDefaultValue() {
609 return _variableElement.cachedNode !== null && 612 return _variableElement.cachedNode !== null &&
610 _variableElement.cachedNode is SendSet; 613 _variableElement.cachedNode is SendSet;
611 } 614 }
612 615
613 bool isOptional() => _isOptional; 616 bool get isInitializingFormal() => false;
614 617
615 bool isInitializingFormal() => false; 618 FieldMirror get initializedField() => null;
616
617 FieldMirror initializedField() => null;
618 } 619 }
619 620
620 class Dart2JsFieldParameterMirror extends Dart2JsParameterMirror { 621 class Dart2JsFieldParameterMirror extends Dart2JsParameterMirror {
621 622
622 Dart2JsFieldParameterMirror(Dart2JsMirrorSystem system, 623 Dart2JsFieldParameterMirror(Dart2JsMirrorSystem system,
623 MethodMirror method, 624 MethodMirror method,
624 FieldParameterElement element, 625 FieldParameterElement element,
625 bool isOptional) 626 bool isOptional)
626 : super._normal(system, method, element, isOptional); 627 : super._normal(system, method, element, isOptional);
627 628
628 FieldParameterElement get _fieldParameterElement() => _element; 629 FieldParameterElement get _fieldParameterElement() => _element;
629 630
630 TypeMirror type() { 631 TypeMirror get type() {
631 if (_fieldParameterElement.variables.cachedNode.type !== null) { 632 if (_fieldParameterElement.variables.cachedNode.type !== null) {
632 return super.type(); 633 return super.type;
633 } 634 }
634 return _convertTypeToTypeMirror(system, 635 return _convertTypeToTypeMirror(system,
635 _fieldParameterElement.fieldElement.computeType(system.compiler), 636 _fieldParameterElement.fieldElement.computeType(system.compiler),
636 system.compiler.dynamicClass.computeType(system.compiler), 637 system.compiler.dynamicClass.computeType(system.compiler),
637 _variableElement.variables.functionSignature); 638 _variableElement.variables.functionSignature);
638 } 639 }
639 640
640 bool isInitializingFormal() => true; 641 bool get isInitializingFormal() => true;
641 642
642 FieldMirror initializedField() => new Dart2JsFieldMirror( 643 FieldMirror get initializedField() => new Dart2JsFieldMirror(
643 _method.surroundingDeclaration(), _fieldParameterElement.fieldElement); 644 _method.surroundingDeclaration, _fieldParameterElement.fieldElement);
644 } 645 }
645 646
646 //------------------------------------------------------------------------------ 647 //------------------------------------------------------------------------------
647 // Declarations 648 // Declarations
648 //------------------------------------------------------------------------------ 649 //------------------------------------------------------------------------------
649 class Dart2JsInterfaceMirror extends Dart2JsObjectMirror 650 class Dart2JsInterfaceMirror extends Dart2JsObjectMirror
650 implements Dart2JsTypeMirror, InterfaceMirror { 651 implements Dart2JsTypeMirror, InterfaceMirror {
651 final Dart2JsLibraryMirror _library; 652 final Dart2JsLibraryMirror library;
652 Map<String, Dart2JsMemberMirror> _members; 653 Map<String, Dart2JsMemberMirror> _members;
653 List<TypeVariableMirror> _typeVariables; 654 List<TypeVariableMirror> _typeVariables;
654 655
655 Dart2JsInterfaceMirror(Dart2JsMirrorSystem system, ClassElement _class) 656 Dart2JsInterfaceMirror(Dart2JsMirrorSystem system, ClassElement _class)
656 : this._library = system.getLibrary(_class.getLibrary()), 657 : this.library = system.getLibrary(_class.getLibrary()),
657 super(system, _class); 658 super(system, _class);
658 659
659 ClassElement get _class() => _element; 660 ClassElement get _class() => _element;
660 661
661 662
662 Dart2JsInterfaceMirror.fromLibrary(Dart2JsLibraryMirror library, 663 Dart2JsInterfaceMirror.fromLibrary(Dart2JsLibraryMirror library,
663 ClassElement _class) 664 ClassElement _class)
664 : this._library = library, 665 : this.library = library,
665 super(library.system, _class); 666 super(library.system, _class);
666 667
667 String get canonicalName() => simpleName(); 668 String get canonicalName() => simpleName;
668 669
669 String qualifiedName() => '${library().qualifiedName()}.${simpleName()}'; 670 String get qualifiedName() => '${library.qualifiedName}.${simpleName}';
670 671
671 Location location() { 672 Location get location() {
672 if (_class is PartialClassElement) { 673 if (_class is PartialClassElement) {
673 var node = _class.parseNode(_diagnosticListener); 674 var node = _class.parseNode(_diagnosticListener);
674 if (node !== null) { 675 if (node !== null) {
675 var script = _class.getCompilationUnit().script; 676 var script = _class.getCompilationUnit().script;
676 var span = system.compiler.spanFromNode(node, script.uri); 677 var span = system.compiler.spanFromNode(node, script.uri);
677 return new Dart2JsLocation(script, span); 678 return new Dart2JsLocation(script, span);
678 } 679 }
679 } 680 }
680 return super.location(); 681 return super.location;
681 } 682 }
682 683
683 void _ensureMembers() { 684 void _ensureMembers() {
684 if (_members == null) { 685 if (_members == null) {
685 _members = <Dart2JsMemberMirror>{}; 686 _members = <Dart2JsMemberMirror>{};
686 _class.constructors.forEach((_, e) { 687 _class.constructors.forEach((_, e) {
687 for (var member in _convertElementMemberToMemberMirrors(this, e)) { 688 for (var member in _convertElementMemberToMemberMirrors(this, e)) {
688 _members[member.canonicalName] = member; 689 _members[member.canonicalName] = member;
689 } 690 }
690 }); 691 });
691 _class.localMembers.forEach((_, e) { 692 _class.localMembers.forEach((_, e) {
692 for (var member in _convertElementMemberToMemberMirrors(this, e)) { 693 for (var member in _convertElementMemberToMemberMirrors(this, e)) {
693 _members[member.canonicalName] = member; 694 _members[member.canonicalName] = member;
694 } 695 }
695 }); 696 });
696 } 697 }
697 } 698 }
698 699
699 Map<Object, MemberMirror> declaredMembers() { 700 Map<Object, MemberMirror> get declaredMembers() {
700 _ensureMembers(); 701 _ensureMembers();
701 return new ImmutableMapWrapper<Object, MemberMirror>(_members); 702 return new ImmutableMapWrapper<Object, MemberMirror>(_members);
702 } 703 }
703 704
704 LibraryMirror library() {
705 return _library;
706 }
707
708 bool get isObject() => _class == system.compiler.objectClass; 705 bool get isObject() => _class == system.compiler.objectClass;
709 706
710 bool get isDynamic() => _class == system.compiler.dynamicClass; 707 bool get isDynamic() => _class == system.compiler.dynamicClass;
711 708
712 bool get isVoid() => false; 709 bool get isVoid() => false;
713 710
714 bool get isTypeVariable() => false; 711 bool get isTypeVariable() => false;
715 712
716 bool get isTypedef() => false; 713 bool get isTypedef() => false;
717 714
718 bool get isFunction() => false; 715 bool get isFunction() => false;
719 716
720 InterfaceMirror get declaration() => this; 717 InterfaceMirror get declaration() => this;
721 718
722 InterfaceMirror superclass() { 719 InterfaceMirror get superclass() {
723 if (_class.supertype != null) { 720 if (_class.supertype != null) {
724 return new Dart2JsInterfaceTypeMirror(system, _class.supertype); 721 return new Dart2JsInterfaceTypeMirror(system, _class.supertype);
725 } 722 }
726 return null; 723 return null;
727 } 724 }
728 725
729 Map<Object, InterfaceMirror> interfaces() { 726 Map<Object, InterfaceMirror> get interfaces() {
730 var map = new Map<String, InterfaceMirror>(); 727 var map = new Map<String, InterfaceMirror>();
731 Link<Type> link = _class.interfaces; 728 Link<Type> link = _class.interfaces;
732 while (!link.isEmpty()) { 729 while (!link.isEmpty()) {
733 var type = _convertTypeToTypeMirror(system, link.head, 730 var type = _convertTypeToTypeMirror(system, link.head,
734 system.compiler.dynamicClass.computeType(system.compiler)); 731 system.compiler.dynamicClass.computeType(system.compiler));
735 map[type.canonicalName] = type; 732 map[type.canonicalName] = type;
736 link = link.tail; 733 link = link.tail;
737 } 734 }
738 return new ImmutableMapWrapper<Object, InterfaceMirror>(map); 735 return new ImmutableMapWrapper<Object, InterfaceMirror>(map);
739 } 736 }
740 737
741 bool get isClass() => !_class.isInterface(); 738 bool get isClass() => !_class.isInterface();
742 739
743 bool get isInterface() => _class.isInterface(); 740 bool get isInterface() => _class.isInterface();
744 741
745 bool get isPrivate() => _isPrivate(simpleName()); 742 bool get isPrivate() => _isPrivate(simpleName);
746 743
747 bool get isDeclaration() => true; 744 bool get isDeclaration() => true;
748 745
749 List<TypeMirror> typeArguments() { 746 List<TypeMirror> get typeArguments() {
750 throw new UnsupportedOperationException( 747 throw new UnsupportedOperationException(
751 'Declarations do not have type arguments'); 748 'Declarations do not have type arguments');
752 } 749 }
753 750
754 List<TypeVariableMirror> typeVariables() { 751 List<TypeVariableMirror> get typeVariables() {
755 if (_typeVariables == null) { 752 if (_typeVariables == null) {
756 _typeVariables = <TypeVariableMirror>[]; 753 _typeVariables = <TypeVariableMirror>[];
757 _class.ensureResolved(system.compiler); 754 _class.ensureResolved(system.compiler);
758 for (TypeVariableType typeVariable in _class.typeVariables) { 755 for (TypeVariableType typeVariable in _class.typeVariables) {
759 _typeVariables.add( 756 _typeVariables.add(
760 new Dart2JsTypeVariableMirror(system, typeVariable)); 757 new Dart2JsTypeVariableMirror(system, typeVariable));
761 } 758 }
762 } 759 }
763 return _typeVariables; 760 return _typeVariables;
764 } 761 }
765 762
766 Map<Object, MethodMirror> constructors() { 763 Map<Object, MethodMirror> get constructors() {
767 _ensureMembers(); 764 _ensureMembers();
768 return new AsFilteredImmutableMap<Object, MemberMirror, MethodMirror>( 765 return new AsFilteredImmutableMap<Object, MemberMirror, MethodMirror>(
769 _members, (m) => m.isConstructor ? m : null); 766 _members, (m) => m.isConstructor ? m : null);
770 } 767 }
771 768
772 /** 769 /**
773 * Returns the default type for this interface. 770 * Returns the default type for this interface.
774 */ 771 */
775 InterfaceMirror defaultType() { 772 InterfaceMirror get defaultType() {
776 if (_class.defaultClass != null) { 773 if (_class.defaultClass != null) {
777 return new Dart2JsInterfaceTypeMirror(system, _class.defaultClass); 774 return new Dart2JsInterfaceTypeMirror(system, _class.defaultClass);
778 } 775 }
779 return null; 776 return null;
780 } 777 }
781 778
782 bool operator ==(Object other) { 779 bool operator ==(Object other) {
783 if (this === other) { 780 if (this === other) {
784 return true; 781 return true;
785 } 782 }
786 if (other is! InterfaceMirror) { 783 if (other is! InterfaceMirror) {
787 return false; 784 return false;
788 } 785 }
789 if (library() != other.library()) { 786 if (library != other.library) {
790 return false; 787 return false;
791 } 788 }
792 if (isDeclaration !== other.isDeclaration) { 789 if (isDeclaration !== other.isDeclaration) {
793 return false; 790 return false;
794 } 791 }
795 return qualifiedName() == other.qualifiedName(); 792 return qualifiedName == other.qualifiedName;
796 } 793 }
797 } 794 }
798 795
799 class Dart2JsTypedefMirror extends Dart2JsElementMirror 796 class Dart2JsTypedefMirror extends Dart2JsElementMirror
800 implements Dart2JsTypeMirror, TypedefMirror { 797 implements Dart2JsTypeMirror, TypedefMirror {
801 final Dart2JsLibraryMirror _library; 798 final Dart2JsLibraryMirror _library;
802 List<TypeVariableMirror> _typeVariables; 799 List<TypeVariableMirror> _typeVariables;
803 TypeMirror _definition; 800 TypeMirror _definition;
804 801
805 Dart2JsTypedefMirror(Dart2JsMirrorSystem system, TypedefElement _typedef) 802 Dart2JsTypedefMirror(Dart2JsMirrorSystem system, TypedefElement _typedef)
806 : this._library = system.getLibrary(_typedef.getLibrary()), 803 : this._library = system.getLibrary(_typedef.getLibrary()),
807 super(system, _typedef); 804 super(system, _typedef);
808 805
809 Dart2JsTypedefMirror.fromLibrary(Dart2JsLibraryMirror library, 806 Dart2JsTypedefMirror.fromLibrary(Dart2JsLibraryMirror library,
810 TypedefElement _typedef) 807 TypedefElement _typedef)
811 : this._library = library, 808 : this._library = library,
812 super(library.system, _typedef); 809 super(library.system, _typedef);
813 810
814 TypedefElement get _typedef() => _element; 811 TypedefElement get _typedef() => _element;
815 812
816 String get canonicalName() => simpleName(); 813 String get canonicalName() => simpleName;
817 814
818 String qualifiedName() => '${library().qualifiedName()}.${simpleName()}'; 815 String get qualifiedName() => '${library.qualifiedName}.${simpleName}';
819 816
820 Location location() { 817 Location get location() {
821 var node = _typedef.parseNode(_diagnosticListener); 818 var node = _typedef.parseNode(_diagnosticListener);
822 if (node !== null) { 819 if (node !== null) {
823 var script = _typedef.getCompilationUnit().script; 820 var script = _typedef.getCompilationUnit().script;
824 var span = system.compiler.spanFromNode(node, script.uri); 821 var span = system.compiler.spanFromNode(node, script.uri);
825 return new Dart2JsLocation(script, span); 822 return new Dart2JsLocation(script, span);
826 } 823 }
827 return super.location(); 824 return super.location;
828 } 825 }
829 826
830 LibraryMirror library() => _library; 827 LibraryMirror get library() => _library;
831 828
832 bool get isObject() => false; 829 bool get isObject() => false;
833 830
834 bool get isDynamic() => false; 831 bool get isDynamic() => false;
835 832
836 bool get isVoid() => false; 833 bool get isVoid() => false;
837 834
838 bool get isTypeVariable() => false; 835 bool get isTypeVariable() => false;
839 836
840 bool get isTypedef() => true; 837 bool get isTypedef() => true;
841 838
842 bool get isFunction() => false; 839 bool get isFunction() => false;
843 840
844 List<TypeMirror> typeArguments() { 841 List<TypeMirror> get typeArguments() {
845 throw new UnsupportedOperationException( 842 throw new UnsupportedOperationException(
846 'Declarations do not have type arguments'); 843 'Declarations do not have type arguments');
847 } 844 }
848 845
849 List<TypeVariableMirror> typeVariables() { 846 List<TypeVariableMirror> get typeVariables() {
850 if (_typeVariables == null) { 847 if (_typeVariables == null) {
851 _typeVariables = <TypeVariableMirror>[]; 848 _typeVariables = <TypeVariableMirror>[];
852 // TODO(johnniwinther): Equip [Typedef] with a [typeParameters] map, just 849 // TODO(johnniwinther): Equip [Typedef] with a [typeParameters] map, just
853 // like [ClassElement]. 850 // like [ClassElement].
854 } 851 }
855 return _typeVariables; 852 return _typeVariables;
856 } 853 }
857 854
858 TypeMirror definition() { 855 TypeMirror get definition() {
859 if (_definition === null) { 856 if (_definition === null) {
860 // TODO(johnniwinther): Provide access to the functionSignature of the 857 // TODO(johnniwinther): Provide access to the functionSignature of the
861 // aliased function definition. 858 // aliased function definition.
862 } 859 }
863 return _definition; 860 return _definition;
864 } 861 }
865 862
866 Map<Object, MemberMirror> declaredMembers() => const <MemberMirror>{}; 863 Map<Object, MemberMirror> get declaredMembers() => const <MemberMirror>{};
867 864
868 InterfaceMirror get declaration() => this; 865 InterfaceMirror get declaration() => this;
869 866
870 // TODO(johnniwinther): How should a typedef respond to these? 867 // TODO(johnniwinther): How should a typedef respond to these?
871 InterfaceMirror superclass() => null; 868 InterfaceMirror get superclass() => null;
872 869
873 Map<Object, InterfaceMirror> interfaces() => const <InterfaceMirror>{}; 870 Map<Object, InterfaceMirror> get interfaces() => const <InterfaceMirror>{};
874 871
875 bool get isClass() => false; 872 bool get isClass() => false;
876 873
877 bool get isInterface() => false; 874 bool get isInterface() => false;
878 875
879 bool get isPrivate() => _isPrivate(simpleName()); 876 bool get isPrivate() => _isPrivate(simpleName);
880 877
881 bool get isDeclaration() => true; 878 bool get isDeclaration() => true;
882 879
883 Map<Object, MethodMirror> constructors() => const <MethodMirror>{}; 880 Map<Object, MethodMirror> get constructors() => const <MethodMirror>{};
884 881
885 InterfaceMirror defaultType() => null; 882 InterfaceMirror get defaultType() => null;
886 } 883 }
887 884
888 class Dart2JsTypeVariableMirror extends Dart2JsTypeElementMirror 885 class Dart2JsTypeVariableMirror extends Dart2JsTypeElementMirror
889 implements TypeVariableMirror { 886 implements TypeVariableMirror {
890 final TypeVariableType _typeVariableType; 887 final TypeVariableType _typeVariableType;
891 InterfaceMirror _declarer; 888 InterfaceMirror _declarer;
892 889
893 Dart2JsTypeVariableMirror(Dart2JsMirrorSystem system, 890 Dart2JsTypeVariableMirror(Dart2JsMirrorSystem system,
894 TypeVariableType typeVariableType) 891 TypeVariableType typeVariableType)
895 : this._typeVariableType = typeVariableType, 892 : this._typeVariableType = typeVariableType,
896 super(system, typeVariableType) { 893 super(system, typeVariableType) {
897 assert(_typeVariableType !== null); 894 assert(_typeVariableType !== null);
898 } 895 }
899 896
900 897
901 String qualifiedName() => '${declarer().qualifiedName()}.${simpleName()}'; 898 String get qualifiedName() => '${declarer.qualifiedName}.${simpleName}';
902 899
903 InterfaceMirror declarer() { 900 InterfaceMirror get declarer() {
904 if (_declarer === null) { 901 if (_declarer === null) {
905 if (_typeVariableType.element.enclosingElement.isClass()) { 902 if (_typeVariableType.element.enclosingElement.isClass()) {
906 _declarer = new Dart2JsInterfaceMirror(system, 903 _declarer = new Dart2JsInterfaceMirror(system,
907 _typeVariableType.element.enclosingElement); 904 _typeVariableType.element.enclosingElement);
908 } else if (_typeVariableType.element.enclosingElement.isTypedef()) { 905 } else if (_typeVariableType.element.enclosingElement.isTypedef()) {
909 _declarer = new Dart2JsTypedefMirror(system, 906 _declarer = new Dart2JsTypedefMirror(system,
910 _typeVariableType.element.enclosingElement); 907 _typeVariableType.element.enclosingElement);
911 } 908 }
912 } 909 }
913 return _declarer; 910 return _declarer;
914 } 911 }
915 912
916 LibraryMirror library() => declarer().library(); 913 LibraryMirror get library() => declarer.library;
917 914
918 bool get isObject() => false; 915 bool get isObject() => false;
919 916
920 bool get isDynamic() => false; 917 bool get isDynamic() => false;
921 918
922 bool get isVoid() => false; 919 bool get isVoid() => false;
923 920
924 bool get isTypeVariable() => true; 921 bool get isTypeVariable() => true;
925 922
926 bool get isTypedef() => false; 923 bool get isTypedef() => false;
927 924
928 bool get isFunction() => false; 925 bool get isFunction() => false;
929 926
930 TypeMirror bound() => _convertTypeToTypeMirror( 927 TypeMirror get bound() => _convertTypeToTypeMirror(
931 system, 928 system,
932 _typeVariableType.element.bound, 929 _typeVariableType.element.bound,
933 system.compiler.objectClass.computeType(system.compiler)); 930 system.compiler.objectClass.computeType(system.compiler));
934 931
935 bool operator ==(Object other) { 932 bool operator ==(Object other) {
936 if (this === other) { 933 if (this === other) {
937 return true; 934 return true;
938 } 935 }
939 if (other is! TypeVariableMirror) { 936 if (other is! TypeVariableMirror) {
940 return false; 937 return false;
941 } 938 }
942 if (declarer() != other.declarer()) { 939 if (declarer != other.declarer) {
943 return false; 940 return false;
944 } 941 }
945 return qualifiedName() == other.qualifiedName(); 942 return qualifiedName == other.qualifiedName;
946 } 943 }
947 } 944 }
948 945
949 946
950 //------------------------------------------------------------------------------ 947 //------------------------------------------------------------------------------
951 // Types 948 // Types
952 //------------------------------------------------------------------------------ 949 //------------------------------------------------------------------------------
953 950
954 abstract class Dart2JsTypeElementMirror extends Dart2JsProxyMirror 951 abstract class Dart2JsTypeElementMirror extends Dart2JsProxyMirror
955 implements Dart2JsTypeMirror { 952 implements Dart2JsTypeMirror {
956 final Type _type; 953 final Type _type;
957 954
958 Dart2JsTypeElementMirror(Dart2JsMirrorSystem system, this._type) 955 Dart2JsTypeElementMirror(Dart2JsMirrorSystem system, this._type)
959 : super(system); 956 : super(system);
960 957
961 String simpleName() => _type.name.slowToString(); 958 String get simpleName() => _type.name.slowToString();
962 959
963 String get canonicalName() => simpleName(); 960 String get canonicalName() => simpleName;
964 961
965 Location location() { 962 Location get location() {
966 var script = _type.element.getCompilationUnit().script; 963 var script = _type.element.getCompilationUnit().script;
967 return new Dart2JsLocation(script, 964 return new Dart2JsLocation(script,
968 system.compiler.spanFromElement(_type.element)); 965 system.compiler.spanFromElement(_type.element));
969 } 966 }
970 967
971 LibraryMirror library() { 968 LibraryMirror get library() {
972 return system.getLibrary(_type.element.getLibrary()); 969 return system.getLibrary(_type.element.getLibrary());
973 } 970 }
974 971
975 String toString() => _type.element.toString(); 972 String toString() => _type.element.toString();
976 } 973 }
977 974
978 class Dart2JsInterfaceTypeMirror extends Dart2JsTypeElementMirror 975 class Dart2JsInterfaceTypeMirror extends Dart2JsTypeElementMirror
979 implements InterfaceMirror { 976 implements InterfaceMirror {
980 List<TypeMirror> _typeArguments; 977 List<TypeMirror> _typeArguments;
981 978
982 Dart2JsInterfaceTypeMirror(Dart2JsMirrorSystem system, 979 Dart2JsInterfaceTypeMirror(Dart2JsMirrorSystem system,
983 InterfaceType interfaceType) 980 InterfaceType interfaceType)
984 : super(system, interfaceType); 981 : super(system, interfaceType);
985 982
986 InterfaceType get _interfaceType() => _type; 983 InterfaceType get _interfaceType() => _type;
987 984
988 String qualifiedName() => declaration.qualifiedName(); 985 String get qualifiedName() => declaration.qualifiedName;
989 986
990 // TODO(johnniwinther): Substitute type arguments for type variables. 987 // TODO(johnniwinther): Substitute type arguments for type variables.
991 Map<Object, MemberMirror> declaredMembers() => declaration.declaredMembers(); 988 Map<Object, MemberMirror> get declaredMembers() => declaration.declaredMembers ;
992 989
993 bool get isObject() => system.compiler.objectClass == _type.element; 990 bool get isObject() => system.compiler.objectClass == _type.element;
994 991
995 bool get isDynamic() => system.compiler.dynamicClass == _type.element; 992 bool get isDynamic() => system.compiler.dynamicClass == _type.element;
996 993
997 bool get isTypeVariable() => false; 994 bool get isTypeVariable() => false;
998 995
999 bool get isVoid() => false; 996 bool get isVoid() => false;
1000 997
1001 bool get isTypedef() => false; 998 bool get isTypedef() => false;
1002 999
1003 bool get isFunction() => false; 1000 bool get isFunction() => false;
1004 1001
1005 InterfaceMirror get declaration() 1002 InterfaceMirror get declaration()
1006 => new Dart2JsInterfaceMirror(system, _type.element); 1003 => new Dart2JsInterfaceMirror(system, _type.element);
1007 1004
1008 // TODO(johnniwinther): Substitute type arguments for type variables. 1005 // TODO(johnniwinther): Substitute type arguments for type variables.
1009 InterfaceMirror superclass() => declaration.superclass(); 1006 InterfaceMirror get superclass() => declaration.superclass;
1010 1007
1011 // TODO(johnniwinther): Substitute type arguments for type variables. 1008 // TODO(johnniwinther): Substitute type arguments for type variables.
1012 Map<Object, InterfaceMirror> interfaces() => declaration.interfaces(); 1009 Map<Object, InterfaceMirror> get interfaces() => declaration.interfaces;
1013 1010
1014 bool get isClass() => declaration.isClass; 1011 bool get isClass() => declaration.isClass;
1015 1012
1016 bool get isInterface() => declaration.isInterface; 1013 bool get isInterface() => declaration.isInterface;
1017 1014
1018 bool get isPrivate() => declaration.isPrivate; 1015 bool get isPrivate() => declaration.isPrivate;
1019 1016
1020 bool get isDeclaration() => false; 1017 bool get isDeclaration() => false;
1021 1018
1022 List<TypeMirror> typeArguments() { 1019 List<TypeMirror> get typeArguments() {
1023 if (_typeArguments == null) { 1020 if (_typeArguments == null) {
1024 _typeArguments = <TypeMirror>[]; 1021 _typeArguments = <TypeMirror>[];
1025 Link<Type> type = _interfaceType.arguments; 1022 Link<Type> type = _interfaceType.arguments;
1026 while (type != null && type.head != null) { 1023 while (type != null && type.head != null) {
1027 _typeArguments.add(_convertTypeToTypeMirror(system, type.head, 1024 _typeArguments.add(_convertTypeToTypeMirror(system, type.head,
1028 system.compiler.dynamicClass.computeType(system.compiler))); 1025 system.compiler.dynamicClass.computeType(system.compiler)));
1029 type = type.tail; 1026 type = type.tail;
1030 } 1027 }
1031 } 1028 }
1032 return _typeArguments; 1029 return _typeArguments;
1033 } 1030 }
1034 1031
1035 List<TypeVariableMirror> typeVariables() => declaration.typeVariables(); 1032 List<TypeVariableMirror> get typeVariables() => declaration.typeVariables;
1036 1033
1037 // TODO(johnniwinther): Substitute type arguments for type variables. 1034 // TODO(johnniwinther): Substitute type arguments for type variables.
1038 Map<Object, MethodMirror> constructors() => declaration.constructors(); 1035 Map<Object, MethodMirror> get constructors() => declaration.constructors;
1039 1036
1040 // TODO(johnniwinther): Substitute type arguments for type variables? 1037 // TODO(johnniwinther): Substitute type arguments for type variables?
1041 InterfaceMirror defaultType() => declaration.defaultType(); 1038 InterfaceMirror get defaultType() => declaration.defaultType;
1042 1039
1043 bool operator ==(Object other) { 1040 bool operator ==(Object other) {
1044 if (this === other) { 1041 if (this === other) {
1045 return true; 1042 return true;
1046 } 1043 }
1047 if (other is! InterfaceMirror) { 1044 if (other is! InterfaceMirror) {
1048 return false; 1045 return false;
1049 } 1046 }
1050 if (other.isDeclaration) { 1047 if (other.isDeclaration) {
1051 return false; 1048 return false;
1052 } 1049 }
1053 if (declaration != other.declaration) { 1050 if (declaration != other.declaration) {
1054 return false; 1051 return false;
1055 } 1052 }
1056 var thisTypeArguments = typeArguments().iterator(); 1053 var thisTypeArguments = typeArguments.iterator();
1057 var otherTypeArguments = other.typeArguments().iterator(); 1054 var otherTypeArguments = other.typeArguments.iterator();
1058 while (thisTypeArguments.hasNext() && otherTypeArguments.hasNext()) { 1055 while (thisTypeArguments.hasNext() && otherTypeArguments.hasNext()) {
1059 if (thisTypeArguments.next() != otherTypeArguments.next()) { 1056 if (thisTypeArguments.next() != otherTypeArguments.next()) {
1060 return false; 1057 return false;
1061 } 1058 }
1062 } 1059 }
1063 return !thisTypeArguments.hasNext() && !otherTypeArguments.hasNext(); 1060 return !thisTypeArguments.hasNext() && !otherTypeArguments.hasNext();
1064 } 1061 }
1065 } 1062 }
1066 1063
1067 1064
1068 class Dart2JsFunctionTypeMirror extends Dart2JsTypeElementMirror 1065 class Dart2JsFunctionTypeMirror extends Dart2JsTypeElementMirror
1069 implements FunctionTypeMirror { 1066 implements FunctionTypeMirror {
1070 final FunctionSignature _functionSignature; 1067 final FunctionSignature _functionSignature;
1071 List<ParameterMirror> _parameters; 1068 List<ParameterMirror> _parameters;
1072 1069
1073 Dart2JsFunctionTypeMirror(Dart2JsMirrorSystem system, 1070 Dart2JsFunctionTypeMirror(Dart2JsMirrorSystem system,
1074 FunctionType functionType, this._functionSignature) 1071 FunctionType functionType, this._functionSignature)
1075 : super(system, functionType) { 1072 : super(system, functionType) {
1076 assert (_functionSignature !== null); 1073 assert (_functionSignature !== null);
1077 } 1074 }
1078 1075
1079 FunctionType get _functionType() => _type; 1076 FunctionType get _functionType() => _type;
1080 1077
1081 // TODO(johnniwinther): Is this the qualified name of a function type? 1078 // TODO(johnniwinther): Is this the qualified name of a function type?
1082 String qualifiedName() => declaration.qualifiedName(); 1079 String get qualifiedName() => declaration.qualifiedName;
1083 1080
1084 // TODO(johnniwinther): Substitute type arguments for type variables. 1081 // TODO(johnniwinther): Substitute type arguments for type variables.
1085 Map<Object, MemberMirror> declaredMembers() { 1082 Map<Object, MemberMirror> get declaredMembers() {
1086 var method = callMethod(); 1083 var method = callMethod;
1087 if (method !== null) { 1084 if (method !== null) {
1088 var map = new Map<String, MemberMirror>.from( 1085 var map = new Map<String, MemberMirror>.from(
1089 declaration.declaredMembers()); 1086 declaration.declaredMembers);
1090 var name = method.qualifiedName(); 1087 var name = method.qualifiedName;
1091 map[name] = method; 1088 map[name] = method;
1092 Function func = null; 1089 Function func = null;
1093 return new ImmutableMapWrapper<Object, MemberMirror>(map); 1090 return new ImmutableMapWrapper<Object, MemberMirror>(map);
1094 } 1091 }
1095 return declaration.declaredMembers(); 1092 return declaration.declaredMembers;
1096 } 1093 }
1097 1094
1098 bool get isObject() => system.compiler.objectClass == _type.element; 1095 bool get isObject() => system.compiler.objectClass == _type.element;
1099 1096
1100 bool get isDynamic() => system.compiler.dynamicClass == _type.element; 1097 bool get isDynamic() => system.compiler.dynamicClass == _type.element;
1101 1098
1102 bool get isVoid() => false; 1099 bool get isVoid() => false;
1103 1100
1104 bool get isTypeVariable() => false; 1101 bool get isTypeVariable() => false;
1105 1102
1106 bool get isTypedef() => false; 1103 bool get isTypedef() => false;
1107 1104
1108 bool get isFunction() => true; 1105 bool get isFunction() => true;
1109 1106
1110 MethodMirror callMethod() => _convertElementMethodToMethodMirror( 1107 MethodMirror get callMethod() => _convertElementMethodToMethodMirror(
1111 system.getLibrary(_functionType.element.getLibrary()), 1108 system.getLibrary(_functionType.element.getLibrary()),
1112 _functionType.element); 1109 _functionType.element);
1113 1110
1114 InterfaceMirror get declaration() 1111 InterfaceMirror get declaration()
1115 => new Dart2JsInterfaceMirror(system, system.compiler.functionClass); 1112 => new Dart2JsInterfaceMirror(system, system.compiler.functionClass);
1116 1113
1117 // TODO(johnniwinther): Substitute type arguments for type variables. 1114 // TODO(johnniwinther): Substitute type arguments for type variables.
1118 InterfaceMirror superclass() => declaration.superclass(); 1115 InterfaceMirror get superclass() => declaration.superclass;
1119 1116
1120 // TODO(johnniwinther): Substitute type arguments for type variables. 1117 // TODO(johnniwinther): Substitute type arguments for type variables.
1121 Map<Object, InterfaceMirror> interfaces() => declaration.interfaces(); 1118 Map<Object, InterfaceMirror> get interfaces() => declaration.interfaces;
1122 1119
1123 bool get isClass() => declaration.isClass; 1120 bool get isClass() => declaration.isClass;
1124 1121
1125 bool get isInterface() => declaration.isInterface; 1122 bool get isInterface() => declaration.isInterface;
1126 1123
1127 bool get isPrivate() => declaration.isPrivate; 1124 bool get isPrivate() => declaration.isPrivate;
1128 1125
1129 bool get isDeclaration() => false; 1126 bool get isDeclaration() => false;
1130 1127
1131 List<TypeMirror> typeArguments() => const <TypeMirror>[]; 1128 List<TypeMirror> get typeArguments() => const <TypeMirror>[];
1132 1129
1133 List<TypeVariableMirror> typeVariables() => declaration.typeVariables(); 1130 List<TypeVariableMirror> get typeVariables() => declaration.typeVariables;
1134 1131
1135 Map<Object, MethodMirror> constructors() => <MethodMirror>{}; 1132 Map<Object, MethodMirror> get constructors() => <MethodMirror>{};
1136 1133
1137 InterfaceMirror defaultType() => null; 1134 InterfaceMirror get defaultType() => null;
1138 1135
1139 TypeMirror returnType() { 1136 TypeMirror get returnType() {
1140 return _convertTypeToTypeMirror(system, _functionType.returnType, 1137 return _convertTypeToTypeMirror(system, _functionType.returnType,
1141 system.compiler.dynamicClass.computeType(system.compiler)); 1138 system.compiler.dynamicClass.computeType(system.compiler));
1142 } 1139 }
1143 1140
1144 List<ParameterMirror> parameters() { 1141 List<ParameterMirror> get parameters() {
1145 if (_parameters === null) { 1142 if (_parameters === null) {
1146 _parameters = _parametersFromFunctionSignature(system, callMethod(), 1143 _parameters = _parametersFromFunctionSignature(system, callMethod,
1147 _functionSignature); 1144 _functionSignature);
1148 } 1145 }
1149 return _parameters; 1146 return _parameters;
1150 } 1147 }
1151 } 1148 }
1152 1149
1153 class Dart2JsVoidMirror extends Dart2JsTypeElementMirror { 1150 class Dart2JsVoidMirror extends Dart2JsTypeElementMirror {
1154 1151
1155 Dart2JsVoidMirror(Dart2JsMirrorSystem system, VoidType voidType) 1152 Dart2JsVoidMirror(Dart2JsMirrorSystem system, VoidType voidType)
1156 : super(system, voidType); 1153 : super(system, voidType);
1157 1154
1158 VoidType get _voidType() => _type; 1155 VoidType get _voidType() => _type;
1159 1156
1160 String qualifiedName() => simpleName(); 1157 String get qualifiedName() => simpleName;
1161 1158
1162 /** 1159 /**
1163 * The void type has no location. 1160 * The void type has no location.
1164 */ 1161 */
1165 Location location() => null; 1162 Location get location() => null;
1166 1163
1167 /** 1164 /**
1168 * The void type has no library. 1165 * The void type has no library.
1169 */ 1166 */
1170 LibraryMirror getLibrary() => null; 1167 LibraryMirror get library() => null;
1171 1168
1172 bool get isObject() => false; 1169 bool get isObject() => false;
1173 1170
1174 bool get isVoid() => true; 1171 bool get isVoid() => true;
1175 1172
1176 bool get isDynamic() => false; 1173 bool get isDynamic() => false;
1177 1174
1178 bool get isTypeVariable() => false; 1175 bool get isTypeVariable() => false;
1179 1176
1180 bool get isTypedef() => false; 1177 bool get isTypedef() => false;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 _canonicalName = _name; 1253 _canonicalName = _name;
1257 } else if (kind == Dart2JsMethodKind.SETTER) { 1254 } else if (kind == Dart2JsMethodKind.SETTER) {
1258 _canonicalName = '$_name='; 1255 _canonicalName = '$_name=';
1259 } else { 1256 } else {
1260 assert(false); 1257 assert(false);
1261 } 1258 }
1262 } 1259 }
1263 1260
1264 FunctionElement get _function() => _element; 1261 FunctionElement get _function() => _element;
1265 1262
1266 String simpleName() => _name; 1263 String get simpleName() => _name;
1267 1264
1268 String qualifiedName() 1265 String get qualifiedName()
1269 => '${surroundingDeclaration().qualifiedName()}.$canonicalName'; 1266 => '${surroundingDeclaration.qualifiedName}.$canonicalName';
1270 1267
1271 String get canonicalName() => _canonicalName; 1268 String get canonicalName() => _canonicalName;
1272 1269
1273 ObjectMirror surroundingDeclaration() => _objectMirror; 1270 ObjectMirror get surroundingDeclaration() => _objectMirror;
1274 1271
1275 bool get isTopLevel() => _objectMirror is LibraryMirror; 1272 bool get isTopLevel() => _objectMirror is LibraryMirror;
1276 1273
1277 bool get isConstructor() 1274 bool get isConstructor()
1278 => _kind == Dart2JsMethodKind.CONSTRUCTOR || isConst || isFactory; 1275 => _kind == Dart2JsMethodKind.CONSTRUCTOR || isConst || isFactory;
1279 1276
1280 bool get isField() => false; 1277 bool get isField() => false;
1281 1278
1282 bool get isMethod() => !isConstructor; 1279 bool get isMethod() => !isConstructor;
1283 1280
1284 bool get isPrivate() => _isPrivate(simpleName()); 1281 bool get isPrivate() => _isPrivate(simpleName);
1285 1282
1286 bool get isStatic() => 1283 bool get isStatic() =>
1287 _function.modifiers !== null && _function.modifiers.isStatic(); 1284 _function.modifiers !== null && _function.modifiers.isStatic();
1288 1285
1289 List<ParameterMirror> parameters() { 1286 List<ParameterMirror> get parameters() {
1290 return _parametersFromFunctionSignature(system, this, 1287 return _parametersFromFunctionSignature(system, this,
1291 _function.computeSignature(system.compiler)); 1288 _function.computeSignature(system.compiler));
1292 } 1289 }
1293 1290
1294 TypeMirror returnType() => _convertTypeToTypeMirror( 1291 TypeMirror get returnType() => _convertTypeToTypeMirror(
1295 system, _function.computeSignature(system.compiler).returnType, 1292 system, _function.computeSignature(system.compiler).returnType,
1296 system.compiler.dynamicClass.computeType(system.compiler)); 1293 system.compiler.dynamicClass.computeType(system.compiler));
1297 1294
1298 bool get isConst() => _kind == Dart2JsMethodKind.CONST; 1295 bool get isConst() => _kind == Dart2JsMethodKind.CONST;
1299 1296
1300 bool get isFactory() => _kind == Dart2JsMethodKind.FACTORY; 1297 bool get isFactory() => _kind == Dart2JsMethodKind.FACTORY;
1301 1298
1302 String get constructorName() => _constructorName; 1299 String get constructorName() => _constructorName;
1303 1300
1304 bool get isGetter() => _kind == Dart2JsMethodKind.GETTER; 1301 bool get isGetter() => _kind == Dart2JsMethodKind.GETTER;
1305 1302
1306 bool get isSetter() => _kind == Dart2JsMethodKind.SETTER; 1303 bool get isSetter() => _kind == Dart2JsMethodKind.SETTER;
1307 1304
1308 bool get isOperator() => _kind == Dart2JsMethodKind.OPERATOR; 1305 bool get isOperator() => _kind == Dart2JsMethodKind.OPERATOR;
1309 1306
1310 String get operatorName() => _operatorName; 1307 String get operatorName() => _operatorName;
1311 1308
1312 Location location() { 1309 Location get location() {
1313 var node = _function.parseNode(_diagnosticListener); 1310 var node = _function.parseNode(_diagnosticListener);
1314 if (node !== null) { 1311 if (node !== null) {
1315 var script = _function.getCompilationUnit().script; 1312 var script = _function.getCompilationUnit().script;
1316 var span = system.compiler.spanFromNode(node, script.uri); 1313 var span = system.compiler.spanFromNode(node, script.uri);
1317 return new Dart2JsLocation(script, span); 1314 return new Dart2JsLocation(script, span);
1318 } 1315 }
1319 return super.location(); 1316 return super.location;
1320 } 1317 }
1321 1318
1322 } 1319 }
1323 1320
1324 class Dart2JsFieldMirror extends Dart2JsElementMirror 1321 class Dart2JsFieldMirror extends Dart2JsElementMirror
1325 implements Dart2JsMemberMirror, FieldMirror { 1322 implements Dart2JsMemberMirror, FieldMirror {
1326 Dart2JsObjectMirror _objectMirror; 1323 Dart2JsObjectMirror _objectMirror;
1327 VariableElement _variable; 1324 VariableElement _variable;
1328 1325
1329 Dart2JsFieldMirror(Dart2JsObjectMirror objectMirror, 1326 Dart2JsFieldMirror(Dart2JsObjectMirror objectMirror,
1330 VariableElement variable) 1327 VariableElement variable)
1331 : this._objectMirror = objectMirror, 1328 : this._objectMirror = objectMirror,
1332 this._variable = variable, 1329 this._variable = variable,
1333 super(objectMirror.system, variable); 1330 super(objectMirror.system, variable);
1334 1331
1335 String qualifiedName() 1332 String get qualifiedName()
1336 => '${surroundingDeclaration().qualifiedName()}.$canonicalName'; 1333 => '${surroundingDeclaration.qualifiedName}.$canonicalName';
1337 1334
1338 String get canonicalName() => simpleName(); 1335 String get canonicalName() => simpleName;
1339 1336
1340 ObjectMirror surroundingDeclaration() => _objectMirror; 1337 ObjectMirror get surroundingDeclaration() => _objectMirror;
1341 1338
1342 bool get isTopLevel() => _objectMirror is LibraryMirror; 1339 bool get isTopLevel() => _objectMirror is LibraryMirror;
1343 1340
1344 bool get isConstructor() => false; 1341 bool get isConstructor() => false;
1345 1342
1346 bool get isField() => true; 1343 bool get isField() => true;
1347 1344
1348 bool get isMethod() => false; 1345 bool get isMethod() => false;
1349 1346
1350 bool get isPrivate() => _isPrivate(simpleName()); 1347 bool get isPrivate() => _isPrivate(simpleName);
1351 1348
1352 bool get isStatic() => _variable.modifiers.isStatic(); 1349 bool get isStatic() => _variable.modifiers.isStatic();
1353 1350
1354 bool get isFinal() => _variable.modifiers.isFinal(); 1351 bool get isFinal() => _variable.modifiers.isFinal();
1355 1352
1356 TypeMirror type() => _convertTypeToTypeMirror(system, 1353 TypeMirror get type() => _convertTypeToTypeMirror(system,
1357 _variable.computeType(system.compiler), 1354 _variable.computeType(system.compiler),
1358 system.compiler.dynamicClass.computeType(system.compiler)); 1355 system.compiler.dynamicClass.computeType(system.compiler));
1359 1356
1360 Location location() { 1357 Location get location() {
1361 var script = _variable.getCompilationUnit().script; 1358 var script = _variable.getCompilationUnit().script;
1362 var node = _variable.variables.parseNode(_diagnosticListener); 1359 var node = _variable.variables.parseNode(_diagnosticListener);
1363 if (node !== null) { 1360 if (node !== null) {
1364 var span = system.compiler.spanFromNode(node, script.uri); 1361 var span = system.compiler.spanFromNode(node, script.uri);
1365 return new Dart2JsLocation(script, span); 1362 return new Dart2JsLocation(script, span);
1366 } else { 1363 } else {
1367 var span = system.compiler.spanFromElement(_variable); 1364 var span = system.compiler.spanFromElement(_variable);
1368 return new Dart2JsLocation(script, span); 1365 return new Dart2JsLocation(script, span);
1369 } 1366 }
1370 } 1367 }
1371 } 1368 }
1372 1369
OLDNEW
« no previous file with comments | « lib/dartdoc/dartdoc.dart ('k') | lib/dartdoc/mirrors/mirrors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698