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

Unified Diff: pkg/docgen/lib/src/models/typedef.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/typedef.dart
diff --git a/pkg/docgen/lib/src/models/typedef.dart b/pkg/docgen/lib/src/models/typedef.dart
new file mode 100644
index 0000000000000000000000000000000000000000..4f3a8e92f3c93453a44aedca4e749eb2597f8de9
--- /dev/null
+++ b/pkg/docgen/lib/src/models/typedef.dart
@@ -0,0 +1,69 @@
+// 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.typedef;
+
+import '../exports/source_mirrors.dart';
+
+import 'package:markdown/markdown.dart' as markdown;
+
+import '../library_helpers.dart';
+
+import 'dummy_mirror.dart';
+import 'library.dart';
+import 'model_helpers.dart';
+import 'generic.dart';
+import 'parameter.dart';
+import 'owned_indexable.dart';
+
+class Typedef extends OwnedIndexable {
+ final String returnType;
+
+ final Map<String, Parameter> parameters;
+
+ /// Generic information about the typedef.
+ final Map<String, Generic> generics;
+
+ /// Returns the [Library] for the given [mirror] if it has already been
+ /// created, else creates it.
+ factory Typedef(TypedefMirror mirror, Library owningLibrary) {
+ var aTypedef = getDocgenObject(mirror, owningLibrary);
+ if (aTypedef is DummyMirror) {
+ aTypedef = new Typedef._(mirror, owningLibrary);
+ }
+ return aTypedef;
+ }
+
+ Typedef._(TypedefMirror mirror, Library owningLibrary)
+ : returnType = getDocgenObject(mirror.referent.returnType).docName,
+ generics = createGenerics(mirror),
+ parameters = createParameters(mirror.referent.parameters,
+ owningLibrary),
+ super(mirror, owningLibrary);
+
+ Map toMap() {
+ var map = {
+ 'name': name,
+ 'qualifiedName': qualifiedName,
+ 'comment': comment,
+ 'return': returnType,
+ 'parameters': recurseMap(parameters),
+ 'annotations': annotations.map((a) => a.toMap()).toList(),
+ 'generics': recurseMap(generics)
+ };
+
+ // Typedef is displayed on the library page as a class, so a preview is
+ // added manually
+ var pre = preview;
+ if (pre != null) map['preview'] = pre;
+
+ return map;
+ }
+
+ markdown.Node fixReference(String name) => null;
+
+ String get typeName => 'typedef';
+
+ bool isValidMirror(DeclarationMirror mirror) => mirror is TypedefMirror;
+}

Powered by Google App Engine
This is Rietveld 408576698