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

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

Powered by Google App Engine
This is Rietveld 408576698