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

Side by Side Diff: pkg/docgen/lib/src/models/annotation.dart

Issue 243423005: Partial fix for Angular Annotations viewed in Docgen. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library docgen.models.annotation; 5 library docgen.models.annotation;
6 6
7 import '../exports/mirrors_util.dart' as dart2js_util; 7 import '../exports/mirrors_util.dart' as dart2js_util;
8 import '../exports/source_mirrors.dart'; 8 import '../exports/source_mirrors.dart';
9 9
10 import '../library_helpers.dart'; 10 import '../library_helpers.dart';
11 11
12 import 'library.dart'; 12 import 'library.dart';
13 import 'mirror_based.dart'; 13 import 'mirror_based.dart';
14 14
15 /// Holds the name of the annotation, and its parameters. 15 /// Holds the name of the annotation, and its parameters.
16 class Annotation extends MirrorBased { 16 class Annotation extends MirrorBased {
17 /// The class of this annotation. 17 /// The class of this annotation.
18 final ClassMirror mirror; 18 final ClassMirror mirror;
19 final Library owningLibrary; 19 final Library owningLibrary;
20 List<String> parameters; 20 List<String> parameters;
21 21
22 Annotation(InstanceMirror originalMirror, this.owningLibrary) 22 Annotation(InstanceMirror originalMirror, this.owningLibrary)
23 : mirror = originalMirror.type { 23 : mirror = originalMirror.type {
24 parameters = dart2js_util.variablesOf(originalMirror.type.declarations) 24 var curMirror = originalMirror.type;
25 .where((e) => e.isFinal) 25 Map<Symbol, DeclarationMirror> allDeclarations =
26 new Map.from(curMirror.declarations);
27 // This method assumes that our users aren't creating deep inheritance
28 // chains of custom annotation inheritance. If this is not the case,
29 // re-write this section for performance.
30 while (curMirror.superclass != null &&
31 curMirror.superclass.simpleName.toString() != 'Object') {
32 allDeclarations.addAll(curMirror.superclass.declarations);
33 curMirror = curMirror.superclass;
34 }
35
36 // TODO(efortuna): Some originalMirrors, such as the
37 // Dart2JsMapConstantMirror and Dart2JsListConstantMirror don't have a
38 // reflectee field, but we want the value of the parameter from them.
39 // Gross workaround is to assemble the object manually.
40 // See issue 18346.
41 parameters = dart2js_util.variablesOf(allDeclarations)
42 .where((e) => e.isFinal &&
43 originalMirror.getField(e.simpleName).hasReflectee)
26 .map((e) => originalMirror.getField(e.simpleName).reflectee) 44 .map((e) => originalMirror.getField(e.simpleName).reflectee)
27 .where((e) => e != null) 45 .where((e) => e != null)
28 .toList(); 46 .toList();
29 } 47 }
30 48
31 Map toMap() => { 49 Map toMap() => {
32 'name': getDocgenObject(mirror, owningLibrary).docName, 50 'name': getDocgenObject(mirror, owningLibrary).docName,
33 'parameters': parameters 51 'parameters': parameters
34 }; 52 };
35 } 53 }
OLDNEW
« 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