| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 serialization.elements; | 5 library serialization.elements; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/element/element.dart'; | 7 import 'package:analyzer/dart/element/element.dart'; |
| 8 import 'package:analyzer/dart/element/type.dart'; | 8 import 'package:analyzer/dart/element/type.dart'; |
| 9 import 'package:analyzer/src/dart/element/type.dart'; | 9 import 'package:analyzer/src/dart/element/type.dart'; |
| 10 import 'package:analyzer/src/generated/resolver.dart'; | 10 import 'package:analyzer/src/generated/resolver.dart'; |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 unlinkedReferences = <UnlinkedReferenceBuilder>[ | 160 unlinkedReferences = <UnlinkedReferenceBuilder>[ |
| 161 encodeUnlinkedReference(ctx) | 161 encodeUnlinkedReference(ctx) |
| 162 ]; | 162 ]; |
| 163 prelinkedReferences = <PrelinkedReferenceBuilder>[ | 163 prelinkedReferences = <PrelinkedReferenceBuilder>[ |
| 164 encodePrelinkedReference(ctx, kind: PrelinkedReferenceKind.classOrEnum) | 164 encodePrelinkedReference(ctx, kind: PrelinkedReferenceKind.classOrEnum) |
| 165 ]; | 165 ]; |
| 166 List<UnlinkedPublicNameBuilder> names = <UnlinkedPublicNameBuilder>[]; | 166 List<UnlinkedPublicNameBuilder> names = <UnlinkedPublicNameBuilder>[]; |
| 167 for (PropertyAccessorElement accessor in element.accessors) { | 167 for (PropertyAccessorElement accessor in element.accessors) { |
| 168 if (accessor.isPublic) { | 168 if (accessor.isPublic) { |
| 169 names.add(encodeUnlinkedPublicName(ctx, | 169 names.add(encodeUnlinkedPublicName(ctx, |
| 170 kind: PrelinkedReferenceKind.other, name: accessor.name)); | 170 kind: PrelinkedReferenceKind.other, |
| 171 name: accessor.name, |
| 172 numTypeParameters: accessor.typeParameters.length)); |
| 171 } | 173 } |
| 172 } | 174 } |
| 173 for (ClassElement cls in element.types) { | 175 for (ClassElement cls in element.types) { |
| 174 if (cls.isPublic) { | 176 if (cls.isPublic) { |
| 175 names.add(encodeUnlinkedPublicName(ctx, | 177 names.add(encodeUnlinkedPublicName(ctx, |
| 176 kind: PrelinkedReferenceKind.classOrEnum, name: cls.name)); | 178 kind: PrelinkedReferenceKind.classOrEnum, |
| 179 name: cls.name, |
| 180 numTypeParameters: cls.typeParameters.length)); |
| 177 } | 181 } |
| 178 } | 182 } |
| 179 for (ClassElement enm in element.enums) { | 183 for (ClassElement enm in element.enums) { |
| 180 if (enm.isPublic) { | 184 if (enm.isPublic) { |
| 181 names.add(encodeUnlinkedPublicName(ctx, | 185 names.add(encodeUnlinkedPublicName(ctx, |
| 182 kind: PrelinkedReferenceKind.classOrEnum, name: enm.name)); | 186 kind: PrelinkedReferenceKind.classOrEnum, name: enm.name)); |
| 183 } | 187 } |
| 184 } | 188 } |
| 185 for (FunctionElement function in element.functions) { | 189 for (FunctionElement function in element.functions) { |
| 186 if (function.isPublic) { | 190 if (function.isPublic) { |
| 187 names.add(encodeUnlinkedPublicName(ctx, | 191 names.add(encodeUnlinkedPublicName(ctx, |
| 188 kind: PrelinkedReferenceKind.other, name: function.name)); | 192 kind: PrelinkedReferenceKind.other, |
| 193 name: function.name, |
| 194 numTypeParameters: function.typeParameters.length)); |
| 189 } | 195 } |
| 190 } | 196 } |
| 191 for (FunctionTypeAliasElement typedef in element.functionTypeAliases) { | 197 for (FunctionTypeAliasElement typedef in element.functionTypeAliases) { |
| 192 if (typedef.isPublic) { | 198 if (typedef.isPublic) { |
| 193 names.add(encodeUnlinkedPublicName(ctx, | 199 names.add(encodeUnlinkedPublicName(ctx, |
| 194 kind: PrelinkedReferenceKind.typedef, name: typedef.name)); | 200 kind: PrelinkedReferenceKind.typedef, |
| 201 name: typedef.name, |
| 202 numTypeParameters: typedef.typeParameters.length)); |
| 195 } | 203 } |
| 196 } | 204 } |
| 197 if (unitNum == 0) { | 205 if (unitNum == 0) { |
| 198 if (libraryElement.name.isNotEmpty) { | 206 if (libraryElement.name.isNotEmpty) { |
| 199 b.libraryName = libraryElement.name; | 207 b.libraryName = libraryElement.name; |
| 200 } | 208 } |
| 201 b.publicNamespace = encodeUnlinkedPublicNamespace(ctx, | 209 b.publicNamespace = encodeUnlinkedPublicNamespace(ctx, |
| 202 exports: libraryElement.exports.map(serializeExport).toList(), | 210 exports: libraryElement.exports.map(serializeExport).toList(), |
| 203 parts: libraryElement.parts | 211 parts: libraryElement.parts |
| 204 .map((CompilationUnitElement e) => | 212 .map((CompilationUnitElement e) => |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 UnlinkedVariableBuilder b = new UnlinkedVariableBuilder(ctx); | 647 UnlinkedVariableBuilder b = new UnlinkedVariableBuilder(ctx); |
| 640 b.name = variable.name; | 648 b.name = variable.name; |
| 641 b.type = serializeTypeRef(variable.type, variable); | 649 b.type = serializeTypeRef(variable.type, variable); |
| 642 b.isStatic = variable.isStatic && variable.enclosingElement is ClassElement; | 650 b.isStatic = variable.isStatic && variable.enclosingElement is ClassElement; |
| 643 b.isFinal = variable.isFinal; | 651 b.isFinal = variable.isFinal; |
| 644 b.isConst = variable.isConst; | 652 b.isConst = variable.isConst; |
| 645 b.hasImplicitType = variable.hasImplicitType; | 653 b.hasImplicitType = variable.hasImplicitType; |
| 646 return b; | 654 return b; |
| 647 } | 655 } |
| 648 } | 656 } |
| OLD | NEW |