| OLD | NEW |
| 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.indexable; | 5 library docgen.models.indexable; |
| 6 | 6 |
| 7 import 'dart:collection'; |
| 8 |
| 7 import 'package:markdown/markdown.dart' as markdown; | 9 import 'package:markdown/markdown.dart' as markdown; |
| 8 | 10 |
| 9 import '../exports/mirrors_util.dart' as dart2js_util; | 11 import '../exports/mirrors_util.dart' as dart2js_util; |
| 10 import '../exports/source_mirrors.dart'; | 12 import '../exports/source_mirrors.dart'; |
| 11 | 13 |
| 12 import '../library_helpers.dart'; | 14 import '../library_helpers.dart'; |
| 13 import 'library.dart'; | 15 import 'library.dart'; |
| 14 import 'mirror_based.dart'; | 16 import 'mirror_based.dart'; |
| 15 import 'model_helpers.dart'; | 17 import 'model_helpers.dart'; |
| 16 | 18 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 43 /// methods need to resolve links differently from the superclass. | 45 /// methods need to resolve links differently from the superclass. |
| 44 String unresolvedComment = ''; | 46 String unresolvedComment = ''; |
| 45 | 47 |
| 46 Indexable(TMirror mirror) | 48 Indexable(TMirror mirror) |
| 47 : this.mirror = mirror, | 49 : this.mirror = mirror, |
| 48 this.isPrivate = isHidden(mirror) { | 50 this.isPrivate = isHidden(mirror) { |
| 49 | 51 |
| 50 var mirrorQualifiedName = dart2js_util.qualifiedNameOf(this.mirror); | 52 var mirrorQualifiedName = dart2js_util.qualifiedNameOf(this.mirror); |
| 51 | 53 |
| 52 var map = _mirrorToDocgen.putIfAbsent(mirrorQualifiedName, | 54 var map = _mirrorToDocgen.putIfAbsent(mirrorQualifiedName, |
| 53 () => new Map<String, Indexable>()); | 55 () => new HashMap<String, Indexable>()); |
| 54 | 56 |
| 55 var added = false; | 57 var added = false; |
| 56 map.putIfAbsent(owner.docName, () { | 58 map.putIfAbsent(owner.docName, () { |
| 57 added = true; | 59 added = true; |
| 58 return this; | 60 return this; |
| 59 }); | 61 }); |
| 60 | 62 |
| 61 if (!added) { | 63 if (!added) { |
| 62 throw new StateError('An indexable has already been stored for ' | 64 throw new StateError('An indexable has already been stored for ' |
| 63 '${owner.docName}'); | 65 '${owner.docName}'); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 bool isValidMirror(DeclarationMirror mirror); | 199 bool isValidMirror(DeclarationMirror mirror); |
| 198 } | 200 } |
| 199 | 201 |
| 200 /// Index of all the dart2js mirrors examined to corresponding MirrorBased | 202 /// Index of all the dart2js mirrors examined to corresponding MirrorBased |
| 201 /// docgen objects. | 203 /// docgen objects. |
| 202 /// | 204 /// |
| 203 /// Used for lookup because of the dart2js mirrors exports | 205 /// Used for lookup because of the dart2js mirrors exports |
| 204 /// issue. The second level map is indexed by owner docName for faster lookup. | 206 /// issue. The second level map is indexed by owner docName for faster lookup. |
| 205 /// Why two levels of lookup? Speed, man. Speed. | 207 /// Why two levels of lookup? Speed, man. Speed. |
| 206 final Map<String, Map<String, Indexable>> _mirrorToDocgen = | 208 final Map<String, Map<String, Indexable>> _mirrorToDocgen = |
| 207 new Map<String, Map<String, Indexable>>(); | 209 new HashMap<String, Map<String, Indexable>>(); |
| 208 | 210 |
| 209 Iterable<Indexable> get allIndexables => | 211 Iterable<Indexable> get allIndexables => |
| 210 _mirrorToDocgen.values.expand((map) => map.values); | 212 _mirrorToDocgen.values.expand((map) => map.values); |
| 211 | 213 |
| 212 Map<String, Indexable> lookupIndexableMap(DeclarationMirror mirror) { | 214 Map<String, Indexable> lookupIndexableMap(DeclarationMirror mirror) { |
| 213 return _mirrorToDocgen[dart2js_util.qualifiedNameOf(mirror)]; | 215 return _mirrorToDocgen[dart2js_util.qualifiedNameOf(mirror)]; |
| 214 } | 216 } |
| OLD | NEW |