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

Unified Diff: pkg/docgen/lib/src/models/owned_indexable.dart

Issue 242363004: pkg/docgen: moved model classes into minilibs (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: cl nits Created 6 years, 8 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: pkg/docgen/lib/src/models/owned_indexable.dart
diff --git a/pkg/docgen/lib/src/models/owned_indexable.dart b/pkg/docgen/lib/src/models/owned_indexable.dart
new file mode 100644
index 0000000000000000000000000000000000000000..1df771e3c8d60212ff1a89239addd1826bf707cd
--- /dev/null
+++ b/pkg/docgen/lib/src/models/owned_indexable.dart
@@ -0,0 +1,51 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library docgen.models.owned_indexable;
+
+import '../exports/mirrors_util.dart' as dart2js_util;
+import '../exports/source_mirrors.dart';
+
+import '../library_helpers.dart';
+import '../mdn.dart';
+import '../package_helpers.dart';
+
+import 'annotation.dart';
+import 'indexable.dart';
+import 'model_helpers.dart';
+
+abstract class OwnedIndexable<TMirror extends DeclarationMirror>
+ extends Indexable<TMirror> {
+ /// List of the meta annotations on this item.
+ final List<Annotation> annotations;
+
+ /// The object one scope-level above which this item is defined.
+ ///
+ /// Ex: The owner for a top level class, would be its enclosing library.
+ /// The owner of a local variable in a method would be the enclosing method.
+ final Indexable owner;
+
+ /// Returns this object's qualified name, but following the conventions
+ /// we're using in Dartdoc, which is that library names with dots in them
+ /// have them replaced with hyphens.
+ String get docName => owner.docName + '.' + dart2js_util.nameOf(mirror);
+
+ OwnedIndexable(DeclarationMirror mirror, Indexable owner)
+ : annotations = createAnnotations(mirror, owner.owningLibrary),
+ this.owner = owner,
+ super(mirror);
+
+ /// Generates MDN comments from database.json.
+ String getMdnComment() {
+ var domAnnotation = this.annotations.firstWhere(
+ (e) => e.mirror.qualifiedName == #metadata.DomName,
+ orElse: () => null);
+ if (domAnnotation == null) return '';
+ var domName = domAnnotation.parameters.single;
+
+ return mdnComment(rootDirectory, logger, domName);
+ }
+
+ String get packagePrefix => owner.packagePrefix;
+}

Powered by Google App Engine
This is Rietveld 408576698