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

Unified Diff: lib/dartdoc/mirrors/mirrors_util.dart

Issue 10701091: Dartdoc and Apidoc updated to use dart2js through the mirror system. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed cf. rnystrom's comments. Created 8 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
Index: lib/dartdoc/mirrors/mirrors_util.dart
diff --git a/lib/dartdoc/mirrors/mirrors_util.dart b/lib/dartdoc/mirrors/mirrors_util.dart
index 727d5cb6c91759dbbff770346299d526e67c1953..3dad2048d00a980eb488350449601ff9efa76455 100644
--- a/lib/dartdoc/mirrors/mirrors_util.dart
+++ b/lib/dartdoc/mirrors/mirrors_util.dart
@@ -5,6 +5,7 @@
#library('mirrors.util');
#import('mirrors.dart');
+#import('../../compiler/implementation/util/characters.dart');
//------------------------------------------------------------------------------
// Utility functions for using the Mirror API
@@ -14,11 +15,10 @@
* Returns an iterable over the type declarations directly inheriting from
* the declaration of this type.
*/
-Iterable<InterfaceMirror> computeSubdeclarations(MirrorSystem system,
- InterfaceMirror type) {
+Iterable<InterfaceMirror> computeSubdeclarations(InterfaceMirror type) {
type = type.declaration;
var subtypes = <InterfaceMirror>[];
- system.libraries().forEach((_, library) {
+ type.system.libraries().forEach((_, library) {
for (InterfaceMirror otherType in library.types().getValues()) {
var superClass = otherType.superclass();
if (superClass !== null) {
@@ -70,3 +70,32 @@ Mirror findMirror(Map<Object,Mirror> map, String name,
});
return foundMirror;
}
+
+LibraryMirror findLibrary(MemberMirror member) {
+ ObjectMirror owner = member.surroundingDeclaration();
+ if (owner is LibraryMirror) {
+ return owner;
+ } else if (owner is TypeMirror) {
+ return owner.library();
+ }
+ throw new Exception('Unexpected owner: ${owner}');
+}
+
+
+/**
+ * Returns the column of the start of a location.
+ */
+int getLocationColumn(Location location) {
+ String text = location.source().text();
+ int index = location.start()-1;
+ var column = 0;
+ while (0 <= index && index < text.length) {
+ var charCode = text.charCodeAt(index);
+ if (charCode == $CR || charCode == $LF) {
+ break;
+ }
+ index--;
+ column++;
+ }
+ return column;
+}

Powered by Google App Engine
This is Rietveld 408576698