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

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

Issue 242363004: pkg/docgen: moved model classes into minilibs (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
OLDNEW
(Empty)
1 library docgen.models.dummy_mirror;
2
3 import '../exports/mirrors_util.dart' as dart2js_util;
4 import '../exports/source_mirrors.dart';
5
6 import '../library_helpers.dart';
7
8 import 'indexable.dart';
9 import 'model_helpers.dart';
10
11 /// For types that we do not explicitly create or have not yet created in our
12 /// entity map (like core types).
13 class DummyMirror implements Indexable {
14 final DeclarationMirror mirror;
15 /// The library that contains this element, if any. Used as a hint to help
16 /// determine which object we're referring to when looking up this mirror in
17 /// our map.
18 final Indexable owner;
19 DummyMirror(this.mirror, [this.owner]);
20
21 String get docName {
22 if (mirror == null) return '';
23 if (mirror is LibraryMirror) {
24 return dart2js_util.qualifiedNameOf(mirror).replaceAll('.', '-');
25 }
26 var mirrorOwner = mirror.owner;
27 if (mirrorOwner == null) return dart2js_util.qualifiedNameOf(mirror);
28 var simpleName = dart2js_util.nameOf(mirror);
29 if (mirror is MethodMirror && (mirror as MethodMirror).isConstructor) {
30 // We name constructors specially -- repeating the class name and a
31 // "-" to separate the constructor from its name (if any).
32 simpleName = '${dart2js_util.nameOf(mirrorOwner)}-$simpleName';
33 }
34 return getDocgenObject(mirrorOwner, owner).docName + '.' +
35 simpleName;
36 }
37
38 bool get isPrivate => mirror == null ? false : mirror.isPrivate;
39
40 String get packageName {
41 var libMirror = _getOwningLibraryFromMirror(mirror);
42 if (libMirror != null) {
43 return getPackageName(libMirror);
44 }
45 return '';
46 }
47
48 String get packagePrefix => packageName == null || packageName.isEmpty ?
49 '' : '$packageName/';
50
51 LibraryMirror _getOwningLibraryFromMirror(DeclarationMirror mirror) {
52 if (mirror is LibraryMirror) return mirror;
53 if (mirror == null) return null;
54 return _getOwningLibraryFromMirror(mirror.owner);
55 }
56
57 noSuchMethod(Invocation invocation) {
58 throw new UnimplementedError(invocation.memberName.toString());
59 }
60 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698