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

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

Issue 11337021: Change surroundingDeclaration to DeclarationMirror.owner (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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/lib/mirrors_util.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 'dart:io'; 7 import 'dart:io';
8 import 'dart:uri'; 8 import 'dart:uri';
9 9
10 import '../../../../../lib/compiler/compiler.dart' as diagnostics; 10 import '../../../../../lib/compiler/compiler.dart' as diagnostics;
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 Map<String, ClassMirror> _types; 484 Map<String, ClassMirror> _types;
485 Map<String, MemberMirror> _members; 485 Map<String, MemberMirror> _members;
486 486
487 Dart2JsLibraryMirror(Dart2JsMirrorSystem system, LibraryElement library) 487 Dart2JsLibraryMirror(Dart2JsMirrorSystem system, LibraryElement library)
488 : super(system, library); 488 : super(system, library);
489 489
490 LibraryElement get _library => _element; 490 LibraryElement get _library => _element;
491 491
492 Uri get uri => _library.uri; 492 Uri get uri => _library.uri;
493 493
494 DeclarationMirror get owner => null;
495
494 LibraryMirror library() => this; 496 LibraryMirror library() => this;
495 497
496 /** 498 /**
497 * Returns the library name (for libraries with a #library tag) or the script 499 * Returns the library name (for libraries with a #library tag) or the script
498 * file name (for scripts without a #library tag). The latter case is used to 500 * file name (for scripts without a #library tag). The latter case is used to
499 * provide a 'library name' for scripts, to use for instance in dartdoc. 501 * provide a 'library name' for scripts, to use for instance in dartdoc.
500 */ 502 */
501 String get simpleName { 503 String get simpleName {
502 if (_library.libraryTag !== null) { 504 if (_library.libraryTag !== null) {
503 // TODO(ahe): Remove StringNode check when old syntax is removed. 505 // TODO(ahe): Remove StringNode check when old syntax is removed.
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 return new Dart2JsParameterMirror._normal(system, 614 return new Dart2JsParameterMirror._normal(system,
613 method, element, isOptional); 615 method, element, isOptional);
614 } 616 }
615 617
616 Dart2JsParameterMirror._normal(Dart2JsMirrorSystem system, 618 Dart2JsParameterMirror._normal(Dart2JsMirrorSystem system,
617 this._method, 619 this._method,
618 VariableElement element, 620 VariableElement element,
619 this.isOptional) 621 this.isOptional)
620 : super(system, element); 622 : super(system, element);
621 623
624 DeclarationMirror get owner => _method;
625
622 VariableElement get _variableElement => _element; 626 VariableElement get _variableElement => _element;
623 627
624 String get qualifiedName => '${_method.qualifiedName}#${simpleName}'; 628 String get qualifiedName => '${_method.qualifiedName}#${simpleName}';
625 629
626 TypeMirror get type => _convertTypeToTypeMirror(system, 630 TypeMirror get type => _convertTypeToTypeMirror(system,
627 _variableElement.computeType(system.compiler), 631 _variableElement.computeType(system.compiler),
628 system.compiler.types.dynamicType, 632 system.compiler.types.dynamicType,
629 _variableElement.variables.functionSignature); 633 _variableElement.variables.functionSignature);
630 634
631 String get defaultValue { 635 String get defaultValue {
(...skipping 29 matching lines...) Expand all
661 } 665 }
662 return _convertTypeToTypeMirror(system, 666 return _convertTypeToTypeMirror(system,
663 _fieldParameterElement.fieldElement.computeType(system.compiler), 667 _fieldParameterElement.fieldElement.computeType(system.compiler),
664 system.compiler.types.dynamicType, 668 system.compiler.types.dynamicType,
665 _variableElement.variables.functionSignature); 669 _variableElement.variables.functionSignature);
666 } 670 }
667 671
668 bool get isInitializingFormal => true; 672 bool get isInitializingFormal => true;
669 673
670 FieldMirror get initializedField => new Dart2JsFieldMirror( 674 FieldMirror get initializedField => new Dart2JsFieldMirror(
671 _method.surroundingDeclaration, _fieldParameterElement.fieldElement); 675 _method.owner, _fieldParameterElement.fieldElement);
672 } 676 }
673 677
674 //------------------------------------------------------------------------------ 678 //------------------------------------------------------------------------------
675 // Declarations 679 // Declarations
676 //------------------------------------------------------------------------------ 680 //------------------------------------------------------------------------------
677 class Dart2JsClassMirror extends Dart2JsObjectMirror 681 class Dart2JsClassMirror extends Dart2JsObjectMirror
678 implements Dart2JsTypeMirror, ClassMirror { 682 implements Dart2JsTypeMirror, ClassMirror {
679 final Dart2JsLibraryMirror library; 683 final Dart2JsLibraryMirror library;
680 Map<String, Dart2JsMemberMirror> _members; 684 Map<String, Dart2JsMemberMirror> _members;
681 List<TypeVariableMirror> _typeVariables; 685 List<TypeVariableMirror> _typeVariables;
682 686
683 Dart2JsClassMirror(Dart2JsMirrorSystem system, ClassElement _class) 687 Dart2JsClassMirror(Dart2JsMirrorSystem system, ClassElement _class)
684 : this.library = system.getLibrary(_class.getLibrary()), 688 : this.library = system.getLibrary(_class.getLibrary()),
685 super(system, _class); 689 super(system, _class);
686 690
687 ClassElement get _class => _element; 691 ClassElement get _class => _element;
688 692
689 Dart2JsClassMirror.fromLibrary(Dart2JsLibraryMirror library, 693 Dart2JsClassMirror.fromLibrary(Dart2JsLibraryMirror library,
690 ClassElement _class) 694 ClassElement _class)
691 : this.library = library, 695 : this.library = library,
692 super(library.system, _class); 696 super(library.system, _class);
693 697
698 DeclarationMirror get owner => library;
699
694 String get qualifiedName => '${library.qualifiedName}.${simpleName}'; 700 String get qualifiedName => '${library.qualifiedName}.${simpleName}';
695 701
696 SourceLocation get location { 702 SourceLocation get location {
697 if (_class is PartialClassElement) { 703 if (_class is PartialClassElement) {
698 var node = _class.parseNode(system.compiler); 704 var node = _class.parseNode(system.compiler);
699 if (node !== null) { 705 if (node !== null) {
700 var script = _class.getCompilationUnit().script; 706 var script = _class.getCompilationUnit().script;
701 var span = system.compiler.spanFromNode(node, script.uri); 707 var span = system.compiler.spanFromNode(node, script.uri);
702 return new Dart2JsLocation(script, span); 708 return new Dart2JsLocation(script, span);
703 } 709 }
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 : super(system); 974 : super(system);
969 975
970 String get simpleName => _type.name.slowToString(); 976 String get simpleName => _type.name.slowToString();
971 977
972 SourceLocation get location { 978 SourceLocation get location {
973 var script = _type.element.getCompilationUnit().script; 979 var script = _type.element.getCompilationUnit().script;
974 return new Dart2JsLocation(script, 980 return new Dart2JsLocation(script,
975 system.compiler.spanFromElement(_type.element)); 981 system.compiler.spanFromElement(_type.element));
976 } 982 }
977 983
984 DeclarationMirror get owner => library;
985
978 LibraryMirror get library { 986 LibraryMirror get library {
979 return system.getLibrary(_type.element.getLibrary()); 987 return system.getLibrary(_type.element.getLibrary());
980 } 988 }
981 989
982 bool get isObject => false; 990 bool get isObject => false;
983 991
984 bool get isVoid => false; 992 bool get isVoid => false;
985 993
986 bool get isDynamic => false; 994 bool get isDynamic => false;
987 995
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
1294 } 1302 }
1295 } 1303 }
1296 1304
1297 FunctionElement get _function => _element; 1305 FunctionElement get _function => _element;
1298 1306
1299 String get simpleName => _simpleName; 1307 String get simpleName => _simpleName;
1300 1308
1301 String get displayName => _displayName; 1309 String get displayName => _displayName;
1302 1310
1303 String get qualifiedName 1311 String get qualifiedName
1304 => '${surroundingDeclaration.qualifiedName}.$simpleName'; 1312 => '${owner.qualifiedName}.$simpleName';
1305 1313
1306 ObjectMirror get surroundingDeclaration => _objectMirror; 1314 DeclarationMirror get owner => _objectMirror;
1307 1315
1308 bool get isTopLevel => _objectMirror is LibraryMirror; 1316 bool get isTopLevel => _objectMirror is LibraryMirror;
1309 1317
1310 bool get isConstructor 1318 bool get isConstructor
1311 => _kind == Dart2JsMethodKind.CONSTRUCTOR || isConst || isFactory; 1319 => _kind == Dart2JsMethodKind.CONSTRUCTOR || isConst || isFactory;
1312 1320
1313 bool get isField => false; 1321 bool get isField => false;
1314 1322
1315 bool get isMethod => !isConstructor; 1323 bool get isMethod => !isConstructor;
1316 1324
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1361 Dart2JsObjectMirror _objectMirror; 1369 Dart2JsObjectMirror _objectMirror;
1362 VariableElement _variable; 1370 VariableElement _variable;
1363 1371
1364 Dart2JsFieldMirror(Dart2JsObjectMirror objectMirror, 1372 Dart2JsFieldMirror(Dart2JsObjectMirror objectMirror,
1365 VariableElement variable) 1373 VariableElement variable)
1366 : this._objectMirror = objectMirror, 1374 : this._objectMirror = objectMirror,
1367 this._variable = variable, 1375 this._variable = variable,
1368 super(objectMirror.system, variable); 1376 super(objectMirror.system, variable);
1369 1377
1370 String get qualifiedName 1378 String get qualifiedName
1371 => '${surroundingDeclaration.qualifiedName}.$simpleName'; 1379 => '${owner.qualifiedName}.$simpleName';
1372 1380
1373 ObjectMirror get surroundingDeclaration => _objectMirror; 1381 DeclarationMirror get owner => _objectMirror;
1374 1382
1375 bool get isTopLevel => _objectMirror is LibraryMirror; 1383 bool get isTopLevel => _objectMirror is LibraryMirror;
1376 1384
1377 bool get isConstructor => false; 1385 bool get isConstructor => false;
1378 1386
1379 bool get isField => true; 1387 bool get isField => true;
1380 1388
1381 bool get isMethod => false; 1389 bool get isMethod => false;
1382 1390
1383 bool get isPrivate => _isPrivate(simpleName); 1391 bool get isPrivate => _isPrivate(simpleName);
(...skipping 14 matching lines...) Expand all
1398 if (node !== null) { 1406 if (node !== null) {
1399 var span = system.compiler.spanFromNode(node, script.uri); 1407 var span = system.compiler.spanFromNode(node, script.uri);
1400 return new Dart2JsLocation(script, span); 1408 return new Dart2JsLocation(script, span);
1401 } else { 1409 } else {
1402 var span = system.compiler.spanFromElement(_variable); 1410 var span = system.compiler.spanFromElement(_variable);
1403 return new Dart2JsLocation(script, span); 1411 return new Dart2JsLocation(script, span);
1404 } 1412 }
1405 } 1413 }
1406 } 1414 }
1407 1415
OLDNEW
« no previous file with comments | « pkg/dartdoc/lib/mirrors_util.dart ('k') | tests/compiler/dart2js/mirrors_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698