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

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

Issue 1619913005: Rename TypeRef to EntityRef. (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 summary_resynthesizer; 5 library summary_resynthesizer;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/dart/element/element.dart'; 9 import 'package:analyzer/dart/element/element.dart';
10 import 'package:analyzer/dart/element/type.dart'; 10 import 'package:analyzer/dart/element/type.dart';
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 * The [LinkedUnit] from which elements are currently being resynthesized. 255 * The [LinkedUnit] from which elements are currently being resynthesized.
256 */ 256 */
257 LinkedUnit linkedUnit; 257 LinkedUnit linkedUnit;
258 258
259 /** 259 /**
260 * The [UnlinkedUnit] from which elements are currently being resynthesized. 260 * The [UnlinkedUnit] from which elements are currently being resynthesized.
261 */ 261 */
262 UnlinkedUnit unlinkedUnit; 262 UnlinkedUnit unlinkedUnit;
263 263
264 /** 264 /**
265 * Map from slot id to the corresponding [TypeRef] object for linked types 265 * Map from slot id to the corresponding [EntityRef] object for linked types
266 * (i.e. propagated and inferred types). 266 * (i.e. propagated and inferred types).
267 */ 267 */
268 Map<int, TypeRef> linkedTypeMap; 268 Map<int, EntityRef> linkedTypeMap;
269 269
270 /** 270 /**
271 * Map of top level elements that have been resynthesized so far. The first 271 * Map of top level elements that have been resynthesized so far. The first
272 * key is the URI of the compilation unit; the second is the name of the top 272 * key is the URI of the compilation unit; the second is the name of the top
273 * level element. 273 * level element.
274 */ 274 */
275 final Map<String, Map<String, Element>> resummarizedElements = 275 final Map<String, Map<String, Element>> resummarizedElements =
276 <String, Map<String, Element>>{}; 276 <String, Map<String, Element>>{};
277 277
278 /** 278 /**
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 867
868 /** 868 /**
869 * Build the appropriate [DartType] object corresponding to a slot id in the 869 * Build the appropriate [DartType] object corresponding to a slot id in the
870 * [LinkedUnit.types] table. 870 * [LinkedUnit.types] table.
871 */ 871 */
872 DartType buildLinkedType(int slot) { 872 DartType buildLinkedType(int slot) {
873 if (slot == 0) { 873 if (slot == 0) {
874 // A slot id of 0 means there is no [DartType] object to build. 874 // A slot id of 0 means there is no [DartType] object to build.
875 return null; 875 return null;
876 } 876 }
877 TypeRef type = linkedTypeMap[slot]; 877 EntityRef type = linkedTypeMap[slot];
878 if (type == null) { 878 if (type == null) {
879 // A missing entry in [LinkedUnit.types] means there is no [DartType] 879 // A missing entry in [LinkedUnit.types] means there is no [DartType]
880 // stored in this slot. 880 // stored in this slot.
881 return null; 881 return null;
882 } 882 }
883 return buildType(type); 883 return buildType(type);
884 } 884 }
885 885
886 /** 886 /**
887 * Resynthesize a [ParameterElement]. 887 * Resynthesize a [ParameterElement].
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 new CompilationUnitElementImpl(unitSource.shortName); 948 new CompilationUnitElementImpl(unitSource.shortName);
949 partUnit.uriOffset = partDecl.uriOffset; 949 partUnit.uriOffset = partDecl.uriOffset;
950 partUnit.uriEnd = partDecl.uriEnd; 950 partUnit.uriEnd = partDecl.uriEnd;
951 partUnit.source = unitSource; 951 partUnit.source = unitSource;
952 partUnit.librarySource = librarySource; 952 partUnit.librarySource = librarySource;
953 partUnit.uri = uri; 953 partUnit.uri = uri;
954 return partUnit; 954 return partUnit;
955 } 955 }
956 956
957 /** 957 /**
958 * Build a [DartType] object based on a [TypeRef]. This [DartType] 958 * Build a [DartType] object based on a [EntityRef]. This [DartType]
959 * may refer to elements in other libraries than the library being 959 * may refer to elements in other libraries than the library being
960 * deserialized, so handles are used to avoid having to deserialize other 960 * deserialized, so handles are used to avoid having to deserialize other
961 * libraries in the process. 961 * libraries in the process.
962 */ 962 */
963 DartType buildType(TypeRef type) { 963 DartType buildType(EntityRef type) {
964 if (type.paramReference != 0) { 964 if (type.paramReference != 0) {
965 // TODO(paulberry): make this work for generic methods. 965 // TODO(paulberry): make this work for generic methods.
966 return currentTypeParameters[ 966 return currentTypeParameters[
967 currentTypeParameters.length - type.paramReference].type; 967 currentTypeParameters.length - type.paramReference].type;
968 } else { 968 } else {
969 // TODO(paulberry): handle references to things other than classes (note: 969 // TODO(paulberry): handle references to things other than classes (note:
970 // this should only occur in the case of erroneous code). 970 // this should only occur in the case of erroneous code).
971 // TODO(paulberry): test reference to something inside a part. 971 // TODO(paulberry): test reference to something inside a part.
972 // TODO(paulberry): test reference to something inside a part of the 972 // TODO(paulberry): test reference to something inside a part of the
973 // current lib. 973 // current lib.
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 <String>[referencedLibraryUri, partUri, name]); 1161 <String>[referencedLibraryUri, partUri, name]);
1162 } 1162 }
1163 1163
1164 /** 1164 /**
1165 * Populate a [CompilationUnitElement] by deserializing all the elements 1165 * Populate a [CompilationUnitElement] by deserializing all the elements
1166 * contained in it. 1166 * contained in it.
1167 */ 1167 */
1168 void populateUnit(CompilationUnitElementImpl unit, int unitNum) { 1168 void populateUnit(CompilationUnitElementImpl unit, int unitNum) {
1169 linkedUnit = linkedLibrary.units[unitNum]; 1169 linkedUnit = linkedLibrary.units[unitNum];
1170 unlinkedUnit = unlinkedUnits[unitNum]; 1170 unlinkedUnit = unlinkedUnits[unitNum];
1171 linkedTypeMap = <int, TypeRef>{}; 1171 linkedTypeMap = <int, EntityRef>{};
1172 for (TypeRef t in linkedUnit.types) { 1172 for (EntityRef t in linkedUnit.types) {
1173 linkedTypeMap[t.slot] = t; 1173 linkedTypeMap[t.slot] = t;
1174 } 1174 }
1175 unitHolder = new ElementHolder(); 1175 unitHolder = new ElementHolder();
1176 unlinkedUnit.classes.forEach(buildClass); 1176 unlinkedUnit.classes.forEach(buildClass);
1177 unlinkedUnit.enums.forEach(buildEnum); 1177 unlinkedUnit.enums.forEach(buildEnum);
1178 unlinkedUnit.executables.forEach(buildExecutable); 1178 unlinkedUnit.executables.forEach(buildExecutable);
1179 unlinkedUnit.typedefs.forEach(buildTypedef); 1179 unlinkedUnit.typedefs.forEach(buildTypedef);
1180 unlinkedUnit.variables.forEach(buildVariable); 1180 unlinkedUnit.variables.forEach(buildVariable);
1181 String absoluteUri = unit.source.uri.toString(); 1181 String absoluteUri = unit.source.uri.toString();
1182 unit.accessors = unitHolder.accessors; 1182 unit.accessors = unitHolder.accessors;
(...skipping 24 matching lines...) Expand all
1207 for (PropertyAccessorElementImpl accessor in unit.accessors) { 1207 for (PropertyAccessorElementImpl accessor in unit.accessors) {
1208 elementMap[accessor.identifier] = accessor; 1208 elementMap[accessor.identifier] = accessor;
1209 } 1209 }
1210 resummarizedElements[absoluteUri] = elementMap; 1210 resummarizedElements[absoluteUri] = elementMap;
1211 unitHolder = null; 1211 unitHolder = null;
1212 linkedUnit = null; 1212 linkedUnit = null;
1213 unlinkedUnit = null; 1213 unlinkedUnit = null;
1214 linkedTypeMap = null; 1214 linkedTypeMap = null;
1215 } 1215 }
1216 } 1216 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698