@@ -38,7 +38,8 @@ Map<String, Map<String, List<Map<String, dynamic>>>> get _crossdartJson {
3838 var crossdartFile =
3939 new File (p.join (config.inputDir.path, "crossdart.json" ));
4040 if (crossdartFile.existsSync ()) {
41- __crossdartJson = JSON .decode (crossdartFile.readAsStringSync ());
41+ __crossdartJson = JSON .decode (crossdartFile.readAsStringSync ())
42+ as Map <String , Map <String , List <Map <String , dynamic >>>>;
4243 } else {
4344 __crossdartJson = {};
4445 }
@@ -361,7 +362,7 @@ class Class extends ModelElement implements EnclosedElement {
361362 return _inheritedMethods;
362363 }
363364
364- List <Method > get inheritedOperators {
365+ List <Operator > get inheritedOperators {
365366 if (_inheritedOperators != null ) return _inheritedOperators;
366367 InheritanceManager manager = new InheritanceManager (element.library);
367368 MemberMap cmap = manager.getMapOfMembersInheritedFromClasses (element);
@@ -708,26 +709,25 @@ abstract class EnclosedElement {
708709}
709710
710711class Enum extends Class {
711- @override
712- List <EnumField > _constants;
712+ List <EnumField > _enumFields;
713713
714714 Enum (ClassElement element, Library library) : super (element, library);
715715
716716 @override
717717 List <EnumField > get constants {
718- if (_constants != null ) return _constants ;
718+ if (_enumFields != null ) return _enumFields ;
719719
720720 // This is a hack to give 'values' an index of -1 and all other fields
721721 // their expected indicies. https://github.com/dart-lang/dartdoc/issues/1176
722722 var index = - 1 ;
723723
724- _constants = _cls.fields
724+ _enumFields = _cls.fields
725725 .where (isPublic)
726726 .where ((f) => f.isConst)
727727 .map ((field) => new EnumField .forConstant (index++ , field, library))
728728 .toList (growable: false )..sort (byName);
729729
730- return _constants ;
730+ return _enumFields ;
731731 }
732732
733733 @override
@@ -1011,8 +1011,8 @@ class Library extends ModelElement {
10111011 if (_functions != null ) return _functions;
10121012
10131013 Set <FunctionElement > elements = new Set ();
1014- elements.addAll (_library .definingCompilationUnit.functions);
1015- for (CompilationUnitElement cu in _library .parts) {
1014+ elements.addAll (_libraryElement .definingCompilationUnit.functions);
1015+ for (CompilationUnitElement cu in _libraryElement .parts) {
10161016 elements.addAll (cu.functions);
10171017 }
10181018 elements.addAll (_exportedNamespace.definedNames.values
@@ -1046,7 +1046,7 @@ class Library extends ModelElement {
10461046
10471047 bool get isDocumented => oneLineDoc.isNotEmpty;
10481048
1049- bool get isInSdk => _library .isInSdk;
1049+ bool get isInSdk => _libraryElement .isInSdk;
10501050
10511051 @override
10521052 String get kind => 'library' ;
@@ -1060,7 +1060,7 @@ class Library extends ModelElement {
10601060
10611061 // handle the case of an anonymous library
10621062 if (element.name == null || element.name.isEmpty) {
1063- _name = _library .definingCompilationUnit.name;
1063+ _name = _libraryElement .definingCompilationUnit.name;
10641064 if (_name.endsWith ('.dart' )) {
10651065 _name = _name.substring (0 , _name.length - '.dart' .length);
10661066 }
@@ -1073,15 +1073,15 @@ class Library extends ModelElement {
10731073 // name is to get source.encoding.
10741074 // This may be wrong or misleading, but developers expect the name
10751075 // of dart:____
1076- var source = _library .definingCompilationUnit.source;
1076+ var source = _libraryElement .definingCompilationUnit.source;
10771077 _name = source.isInSystemLibrary ? source.encoding : _name;
10781078
10791079 return _name;
10801080 }
10811081
10821082 String get packageName {
10831083 if (_packageName == null ) {
1084- String sourcePath = _library .source.fullName;
1084+ String sourcePath = _libraryElement .source.fullName;
10851085 File file = new File (sourcePath);
10861086 if (file.existsSync ()) {
10871087 _packageName = _getPackageName (file.parent);
@@ -1094,7 +1094,7 @@ class Library extends ModelElement {
10941094 return _packageName;
10951095 }
10961096
1097- String get path => _library .definingCompilationUnit.name;
1097+ String get path => _libraryElement .definingCompilationUnit.name;
10981098
10991099 /// All variables ("properties") except constants.
11001100 List <TopLevelVariable > get properties {
@@ -1106,8 +1106,9 @@ class Library extends ModelElement {
11061106 if (_typeDefs != null ) return _typeDefs;
11071107
11081108 Set <FunctionTypeAliasElement > elements = new Set ();
1109- elements.addAll (_library.definingCompilationUnit.functionTypeAliases);
1110- for (CompilationUnitElement cu in _library.parts) {
1109+ elements
1110+ .addAll (_libraryElement.definingCompilationUnit.functionTypeAliases);
1111+ for (CompilationUnitElement cu in _libraryElement.parts) {
11111112 elements.addAll (cu.functionTypeAliases);
11121113 }
11131114
@@ -1125,11 +1126,11 @@ class Library extends ModelElement {
11251126 if (_classes != null ) return _classes;
11261127
11271128 Set <ClassElement > types = new Set ();
1128- types.addAll (_library .definingCompilationUnit.types);
1129- for (CompilationUnitElement cu in _library .parts) {
1129+ types.addAll (_libraryElement .definingCompilationUnit.types);
1130+ for (CompilationUnitElement cu in _libraryElement .parts) {
11301131 types.addAll (cu.types);
11311132 }
1132- for (LibraryElement le in _library .exportedLibraries) {
1133+ for (LibraryElement le in _libraryElement .exportedLibraries) {
11331134 types.addAll (le.definingCompilationUnit.types
11341135 .where ((t) => _exportedNamespace.definedNames.values.contains (t.name))
11351136 .toList ());
@@ -1146,7 +1147,7 @@ class Library extends ModelElement {
11461147 return _classes;
11471148 }
11481149
1149- LibraryElement get _library => (element as LibraryElement );
1150+ LibraryElement get _libraryElement => (element as LibraryElement );
11501151
11511152 Class getClassByName (String name) {
11521153 return _allClasses.firstWhere ((it) => it.name == name, orElse: () => null );
@@ -1168,8 +1169,8 @@ class Library extends ModelElement {
11681169 if (_variables != null ) return _variables;
11691170
11701171 Set <TopLevelVariableElement > elements = new Set ();
1171- elements.addAll (_library .definingCompilationUnit.topLevelVariables);
1172- for (CompilationUnitElement cu in _library .parts) {
1172+ elements.addAll (_libraryElement .definingCompilationUnit.topLevelVariables);
1173+ for (CompilationUnitElement cu in _libraryElement .parts) {
11731174 elements.addAll (cu.topLevelVariables);
11741175 }
11751176 _exportedNamespace.definedNames.values.forEach ((element) {
@@ -1273,21 +1274,21 @@ class Method extends ModelElement
12731274}
12741275
12751276abstract class ModelElement implements Comparable , Nameable , Documentable {
1276- final Element element ;
1277- final Library library ;
1277+ final Element _element ;
1278+ final Library _library ;
12781279
12791280 ElementType _modelType;
12801281 String _rawDocs;
12811282 Documentation __documentation;
1282- List _parameters;
1283+ List < Parameter > _parameters;
12831284 String _linkedName;
12841285
12851286 String _fullyQualifiedName;
12861287
12871288 // WARNING: putting anything into the body of this seems
12881289 // to lead to stack overflows. Need to make a registry of ModelElements
12891290 // somehow.
1290- ModelElement (this .element , this .library );
1291+ ModelElement (this ._element , this ._library );
12911292
12921293 factory ModelElement .from (Element e, Library library) {
12931294 if (e.kind == ElementKind .DYNAMIC ) {
@@ -1388,6 +1389,8 @@ abstract class ModelElement implements Comparable, Nameable, Documentable {
13881389 @override
13891390 String get documentationAsHtml => _documentation.asHtml;
13901391
1392+ Element get element => _element;
1393+
13911394 /// Returns the fully qualified name.
13921395 ///
13931396 /// For example: libraryName.className.methodName
@@ -1456,6 +1459,8 @@ abstract class ModelElement implements Comparable, Nameable, Documentable {
14561459 /// A human-friendly name for the kind of element this is.
14571460 String get kind;
14581461
1462+ Library get library => _library;
1463+
14591464 String get linkedName {
14601465 if (_linkedName == null ) {
14611466 _linkedName = _calculateLinkedName ();
@@ -1906,7 +1911,7 @@ class Package implements Nameable, Documentable {
19061911 }
19071912}
19081913
1909- class PackageCategory implements Comparable {
1914+ class PackageCategory implements Comparable < PackageCategory > {
19101915 final String name;
19111916 final List <Library > _libraries = [];
19121917
@@ -2029,8 +2034,8 @@ abstract class SourceCodeMixin {
20292034
20302035 String get _crossdartPath {
20312036 var node = element.computeNode ();
2032- if (node is Declaration && ( node as Declaration ) .element != null ) {
2033- var source = (( node as Declaration ) .element.source as FileBasedSource );
2037+ if (node is Declaration && node.element != null ) {
2038+ var source = (node.element.source as FileBasedSource );
20342039 var file = source.file.toString ();
20352040 var uri = source.uri.toString ();
20362041 var packageMeta = library.package.packageMeta;
@@ -2077,8 +2082,8 @@ abstract class SourceCodeMixin {
20772082
20782083 int get _lineNumber {
20792084 var node = element.computeNode ();
2080- if (node is Declaration && ( node as Declaration ) .element != null ) {
2081- var element = ( node as Declaration ) .element;
2085+ if (node is Declaration && node.element != null ) {
2086+ var element = node.element;
20822087 var lineNumber = lineNumberCache.lineNumber (
20832088 element.source.fullName, element.nameOffset);
20842089 return lineNumber + 1 ;
0 commit comments