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

Side by Side Diff: pkg/docgen/lib/docgen.dart

Issue 64713006: Filter out statics when adding inherited members (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | « no previous file | no next file » | 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 /// **docgen** is a tool for creating machine readable representations of Dart 5 /// **docgen** is a tool for creating machine readable representations of Dart
6 /// code metadata, including: classes, members, comments and annotations. 6 /// code metadata, including: classes, members, comments and annotations.
7 /// 7 ///
8 /// docgen is run on a `.dart` file or a directory containing `.dart` files. 8 /// docgen is run on a `.dart` file or a directory containing `.dart` files.
9 /// 9 ///
10 /// $ dart docgen.dart [OPTIONS] [FILE/DIR] 10 /// $ dart docgen.dart [OPTIONS] [FILE/DIR]
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 var parent = superclass == null ? [] : [superclass]; 890 var parent = superclass == null ? [] : [superclass];
891 parent.addAll(interfaces); 891 parent.addAll(interfaces);
892 return parent; 892 return parent;
893 } 893 }
894 894
895 /// Add all inherited variables and methods from the provided superclass. 895 /// Add all inherited variables and methods from the provided superclass.
896 /// If [_includePrivate] is true, it also adds the variables and methods from 896 /// If [_includePrivate] is true, it also adds the variables and methods from
897 /// the superclass. 897 /// the superclass.
898 void addInherited(Class superclass) { 898 void addInherited(Class superclass) {
899 inheritedVariables.addAll(superclass.inheritedVariables); 899 inheritedVariables.addAll(superclass.inheritedVariables);
900 inheritedVariables.addAll(superclass.variables); 900 inheritedVariables.addAll(_filterStatics(superclass.variables));
901 inheritedMethods.addInherited(superclass); 901 inheritedMethods.addInherited(superclass);
902 } 902 }
903 903
904 /// Add the subclass to the class. 904 /// Add the subclass to the class.
905 /// 905 ///
906 /// If [this] is private, it will add the subclass to the list of subclasses i n 906 /// If [this] is private, it will add the subclass to the list of subclasses i n
907 /// the superclasses. 907 /// the superclasses.
908 void addSubclass(Class subclass) { 908 void addSubclass(Class subclass) {
909 if (!_includePrivate && isPrivate) { 909 if (!_includePrivate && isPrivate) {
910 if (superclass != null) superclass.addSubclass(subclass); 910 if (superclass != null) superclass.addSubclass(subclass);
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1183 operators[mirror.simpleName] = method; 1183 operators[mirror.simpleName] = method;
1184 } else if (mirror.isRegularMethod) { 1184 } else if (mirror.isRegularMethod) {
1185 regularMethods[mirror.simpleName] = method; 1185 regularMethods[mirror.simpleName] = method;
1186 } else { 1186 } else {
1187 throw new ArgumentError('${mirror.simpleName} - no method type match'); 1187 throw new ArgumentError('${mirror.simpleName} - no method type match');
1188 } 1188 }
1189 } 1189 }
1190 1190
1191 void addInherited(Class parent) { 1191 void addInherited(Class parent) {
1192 setters.addAll(parent.inheritedMethods.setters); 1192 setters.addAll(parent.inheritedMethods.setters);
1193 setters.addAll(parent.methods.setters); 1193 setters.addAll(_filterStatics(parent.methods.setters));
1194 getters.addAll(parent.inheritedMethods.getters); 1194 getters.addAll(parent.inheritedMethods.getters);
1195 getters.addAll(parent.methods.getters); 1195 getters.addAll(_filterStatics(parent.methods.getters));
1196 operators.addAll(parent.inheritedMethods.operators); 1196 operators.addAll(parent.inheritedMethods.operators);
1197 operators.addAll(parent.methods.operators); 1197 operators.addAll(_filterStatics(parent.methods.operators));
1198 regularMethods.addAll(parent.inheritedMethods.regularMethods); 1198 regularMethods.addAll(parent.inheritedMethods.regularMethods);
1199 regularMethods.addAll(parent.methods.regularMethods); 1199 regularMethods.addAll(_filterStatics(parent.methods.regularMethods));
1200 } 1200 }
1201 1201
1202 Map toMap() => { 1202 Map toMap() => {
1203 'setters': recurseMap(setters), 1203 'setters': recurseMap(setters),
1204 'getters': recurseMap(getters), 1204 'getters': recurseMap(getters),
1205 'constructors': recurseMap(constructors), 1205 'constructors': recurseMap(constructors),
1206 'operators': recurseMap(operators), 1206 'operators': recurseMap(operators),
1207 'methods': recurseMap(regularMethods) 1207 'methods': recurseMap(regularMethods)
1208 }; 1208 };
1209 1209
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 String docName(DeclarationMirror m) { 1325 String docName(DeclarationMirror m) {
1326 if (m is LibraryMirror) { 1326 if (m is LibraryMirror) {
1327 return (m as LibraryMirror).qualifiedName.replaceAll('.','-'); 1327 return (m as LibraryMirror).qualifiedName.replaceAll('.','-');
1328 } 1328 }
1329 var owner = m.owner; 1329 var owner = m.owner;
1330 if (owner == null) return m.qualifiedName; 1330 if (owner == null) return m.qualifiedName;
1331 // For the unnamed constructor we just return the class name. 1331 // For the unnamed constructor we just return the class name.
1332 if (m.simpleName == '') return docName(owner); 1332 if (m.simpleName == '') return docName(owner);
1333 return docName(owner) + '.' + m.simpleName; 1333 return docName(owner) + '.' + m.simpleName;
1334 } 1334 }
1335
1336 /// Remove statics from the map of inherited items before adding them.
1337 Map _filterStatics(Map items) {
1338 var result = {};
1339 items.forEach((name, item) {
1340 if (!item.isStatic) {
1341 result[name] = item;
1342 }
1343 });
1344 return result;
1345 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698