Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: pkg/analyzer/lib/src/summary/summarize_elements.dart

Issue 1610003002: Rename UnlinkedTypeRef to TypeRef. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/element.dart'; 9 import 'package:analyzer/src/dart/element/element.dart';
10 import 'package:analyzer/src/dart/element/type.dart'; 10 import 'package:analyzer/src/dart/element/type.dart';
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 /** 55 /**
56 * Instances of this class keep track of intermediate state during 56 * Instances of this class keep track of intermediate state during
57 * serialization of a single constant [Expression]. 57 * serialization of a single constant [Expression].
58 */ 58 */
59 class _ConstExprSerializer extends AbstractConstExprSerializer { 59 class _ConstExprSerializer extends AbstractConstExprSerializer {
60 final _LibrarySerializer serializer; 60 final _LibrarySerializer serializer;
61 61
62 _ConstExprSerializer(this.serializer); 62 _ConstExprSerializer(this.serializer);
63 63
64 UnlinkedTypeRefBuilder serializeIdentifier(Identifier identifier) { 64 TypeRefBuilder serializeIdentifier(Identifier identifier) {
65 Element element = identifier.staticElement; 65 Element element = identifier.staticElement;
66 assert(element != null); 66 assert(element != null);
67 // TODO(scheglov) how to serialize element references? 67 // TODO(scheglov) how to serialize element references?
68 return new UnlinkedTypeRefBuilder( 68 return new TypeRefBuilder(
69 reference: serializer._getElementReferenceId(element)); 69 reference: serializer._getElementReferenceId(element));
70 } 70 }
71 71
72 @override 72 @override
73 UnlinkedTypeRefBuilder serializeType(TypeName typeName) { 73 TypeRefBuilder serializeType(TypeName typeName) {
74 DartType type = typeName != null ? typeName.type : DynamicTypeImpl.instance; 74 DartType type = typeName != null ? typeName.type : DynamicTypeImpl.instance;
75 return serializer.serializeTypeRef(type, null); 75 return serializer.serializeTypeRef(type, null);
76 } 76 }
77 } 77 }
78 78
79 /** 79 /**
80 * Instances of this class keep track of intermediate state during 80 * Instances of this class keep track of intermediate state during
81 * serialization of a single library. 81 * serialization of a single library.
82 */ 82 */
83 class _LibrarySerializer { 83 class _LibrarySerializer {
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 UnlinkedTypeParamBuilder b = new UnlinkedTypeParamBuilder(); 695 UnlinkedTypeParamBuilder b = new UnlinkedTypeParamBuilder();
696 b.name = typeParameter.name; 696 b.name = typeParameter.name;
697 b.nameOffset = typeParameter.nameOffset; 697 b.nameOffset = typeParameter.nameOffset;
698 if (typeParameter.bound != null) { 698 if (typeParameter.bound != null) {
699 b.bound = serializeTypeRef(typeParameter.bound, typeParameter); 699 b.bound = serializeTypeRef(typeParameter.bound, typeParameter);
700 } 700 }
701 return b; 701 return b;
702 } 702 }
703 703
704 /** 704 /**
705 * Serialize the given [type] into an [UnlinkedTypeRef]. 705 * Serialize the given [type] into a [TypeRef].
706 */ 706 */
707 UnlinkedTypeRefBuilder serializeTypeRef(DartType type, Element context) { 707 TypeRefBuilder serializeTypeRef(DartType type, Element context) {
708 UnlinkedTypeRefBuilder b = new UnlinkedTypeRefBuilder(); 708 TypeRefBuilder b = new TypeRefBuilder();
709 if (type is TypeParameterType) { 709 if (type is TypeParameterType) {
710 b.paramReference = findTypeParameterIndex(type, context); 710 b.paramReference = findTypeParameterIndex(type, context);
711 } else { 711 } else {
712 Element element = type.element; 712 Element element = type.element;
713 LibraryElement dependentLibrary = element.library; 713 LibraryElement dependentLibrary = element.library;
714 if (dependentLibrary == null) { 714 if (dependentLibrary == null) {
715 assert(type.isDynamic); 715 assert(type.isDynamic);
716 if (type is UndefinedTypeImpl) { 716 if (type is UndefinedTypeImpl) {
717 b.reference = serializeUnresolvedReference(); 717 b.reference = serializeUnresolvedReference();
718 } else { 718 } else {
719 b.reference = serializeDynamicReference(); 719 b.reference = serializeDynamicReference();
720 } 720 }
721 } else { 721 } else {
722 b.reference = _getElementReferenceId(element); 722 b.reference = _getElementReferenceId(element);
723 } 723 }
724 List<DartType> typeArguments; 724 List<DartType> typeArguments;
725 if (type is InterfaceType) { 725 if (type is InterfaceType) {
726 typeArguments = type.typeArguments; 726 typeArguments = type.typeArguments;
727 } else if (type is FunctionType) { 727 } else if (type is FunctionType) {
728 typeArguments = type.typeArguments; 728 typeArguments = type.typeArguments;
729 } 729 }
730 if (typeArguments != null) { 730 if (typeArguments != null) {
731 // Trailing type arguments of type 'dynamic' should be omitted. 731 // Trailing type arguments of type 'dynamic' should be omitted.
732 int numArgsToSerialize = typeArguments.length; 732 int numArgsToSerialize = typeArguments.length;
733 while (numArgsToSerialize > 0 && 733 while (numArgsToSerialize > 0 &&
734 typeArguments[numArgsToSerialize - 1].isDynamic) { 734 typeArguments[numArgsToSerialize - 1].isDynamic) {
735 --numArgsToSerialize; 735 --numArgsToSerialize;
736 } 736 }
737 if (numArgsToSerialize > 0) { 737 if (numArgsToSerialize > 0) {
738 List<UnlinkedTypeRefBuilder> serializedArguments = 738 List<TypeRefBuilder> serializedArguments = <TypeRefBuilder>[];
739 <UnlinkedTypeRefBuilder>[];
740 for (int i = 0; i < numArgsToSerialize; i++) { 739 for (int i = 0; i < numArgsToSerialize; i++) {
741 serializedArguments 740 serializedArguments
742 .add(serializeTypeRef(typeArguments[i], context)); 741 .add(serializeTypeRef(typeArguments[i], context));
743 } 742 }
744 b.typeArguments = serializedArguments; 743 b.typeArguments = serializedArguments;
745 } 744 }
746 } 745 }
747 } 746 }
748 return b; 747 return b;
749 } 748 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 } else if (element is ClassElement) { 835 } else if (element is ClassElement) {
837 kind = ReferenceKind.classOrEnum; 836 kind = ReferenceKind.classOrEnum;
838 } else if (element is FunctionElement) { 837 } else if (element is FunctionElement) {
839 kind = ReferenceKind.topLevelFunction; 838 kind = ReferenceKind.topLevelFunction;
840 } else { 839 } else {
841 throw new Exception('Unexpected element kind: ${element.runtimeType}'); 840 throw new Exception('Unexpected element kind: ${element.runtimeType}');
842 } 841 }
843 return kind; 842 return kind;
844 } 843 }
845 } 844 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/summarize_const_expr.dart ('k') | pkg/analyzer/test/src/summary/summary_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698