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

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

Issue 10823390: Full typedef support in dartdoc. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removed null check 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
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('../../../lib/compiler/compiler.dart', prefix: 'diagnostics'); 7 #import('../../../lib/compiler/compiler.dart', prefix: 'diagnostics');
8 #import('../../../lib/compiler/implementation/elements/elements.dart'); 8 #import('../../../lib/compiler/implementation/elements/elements.dart');
9 #import('../../../lib/compiler/implementation/apiimpl.dart', prefix: 'api'); 9 #import('../../../lib/compiler/implementation/apiimpl.dart', prefix: 'api');
10 #import('../../../lib/compiler/implementation/scanner/scannerlib.dart'); 10 #import('../../../lib/compiler/implementation/scanner/scannerlib.dart');
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 : super(system, element); 587 : super(system, element);
588 588
589 VariableElement get _variableElement() => _element; 589 VariableElement get _variableElement() => _element;
590 590
591 String get canonicalName() => simpleName; 591 String get canonicalName() => simpleName;
592 592
593 String get qualifiedName() => '${_method.qualifiedName}#${simpleName}'; 593 String get qualifiedName() => '${_method.qualifiedName}#${simpleName}';
594 594
595 TypeMirror get type() => _convertTypeToTypeMirror(system, 595 TypeMirror get type() => _convertTypeToTypeMirror(system,
596 _variableElement.computeType(system.compiler), 596 _variableElement.computeType(system.compiler),
597 system.compiler.dynamicClass.computeType(system.compiler), 597 system.compiler.types.dynamicType,
598 _variableElement.variables.functionSignature); 598 _variableElement.variables.functionSignature);
599 599
600 String get defaultValue() { 600 String get defaultValue() {
601 if (hasDefaultValue) { 601 if (hasDefaultValue) {
602 SendSet expression = _variableElement.cachedNode.asSendSet(); 602 SendSet expression = _variableElement.cachedNode.asSendSet();
603 return expression.arguments.head.unparse(); 603 return expression.arguments.head.unparse();
604 } 604 }
605 return null; 605 return null;
606 } 606 }
607 bool get hasDefaultValue() { 607 bool get hasDefaultValue() {
(...skipping 15 matching lines...) Expand all
623 : super._normal(system, method, element, isOptional); 623 : super._normal(system, method, element, isOptional);
624 624
625 FieldParameterElement get _fieldParameterElement() => _element; 625 FieldParameterElement get _fieldParameterElement() => _element;
626 626
627 TypeMirror get type() { 627 TypeMirror get type() {
628 if (_fieldParameterElement.variables.cachedNode.type !== null) { 628 if (_fieldParameterElement.variables.cachedNode.type !== null) {
629 return super.type; 629 return super.type;
630 } 630 }
631 return _convertTypeToTypeMirror(system, 631 return _convertTypeToTypeMirror(system,
632 _fieldParameterElement.fieldElement.computeType(system.compiler), 632 _fieldParameterElement.fieldElement.computeType(system.compiler),
633 system.compiler.dynamicClass.computeType(system.compiler), 633 system.compiler.types.dynamicType,
634 _variableElement.variables.functionSignature); 634 _variableElement.variables.functionSignature);
635 } 635 }
636 636
637 bool get isInitializingFormal() => true; 637 bool get isInitializingFormal() => true;
638 638
639 FieldMirror get initializedField() => new Dart2JsFieldMirror( 639 FieldMirror get initializedField() => new Dart2JsFieldMirror(
640 _method.surroundingDeclaration, _fieldParameterElement.fieldElement); 640 _method.surroundingDeclaration, _fieldParameterElement.fieldElement);
641 } 641 }
642 642
643 //------------------------------------------------------------------------------ 643 //------------------------------------------------------------------------------
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 return new Dart2JsInterfaceTypeMirror(system, _class.supertype); 712 return new Dart2JsInterfaceTypeMirror(system, _class.supertype);
713 } 713 }
714 return null; 714 return null;
715 } 715 }
716 716
717 Map<Object, InterfaceMirror> get interfaces() { 717 Map<Object, InterfaceMirror> get interfaces() {
718 var map = new Map<String, InterfaceMirror>(); 718 var map = new Map<String, InterfaceMirror>();
719 Link<Type> link = _class.interfaces; 719 Link<Type> link = _class.interfaces;
720 while (!link.isEmpty()) { 720 while (!link.isEmpty()) {
721 var type = _convertTypeToTypeMirror(system, link.head, 721 var type = _convertTypeToTypeMirror(system, link.head,
722 system.compiler.dynamicClass.computeType(system.compiler)); 722 system.compiler.types.dynamicType);
723 map[type.canonicalName] = type; 723 map[type.canonicalName] = type;
724 link = link.tail; 724 link = link.tail;
725 } 725 }
726 return new ImmutableMapWrapper<Object, InterfaceMirror>(map); 726 return new ImmutableMapWrapper<Object, InterfaceMirror>(map);
727 } 727 }
728 728
729 bool get isClass() => !_class.isInterface(); 729 bool get isClass() => !_class.isInterface();
730 730
731 bool get isInterface() => _class.isInterface(); 731 bool get isInterface() => _class.isInterface();
732 732
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 bool get isFunction() => false; 830 bool get isFunction() => false;
831 831
832 List<TypeMirror> get typeArguments() { 832 List<TypeMirror> get typeArguments() {
833 throw new UnsupportedOperationException( 833 throw new UnsupportedOperationException(
834 'Declarations do not have type arguments'); 834 'Declarations do not have type arguments');
835 } 835 }
836 836
837 List<TypeVariableMirror> get typeVariables() { 837 List<TypeVariableMirror> get typeVariables() {
838 if (_typeVariables == null) { 838 if (_typeVariables == null) {
839 _typeVariables = <TypeVariableMirror>[]; 839 _typeVariables = <TypeVariableMirror>[];
840 // TODO(johnniwinther): Equip [Typedef] with a [typeParameters] map, just 840 for (TypeVariableType typeVariable in _typedef.typeArguments) {
841 // like [ClassElement]. 841 _typeVariables.add(
842 new Dart2JsTypeVariableMirror(system, typeVariable));
843 }
842 } 844 }
843 return _typeVariables; 845 return _typeVariables;
844 } 846 }
845 847
846 TypeMirror get definition() { 848 TypeMirror get definition() {
847 if (_definition === null) { 849 if (_definition === null) {
848 // TODO(johnniwinther): Provide access to the functionSignature of the 850 _definition = _convertTypeToTypeMirror(
849 // aliased function definition. 851 system,
852 _typedef.unalias(system.compiler),
ahe 2012/08/21 08:50:28 Why do you unalias here?
Johnni Winther 2012/08/21 09:30:27 Duh! Should be _typedef.element.alias.
853 system.compiler.types.dynamicType,
854 _typedef.element.functionSignature);
850 } 855 }
851 return _definition; 856 return _definition;
852 } 857 }
853 858
854 Map<Object, MemberMirror> get declaredMembers() => 859 Map<Object, MemberMirror> get declaredMembers() =>
855 const <String, MemberMirror>{}; 860 const <String, MemberMirror>{};
856 861
857 InterfaceMirror get declaration() => this; 862 InterfaceMirror get declaration() => this;
858 863
859 // TODO(johnniwinther): How should a typedef respond to these? 864 // TODO(johnniwinther): How should a typedef respond to these?
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 bool get isPrivate() => declaration.isPrivate; 1015 bool get isPrivate() => declaration.isPrivate;
1011 1016
1012 bool get isDeclaration() => false; 1017 bool get isDeclaration() => false;
1013 1018
1014 List<TypeMirror> get typeArguments() { 1019 List<TypeMirror> get typeArguments() {
1015 if (_typeArguments == null) { 1020 if (_typeArguments == null) {
1016 _typeArguments = <TypeMirror>[]; 1021 _typeArguments = <TypeMirror>[];
1017 Link<Type> type = _interfaceType.arguments; 1022 Link<Type> type = _interfaceType.arguments;
1018 while (type != null && type.head != null) { 1023 while (type != null && type.head != null) {
1019 _typeArguments.add(_convertTypeToTypeMirror(system, type.head, 1024 _typeArguments.add(_convertTypeToTypeMirror(system, type.head,
1020 system.compiler.dynamicClass.computeType(system.compiler))); 1025 system.compiler.types.dynamicType));
1021 type = type.tail; 1026 type = type.tail;
1022 } 1027 }
1023 } 1028 }
1024 return _typeArguments; 1029 return _typeArguments;
1025 } 1030 }
1026 1031
1027 List<TypeVariableMirror> get typeVariables() => declaration.typeVariables; 1032 List<TypeVariableMirror> get typeVariables() => declaration.typeVariables;
1028 1033
1029 // TODO(johnniwinther): Substitute type arguments for type variables. 1034 // TODO(johnniwinther): Substitute type arguments for type variables.
1030 Map<Object, MethodMirror> get constructors() => declaration.constructors; 1035 Map<Object, MethodMirror> get constructors() => declaration.constructors;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1124 1129
1125 List<TypeVariableMirror> get typeVariables() => declaration.typeVariables; 1130 List<TypeVariableMirror> get typeVariables() => declaration.typeVariables;
1126 1131
1127 Map<Object, MethodMirror> get constructors() => 1132 Map<Object, MethodMirror> get constructors() =>
1128 <String, MethodMirror>{}; 1133 <String, MethodMirror>{};
1129 1134
1130 InterfaceMirror get defaultType() => null; 1135 InterfaceMirror get defaultType() => null;
1131 1136
1132 TypeMirror get returnType() { 1137 TypeMirror get returnType() {
1133 return _convertTypeToTypeMirror(system, _functionType.returnType, 1138 return _convertTypeToTypeMirror(system, _functionType.returnType,
1134 system.compiler.dynamicClass.computeType(system.compiler)); 1139 system.compiler.types.dynamicType);
1135 } 1140 }
1136 1141
1137 List<ParameterMirror> get parameters() { 1142 List<ParameterMirror> get parameters() {
1138 if (_parameters === null) { 1143 if (_parameters === null) {
1139 _parameters = _parametersFromFunctionSignature(system, callMethod, 1144 _parameters = _parametersFromFunctionSignature(system, callMethod,
1140 _functionSignature); 1145 _functionSignature);
1141 } 1146 }
1142 return _parameters; 1147 return _parameters;
1143 } 1148 }
1144 } 1149 }
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1279 bool get isStatic() => 1284 bool get isStatic() =>
1280 _function.modifiers !== null && _function.modifiers.isStatic(); 1285 _function.modifiers !== null && _function.modifiers.isStatic();
1281 1286
1282 List<ParameterMirror> get parameters() { 1287 List<ParameterMirror> get parameters() {
1283 return _parametersFromFunctionSignature(system, this, 1288 return _parametersFromFunctionSignature(system, this,
1284 _function.computeSignature(system.compiler)); 1289 _function.computeSignature(system.compiler));
1285 } 1290 }
1286 1291
1287 TypeMirror get returnType() => _convertTypeToTypeMirror( 1292 TypeMirror get returnType() => _convertTypeToTypeMirror(
1288 system, _function.computeSignature(system.compiler).returnType, 1293 system, _function.computeSignature(system.compiler).returnType,
1289 system.compiler.dynamicClass.computeType(system.compiler)); 1294 system.compiler.types.dynamicType);
1290 1295
1291 bool get isConst() => _kind == Dart2JsMethodKind.CONST; 1296 bool get isConst() => _kind == Dart2JsMethodKind.CONST;
1292 1297
1293 bool get isFactory() => _kind == Dart2JsMethodKind.FACTORY; 1298 bool get isFactory() => _kind == Dart2JsMethodKind.FACTORY;
1294 1299
1295 String get constructorName() => _constructorName; 1300 String get constructorName() => _constructorName;
1296 1301
1297 bool get isGetter() => _kind == Dart2JsMethodKind.GETTER; 1302 bool get isGetter() => _kind == Dart2JsMethodKind.GETTER;
1298 1303
1299 bool get isSetter() => _kind == Dart2JsMethodKind.SETTER; 1304 bool get isSetter() => _kind == Dart2JsMethodKind.SETTER;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1346 bool get isMethod() => false; 1351 bool get isMethod() => false;
1347 1352
1348 bool get isPrivate() => _isPrivate(simpleName); 1353 bool get isPrivate() => _isPrivate(simpleName);
1349 1354
1350 bool get isStatic() => _variable.modifiers.isStatic(); 1355 bool get isStatic() => _variable.modifiers.isStatic();
1351 1356
1352 bool get isFinal() => _variable.modifiers.isFinal(); 1357 bool get isFinal() => _variable.modifiers.isFinal();
1353 1358
1354 TypeMirror get type() => _convertTypeToTypeMirror(system, 1359 TypeMirror get type() => _convertTypeToTypeMirror(system,
1355 _variable.computeType(system.compiler), 1360 _variable.computeType(system.compiler),
1356 system.compiler.dynamicClass.computeType(system.compiler)); 1361 system.compiler.types.dynamicType);
1357 1362
1358 Location get location() { 1363 Location get location() {
1359 var script = _variable.getCompilationUnit().script; 1364 var script = _variable.getCompilationUnit().script;
1360 var node = _variable.variables.parseNode(_diagnosticListener); 1365 var node = _variable.variables.parseNode(_diagnosticListener);
1361 if (node !== null) { 1366 if (node !== null) {
1362 var span = system.compiler.spanFromNode(node, script.uri); 1367 var span = system.compiler.spanFromNode(node, script.uri);
1363 return new Dart2JsLocation(script, span); 1368 return new Dart2JsLocation(script, span);
1364 } else { 1369 } else {
1365 var span = system.compiler.spanFromElement(_variable); 1370 var span = system.compiler.spanFromElement(_variable);
1366 return new Dart2JsLocation(script, span); 1371 return new Dart2JsLocation(script, span);
1367 } 1372 }
1368 } 1373 }
1369 } 1374 }
1370 1375
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698