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

Side by Side Diff: pkg/dartdoc/lib/mirrors_util.dart

Issue 11014022: Make Mirror.simpleName unique. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 8 years, 2 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/lib/mirrors.dart ('k') | pkg/dartdoc/lib/src/mirrors/dart2js_mirror.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.util'); 5 #library('mirrors.util');
6 6
7 // TODO(rnystrom): Use "package:" URL (#4968). 7 // TODO(rnystrom): Use "package:" URL (#4968).
8 #import('mirrors.dart'); 8 #import('mirrors.dart');
9 #import('../../../lib/compiler/implementation/util/characters.dart'); 9 #import('../../../lib/compiler/implementation/util/characters.dart');
10 10
(...skipping 12 matching lines...) Expand all
23 for (InterfaceMirror otherType in library.types.getValues()) { 23 for (InterfaceMirror otherType in library.types.getValues()) {
24 var superClass = otherType.superclass; 24 var superClass = otherType.superclass;
25 if (superClass !== null) { 25 if (superClass !== null) {
26 superClass = superClass.declaration; 26 superClass = superClass.declaration;
27 if (type.library === superClass.library) { 27 if (type.library === superClass.library) {
28 if (superClass == type) { 28 if (superClass == type) {
29 subtypes.add(otherType); 29 subtypes.add(otherType);
30 } 30 }
31 } 31 }
32 } 32 }
33 final superInterfaces = otherType.interfaces.getValues(); 33 final superInterfaces = otherType.interfaces;
34 for (InterfaceMirror superInterface in superInterfaces) { 34 for (InterfaceMirror superInterface in superInterfaces) {
35 superInterface = superInterface.declaration; 35 superInterface = superInterface.declaration;
36 if (type.library === superInterface.library) { 36 if (type.library === superInterface.library) {
37 if (superInterface == type) { 37 if (superInterface == type) {
38 subtypes.add(otherType); 38 subtypes.add(otherType);
39 } 39 }
40 } 40 }
41 } 41 }
42 } 42 }
43 }); 43 });
44 return subtypes; 44 return subtypes;
45 } 45 }
46 46
47 /**
48 * Finds the mirror in [map] by the simple name [name]. If [constructorName] or
49 * [operatorName] is provided, a constructor/operator method by that name is
50 * returned.
51 */
52 Mirror findMirror(Map<Object,Mirror> map, String name,
53 [String constructorName, String operatorName]) {
54 var foundMirror = null;
55 map.forEach((_, Mirror mirror) {
56 if (mirror.simpleName == name) {
57 if (constructorName !== null) {
58 if (mirror is MethodMirror &&
59 constructorName == mirror.constructorName) {
60 foundMirror = mirror;
61 }
62 } else if (operatorName !== null) {
63 if (mirror is MethodMirror &&
64 operatorName == mirror.operatorName) {
65 foundMirror = mirror;
66 }
67 } else {
68 foundMirror = mirror;
69 }
70 }
71 });
72 return foundMirror;
73 }
74
75 LibraryMirror findLibrary(MemberMirror member) { 47 LibraryMirror findLibrary(MemberMirror member) {
76 ObjectMirror owner = member.surroundingDeclaration; 48 ObjectMirror owner = member.surroundingDeclaration;
77 if (owner is LibraryMirror) { 49 if (owner is LibraryMirror) {
78 return owner; 50 return owner;
79 } else if (owner is TypeMirror) { 51 } else if (owner is TypeMirror) {
80 return owner.library; 52 return owner.library;
81 } 53 }
82 throw new Exception('Unexpected owner: ${owner}'); 54 throw new Exception('Unexpected owner: ${owner}');
83 } 55 }
84 56
85 57
86 /** 58 /**
87 * Returns the column of the start of a location. 59 * Returns the column of the start of a location.
88 */ 60 */
89 int getLocationColumn(Location location) { 61 int getLocationColumn(Location location) {
90 String text = location.source.text; 62 String text = location.source.text;
91 int index = location.start-1; 63 int index = location.start-1;
92 var column = 0; 64 var column = 0;
93 while (0 <= index && index < text.length) { 65 while (0 <= index && index < text.length) {
94 var charCode = text.charCodeAt(index); 66 var charCode = text.charCodeAt(index);
95 if (charCode == $CR || charCode == $LF) { 67 if (charCode == $CR || charCode == $LF) {
96 break; 68 break;
97 } 69 }
98 index--; 70 index--;
99 column++; 71 column++;
100 } 72 }
101 return column; 73 return column;
102 } 74 }
OLDNEW
« no previous file with comments | « pkg/dartdoc/lib/mirrors.dart ('k') | pkg/dartdoc/lib/src/mirrors/dart2js_mirror.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698