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/src/generated/element.dart'; | 7 import 'package:analyzer/src/generated/element.dart'; |
8 import 'package:analyzer/src/generated/resolver.dart'; | 8 import 'package:analyzer/src/generated/resolver.dart'; |
9 import 'package:analyzer/src/generated/utilities_dart.dart'; | 9 import 'package:analyzer/src/generated/utilities_dart.dart'; |
10 import 'package:analyzer/src/summary/builder.dart'; | 10 import 'package:analyzer/src/summary/builder.dart'; |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 } | 533 } |
534 return b; | 534 return b; |
535 } | 535 } |
536 | 536 |
537 /** | 537 /** |
538 * Serialize the given [type] into an [UnlinkedTypeRef]. | 538 * Serialize the given [type] into an [UnlinkedTypeRef]. |
539 */ | 539 */ |
540 UnlinkedTypeRefBuilder serializeTypeRef(DartType type, Element context) { | 540 UnlinkedTypeRefBuilder serializeTypeRef(DartType type, Element context) { |
541 UnlinkedTypeRefBuilder b = new UnlinkedTypeRefBuilder(ctx); | 541 UnlinkedTypeRefBuilder b = new UnlinkedTypeRefBuilder(ctx); |
542 if (type is TypeParameterType) { | 542 if (type is TypeParameterType) { |
543 Element enclosingElement = type.element.enclosingElement; | |
544 b.paramReference = findTypeParameterIndex(type, context); | 543 b.paramReference = findTypeParameterIndex(type, context); |
545 } else { | 544 } else { |
546 Element element = type.element; | 545 Element element = type.element; |
547 CompilationUnitElement dependentCompilationUnit = | |
548 element.getAncestor((Element e) => e is CompilationUnitElement); | |
549 LibraryElement dependentLibrary = element.library; | 546 LibraryElement dependentLibrary = element.library; |
550 if (dependentLibrary == null) { | 547 if (dependentLibrary == null) { |
551 assert(type.isDynamic); | 548 assert(type.isDynamic); |
552 if (type is UndefinedTypeImpl) { | 549 if (type is UndefinedTypeImpl) { |
553 b.reference = serializeUnresolvedReference(); | 550 b.reference = serializeUnresolvedReference(); |
554 } else { | 551 } else { |
555 b.reference = serializeDynamicReference(); | 552 b.reference = serializeDynamicReference(); |
556 } | 553 } |
557 } else { | 554 } else { |
558 b.reference = referenceMap.putIfAbsent(element, () { | 555 b.reference = referenceMap.putIfAbsent(element, () { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 b.name = variable.name; | 621 b.name = variable.name; |
625 b.unit = unitNum; | 622 b.unit = unitNum; |
626 b.type = serializeTypeRef(variable.type, variable); | 623 b.type = serializeTypeRef(variable.type, variable); |
627 b.isStatic = variable.isStatic && variable.enclosingElement is ClassElement; | 624 b.isStatic = variable.isStatic && variable.enclosingElement is ClassElement; |
628 b.isFinal = variable.isFinal; | 625 b.isFinal = variable.isFinal; |
629 b.isConst = variable.isConst; | 626 b.isConst = variable.isConst; |
630 b.hasImplicitType = variable.hasImplicitType; | 627 b.hasImplicitType = variable.hasImplicitType; |
631 return b; | 628 return b; |
632 } | 629 } |
633 } | 630 } |
OLD | NEW |