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

Unified Diff: utils/dartdoc/dartdoc.dart

Issue 8692017: Find [references] to top-level members. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 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 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: utils/dartdoc/dartdoc.dart
diff --git a/utils/dartdoc/dartdoc.dart b/utils/dartdoc/dartdoc.dart
index 2cadadf47cbf38a3c5ae92dc4650a69d4fd4cf65..72b52aadd6f6fadd3c6f9e29466a9fa74ef2127a 100644
--- a/utils/dartdoc/dartdoc.dart
+++ b/utils/dartdoc/dartdoc.dart
@@ -540,21 +540,24 @@ md.Node resolveNameReference(String name) {
return anchor;
}
+ findMember(Type type) {
+ final member = type.members[name];
+ if (member == null) return null;
+
+ // Special case: if the member we've resolved is a property (i.e. it wraps
+ // a getter and/or setter then *that* member itself won't be on the docs,
+ // just the getter or setter will be. So pick one of those to link to.
+ if (member.isProperty) {
+ return member.canGet ? member.getter : member.setter;
+ }
+
+ return member;
+ }
+
// See if it's another member of the current type.
if (_currentType != null) {
- var member = _currentType.members[name];
+ final member = findMember(_currentType);
if (member != null) {
- // Special case: if the member we've resolved is a property (i.e. it wraps
- // a getter and/or setter then *that* member itself won't be on the docs,
- // just the getter or setter will be. So pick one of those to link to.
- if (member.isProperty) {
- if (member.canGet) {
- member = member.getter;
- } else {
- member = member.setter;
- }
- }
-
return makeLink(memberUrl(member));
}
}
@@ -565,6 +568,12 @@ md.Node resolveNameReference(String name) {
if (type != null) {
return makeLink(typeUrl(type));
}
+
+ // See if it's a top-level member in the current library.
+ final member = findMember(_currentLibrary.topType);
+ if (member != null) {
+ return makeLink(memberUrl(member));
+ }
}
// TODO(rnystrom): Should also consider:
« 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