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

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: Updated cf. comments. 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 | « pkg/dartdoc/dartdoc.dart ('k') | tests/compiler/dart2js/mirrors_test.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('../../../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 // TODO(johnniwinther): Should be [ensureResolved].
849 // aliased function definition. 851 system.compiler.resolveTypedef(_typedef.element);
852 _definition = _convertTypeToTypeMirror(
853 system,
854 _typedef.element.alias,
855 system.compiler.types.dynamicType,
856 _typedef.element.functionSignature);
850 } 857 }
851 return _definition; 858 return _definition;
852 } 859 }
853 860
854 Map<Object, MemberMirror> get declaredMembers() => 861 Map<Object, MemberMirror> get declaredMembers() =>
855 const <String, MemberMirror>{}; 862 const <String, MemberMirror>{};
856 863
857 InterfaceMirror get declaration() => this; 864 InterfaceMirror get declaration() => this;
858 865
859 // TODO(johnniwinther): How should a typedef respond to these? 866 // 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; 1017 bool get isPrivate() => declaration.isPrivate;
1011 1018
1012 bool get isDeclaration() => false; 1019 bool get isDeclaration() => false;
1013 1020
1014 List<TypeMirror> get typeArguments() { 1021 List<TypeMirror> get typeArguments() {
1015 if (_typeArguments == null) { 1022 if (_typeArguments == null) {
1016 _typeArguments = <TypeMirror>[]; 1023 _typeArguments = <TypeMirror>[];
1017 Link<Type> type = _interfaceType.arguments; 1024 Link<Type> type = _interfaceType.arguments;
1018 while (type != null && type.head != null) { 1025 while (type != null && type.head != null) {
1019 _typeArguments.add(_convertTypeToTypeMirror(system, type.head, 1026 _typeArguments.add(_convertTypeToTypeMirror(system, type.head,
1020 system.compiler.dynamicClass.computeType(system.compiler))); 1027 system.compiler.types.dynamicType));
1021 type = type.tail; 1028 type = type.tail;
1022 } 1029 }
1023 } 1030 }
1024 return _typeArguments; 1031 return _typeArguments;
1025 } 1032 }
1026 1033
1027 List<TypeVariableMirror> get typeVariables() => declaration.typeVariables; 1034 List<TypeVariableMirror> get typeVariables() => declaration.typeVariables;
1028 1035
1029 // TODO(johnniwinther): Substitute type arguments for type variables. 1036 // TODO(johnniwinther): Substitute type arguments for type variables.
1030 Map<Object, MethodMirror> get constructors() => declaration.constructors; 1037 Map<Object, MethodMirror> get constructors() => declaration.constructors;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1124 1131
1125 List<TypeVariableMirror> get typeVariables() => declaration.typeVariables; 1132 List<TypeVariableMirror> get typeVariables() => declaration.typeVariables;
1126 1133
1127 Map<Object, MethodMirror> get constructors() => 1134 Map<Object, MethodMirror> get constructors() =>
1128 <String, MethodMirror>{}; 1135 <String, MethodMirror>{};
1129 1136
1130 InterfaceMirror get defaultType() => null; 1137 InterfaceMirror get defaultType() => null;
1131 1138
1132 TypeMirror get returnType() { 1139 TypeMirror get returnType() {
1133 return _convertTypeToTypeMirror(system, _functionType.returnType, 1140 return _convertTypeToTypeMirror(system, _functionType.returnType,
1134 system.compiler.dynamicClass.computeType(system.compiler)); 1141 system.compiler.types.dynamicType);
1135 } 1142 }
1136 1143
1137 List<ParameterMirror> get parameters() { 1144 List<ParameterMirror> get parameters() {
1138 if (_parameters === null) { 1145 if (_parameters === null) {
1139 _parameters = _parametersFromFunctionSignature(system, callMethod, 1146 _parameters = _parametersFromFunctionSignature(system, callMethod,
1140 _functionSignature); 1147 _functionSignature);
1141 } 1148 }
1142 return _parameters; 1149 return _parameters;
1143 } 1150 }
1144 } 1151 }
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1279 bool get isStatic() => 1286 bool get isStatic() =>
1280 _function.modifiers !== null && _function.modifiers.isStatic(); 1287 _function.modifiers !== null && _function.modifiers.isStatic();
1281 1288
1282 List<ParameterMirror> get parameters() { 1289 List<ParameterMirror> get parameters() {
1283 return _parametersFromFunctionSignature(system, this, 1290 return _parametersFromFunctionSignature(system, this,
1284 _function.computeSignature(system.compiler)); 1291 _function.computeSignature(system.compiler));
1285 } 1292 }
1286 1293
1287 TypeMirror get returnType() => _convertTypeToTypeMirror( 1294 TypeMirror get returnType() => _convertTypeToTypeMirror(
1288 system, _function.computeSignature(system.compiler).returnType, 1295 system, _function.computeSignature(system.compiler).returnType,
1289 system.compiler.dynamicClass.computeType(system.compiler)); 1296 system.compiler.types.dynamicType);
1290 1297
1291 bool get isConst() => _kind == Dart2JsMethodKind.CONST; 1298 bool get isConst() => _kind == Dart2JsMethodKind.CONST;
1292 1299
1293 bool get isFactory() => _kind == Dart2JsMethodKind.FACTORY; 1300 bool get isFactory() => _kind == Dart2JsMethodKind.FACTORY;
1294 1301
1295 String get constructorName() => _constructorName; 1302 String get constructorName() => _constructorName;
1296 1303
1297 bool get isGetter() => _kind == Dart2JsMethodKind.GETTER; 1304 bool get isGetter() => _kind == Dart2JsMethodKind.GETTER;
1298 1305
1299 bool get isSetter() => _kind == Dart2JsMethodKind.SETTER; 1306 bool get isSetter() => _kind == Dart2JsMethodKind.SETTER;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1346 bool get isMethod() => false; 1353 bool get isMethod() => false;
1347 1354
1348 bool get isPrivate() => _isPrivate(simpleName); 1355 bool get isPrivate() => _isPrivate(simpleName);
1349 1356
1350 bool get isStatic() => _variable.modifiers.isStatic(); 1357 bool get isStatic() => _variable.modifiers.isStatic();
1351 1358
1352 bool get isFinal() => _variable.modifiers.isFinal(); 1359 bool get isFinal() => _variable.modifiers.isFinal();
1353 1360
1354 TypeMirror get type() => _convertTypeToTypeMirror(system, 1361 TypeMirror get type() => _convertTypeToTypeMirror(system,
1355 _variable.computeType(system.compiler), 1362 _variable.computeType(system.compiler),
1356 system.compiler.dynamicClass.computeType(system.compiler)); 1363 system.compiler.types.dynamicType);
1357 1364
1358 Location get location() { 1365 Location get location() {
1359 var script = _variable.getCompilationUnit().script; 1366 var script = _variable.getCompilationUnit().script;
1360 var node = _variable.variables.parseNode(_diagnosticListener); 1367 var node = _variable.variables.parseNode(_diagnosticListener);
1361 if (node !== null) { 1368 if (node !== null) {
1362 var span = system.compiler.spanFromNode(node, script.uri); 1369 var span = system.compiler.spanFromNode(node, script.uri);
1363 return new Dart2JsLocation(script, span); 1370 return new Dart2JsLocation(script, span);
1364 } else { 1371 } else {
1365 var span = system.compiler.spanFromElement(_variable); 1372 var span = system.compiler.spanFromElement(_variable);
1366 return new Dart2JsLocation(script, span); 1373 return new Dart2JsLocation(script, span);
1367 } 1374 }
1368 } 1375 }
1369 } 1376 }
1370 1377
OLDNEW
« no previous file with comments | « pkg/dartdoc/dartdoc.dart ('k') | tests/compiler/dart2js/mirrors_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698