| 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 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 } else { | 570 } else { |
| 571 b.reference = serializeDynamicReference(); | 571 b.reference = serializeDynamicReference(); |
| 572 } | 572 } |
| 573 } else { | 573 } else { |
| 574 b.reference = referenceMap.putIfAbsent(element, () { | 574 b.reference = referenceMap.putIfAbsent(element, () { |
| 575 assert(unlinkedReferences.length == prelinkedReferences.length); | 575 assert(unlinkedReferences.length == prelinkedReferences.length); |
| 576 CompilationUnitElement unitElement = | 576 CompilationUnitElement unitElement = |
| 577 element.getAncestor((Element e) => e is CompilationUnitElement); | 577 element.getAncestor((Element e) => e is CompilationUnitElement); |
| 578 int unit = dependentLibrary.units.indexOf(unitElement); | 578 int unit = dependentLibrary.units.indexOf(unitElement); |
| 579 assert(unit != -1); | 579 assert(unit != -1); |
| 580 int numTypeParameters = 0; |
| 581 if (element is TypeParameterizedElement) { |
| 582 numTypeParameters = element.typeParameters.length; |
| 583 } |
| 580 int index = unlinkedReferences.length; | 584 int index = unlinkedReferences.length; |
| 581 // TODO(paulberry): set UnlinkedReference.prefix. | 585 // TODO(paulberry): set UnlinkedReference.prefix. |
| 582 unlinkedReferences | 586 unlinkedReferences |
| 583 .add(encodeUnlinkedReference(ctx, name: element.name)); | 587 .add(encodeUnlinkedReference(ctx, name: element.name)); |
| 584 prelinkedReferences.add(encodePrelinkedReference(ctx, | 588 prelinkedReferences.add(encodePrelinkedReference(ctx, |
| 585 dependency: serializeDependency(dependentLibrary), | 589 dependency: serializeDependency(dependentLibrary), |
| 586 kind: element is FunctionTypeAliasElement | 590 kind: element is FunctionTypeAliasElement |
| 587 ? PrelinkedReferenceKind.typedef | 591 ? PrelinkedReferenceKind.typedef |
| 588 : PrelinkedReferenceKind.classOrEnum, | 592 : PrelinkedReferenceKind.classOrEnum, |
| 589 unit: unit)); | 593 unit: unit, |
| 594 numTypeParameters: numTypeParameters)); |
| 590 return index; | 595 return index; |
| 591 }); | 596 }); |
| 592 } | 597 } |
| 593 List<DartType> typeArguments; | 598 List<DartType> typeArguments; |
| 594 if (type is InterfaceType) { | 599 if (type is InterfaceType) { |
| 595 typeArguments = type.typeArguments; | 600 typeArguments = type.typeArguments; |
| 596 } else if (type is FunctionType) { | 601 } else if (type is FunctionType) { |
| 597 typeArguments = type.typeArguments; | 602 typeArguments = type.typeArguments; |
| 598 } | 603 } |
| 599 if (typeArguments != null && | 604 if (typeArguments != null && |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 UnlinkedVariableBuilder b = new UnlinkedVariableBuilder(ctx); | 638 UnlinkedVariableBuilder b = new UnlinkedVariableBuilder(ctx); |
| 634 b.name = variable.name; | 639 b.name = variable.name; |
| 635 b.type = serializeTypeRef(variable.type, variable); | 640 b.type = serializeTypeRef(variable.type, variable); |
| 636 b.isStatic = variable.isStatic && variable.enclosingElement is ClassElement; | 641 b.isStatic = variable.isStatic && variable.enclosingElement is ClassElement; |
| 637 b.isFinal = variable.isFinal; | 642 b.isFinal = variable.isFinal; |
| 638 b.isConst = variable.isConst; | 643 b.isConst = variable.isConst; |
| 639 b.hasImplicitType = variable.hasImplicitType; | 644 b.hasImplicitType = variable.hasImplicitType; |
| 640 return b; | 645 return b; |
| 641 } | 646 } |
| 642 } | 647 } |
| OLD | NEW |