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

Unified Diff: pkg/docgen/lib/docgen.dart

Issue 20617005: Returning the closest public superclass rather than returning "" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/docgen/lib/docgen.dart
diff --git a/pkg/docgen/lib/docgen.dart b/pkg/docgen/lib/docgen.dart
index 72588c80027d366b598c35327a2fff0f97300f6c..95a242ab86e4fe695350302a41e64438b8df0dbc 100644
--- a/pkg/docgen/lib/docgen.dart
+++ b/pkg/docgen/lib/docgen.dart
@@ -216,7 +216,7 @@ void _documentLibraries(List<LibraryMirror> libs,
// giant list of subclasses to be printed out.
entityMap['dart.core.Object'].subclasses.clear();
- var filteredEntities = entityMap.values.where((e) => _filterPrivate(e));
+ var filteredEntities = entityMap.values.where((e) => _isHidden(e));
// Output libraries and classes to file after all information is generated.
filteredEntities.where((e) => e is Class || e is Library).forEach((output) {
_writeIndexableToFile(output, outputToYaml);
@@ -279,7 +279,7 @@ bool _isPrivate(DeclarationMirror mirror) {
}
}
-bool _filterPrivate(Indexable item) {
+bool _isHidden(Indexable item) {
Bob Nystrom 2013/08/02 02:25:03 Hmm, I think I told you to name this backwards. It
return _includePrivate || !item.isPrivate;
}
@@ -578,7 +578,7 @@ class Class extends Indexable {
*/
void addInherited(Class superclass) {
inheritedVariables.addAll(superclass.inheritedVariables);
- if (_filterPrivate(superclass)) {
+ if (_isHidden(superclass)) {
inheritedVariables.addAll(superclass.variables);
}
inheritedMethods.addInherited(superclass);
@@ -620,14 +620,23 @@ class Class extends Indexable {
}
}
+ /**
+ * If a class extends a private superclass, find the closest public superclass
+ * of the private superclass.
+ */
+ String validSuperclass() {
+ if (superclass == null) return 'dart.core.Object';
+ if (_isHidden(superclass)) return superclass.qualifiedName;
+ return superclass.validSuperclass();
+ }
+
/// Generates a map describing the [Class] object.
Map toMap() => {
'name': name,
'qualifiedname': qualifiedName,
'comment': comment,
- 'superclass': superclass == null ? "" : (_filterPrivate(superclass)) ?
- superclass.qualifiedName : "",
- 'implements': new List.from(interfaces.where((e) => _filterPrivate(e))
+ 'superclass': validSuperclass(),
+ 'implements': new List.from(interfaces.where((e) => _isHidden(e))
Bob Nystrom 2013/08/02 02:25:03 Instead of where((e) => _isHidden(e)), you can jus
.map((e) => e.qualifiedName)),
'subclass': new List.from(subclasses),
'variables': recurseMap(variables),
@@ -655,7 +664,7 @@ class ClassGroup {
// Adding inherited parent variables and methods.
clazz.parent().forEach((parent) {
- if (_filterPrivate(clazz)) {
+ if (_isHidden(clazz)) {
parent.addSubclass(clazz);
}
clazz.addInherited(parent);
@@ -692,12 +701,12 @@ class ClassGroup {
Map toMap() => {
'abstract': new List.from(abstractClasses.values
- .where((e) => _filterPrivate(e)).map((e) => e.qualifiedName)),
+ .where((e) => _isHidden(e)).map((e) => e.qualifiedName)),
Bob Nystrom 2013/08/02 02:25:03 And here too: where(_isHidden)
'class': new List.from(regularClasses.values
- .where((e) => _filterPrivate(e)).map((e) => e.qualifiedName)),
+ .where((e) => _isHidden(e)).map((e) => e.qualifiedName)),
'typedef': recurseMap(typedefs),
'error': new List.from(errors.values
- .where((e) => _filterPrivate(e)).map((e) => e.qualifiedName))
+ .where((e) => _isHidden(e)).map((e) => e.qualifiedName))
};
}
@@ -832,7 +841,7 @@ class MethodGroup {
getters.addAll(parent.inheritedMethods.getters);
operators.addAll(parent.inheritedMethods.operators);
regularMethods.addAll(parent.inheritedMethods.regularMethods);
- if (_filterPrivate(parent)) {
+ if (_isHidden(parent)) {
setters.addAll(parent.methods.setters);
getters.addAll(parent.methods.getters);
operators.addAll(parent.methods.operators);
« 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