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

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

Issue 2024453002: Resynthesize parameters lazily. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Extract ParameterElementImpl.resynthesizeList(). Created 4 years, 6 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
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/element.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/token.dart'; 10 import 'package:analyzer/dart/ast/token.dart';
(...skipping 2076 matching lines...) Expand 10 before | Expand all | Expand 10 after
2087 2087
2088 /** 2088 /**
2089 * Handle the parts of an executable element that are common to constructors, 2089 * Handle the parts of an executable element that are common to constructors,
2090 * functions, methods, getters, and setters. 2090 * functions, methods, getters, and setters.
2091 */ 2091 */
2092 void buildExecutableCommonParts(ExecutableElementImpl executableElement, 2092 void buildExecutableCommonParts(ExecutableElementImpl executableElement,
2093 UnlinkedExecutable serializedExecutable) { 2093 UnlinkedExecutable serializedExecutable) {
2094 executableElement.typeParameters = 2094 executableElement.typeParameters =
2095 buildTypeParameters(serializedExecutable.typeParameters); 2095 buildTypeParameters(serializedExecutable.typeParameters);
2096 { 2096 {
2097 List<UnlinkedParam> unlinkedParameters = serializedExecutable.parameters;
2098 int length = unlinkedParameters.length;
2099 if (length != 0) {
2100 List<ParameterElementImpl> parameters =
2101 new List<ParameterElementImpl>(length);
2102 for (int i = 0; i < length; i++) {
2103 parameters[i] = new ParameterElementImpl.forSerializedFactory(
2104 unlinkedParameters[i], executableElement);
2105 }
2106 executableElement.parameters = parameters;
2107 }
2108 }
2109 {
2110 List<UnlinkedExecutable> unlinkedFunctions = 2097 List<UnlinkedExecutable> unlinkedFunctions =
2111 serializedExecutable.localFunctions; 2098 serializedExecutable.localFunctions;
2112 int length = unlinkedFunctions.length; 2099 int length = unlinkedFunctions.length;
2113 if (length != 0) { 2100 if (length != 0) {
2114 List<FunctionElementImpl> localFunctions = 2101 List<FunctionElementImpl> localFunctions =
2115 new List<FunctionElementImpl>(length); 2102 new List<FunctionElementImpl>(length);
2116 for (int i = 0; i < length; i++) { 2103 for (int i = 0; i < length; i++) {
2117 localFunctions[i] = 2104 localFunctions[i] =
2118 buildLocalFunction(unlinkedFunctions[i], executableElement); 2105 buildLocalFunction(unlinkedFunctions[i], executableElement);
2119 } 2106 }
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
2265 if (defaultVoid) { 2252 if (defaultVoid) {
2266 return VoidTypeImpl.instance; 2253 return VoidTypeImpl.instance;
2267 } else { 2254 } else {
2268 return DynamicTypeImpl.instance; 2255 return DynamicTypeImpl.instance;
2269 } 2256 }
2270 } 2257 }
2271 if (type.paramReference != 0) { 2258 if (type.paramReference != 0) {
2272 return typeParameterContext.getTypeParameterType(type.paramReference); 2259 return typeParameterContext.getTypeParameterType(type.paramReference);
2273 } else if (type.syntheticReturnType != null) { 2260 } else if (type.syntheticReturnType != null) {
2274 FunctionElementImpl element = 2261 FunctionElementImpl element =
2275 new FunctionElementImpl_forLUB(unit, typeParameterContext); 2262 new FunctionElementImpl_forLUB(unit, typeParameterContext, type);
2276 element.parameters = type.syntheticParams 2263 return element.type;
2277 .map((UnlinkedParam param) =>
2278 new ParameterElementImpl.forSerializedFactory(param, element,
2279 synthetic: true))
2280 .toList();
2281 element.returnType =
2282 buildType(type.syntheticReturnType, typeParameterContext);
2283 FunctionTypeImpl result = new FunctionTypeImpl.elementWithNameAndArgs(
2284 element, null, null, false);
2285 element.type = result;
2286 return result;
2287 } else { 2264 } else {
2288 DartType getTypeArgument(int i) { 2265 DartType getTypeArgument(int i) {
2289 if (i < type.typeArguments.length) { 2266 if (i < type.typeArguments.length) {
2290 return buildType(type.typeArguments[i], typeParameterContext); 2267 return buildType(type.typeArguments[i], typeParameterContext);
2291 } else { 2268 } else {
2292 return DynamicTypeImpl.instance; 2269 return DynamicTypeImpl.instance;
2293 } 2270 }
2294 } 2271 }
2295 _ReferenceInfo referenceInfo = getReferenceInfo(type.reference); 2272 _ReferenceInfo referenceInfo = getReferenceInfo(type.reference);
2296 return referenceInfo.buildType( 2273 return referenceInfo.buildType(
2297 instantiateToBoundsAllowed, 2274 instantiateToBoundsAllowed,
2298 type.typeArguments.length, 2275 type.typeArguments.length,
2299 getTypeArgument, 2276 getTypeArgument,
2300 type.implicitFunctionTypeIndices); 2277 type.implicitFunctionTypeIndices);
2301 } 2278 }
2302 } 2279 }
2303 2280
2304 /** 2281 /**
2305 * Resynthesize a [FunctionTypeAliasElement] and place it in the 2282 * Resynthesize a [FunctionTypeAliasElement] and place it in the
2306 * [unitHolder]. 2283 * [unitHolder].
2307 */ 2284 */
2308 void buildTypedef(UnlinkedTypedef serializedTypedef) { 2285 void buildTypedef(UnlinkedTypedef serializedTypedef) {
2309 FunctionTypeAliasElementImpl functionTypeAliasElement = 2286 FunctionTypeAliasElementImpl functionTypeAliasElement =
2310 new FunctionTypeAliasElementImpl.forSerialized(serializedTypedef, unit); 2287 new FunctionTypeAliasElementImpl.forSerialized(serializedTypedef, unit);
2311 // TODO(scheglov) remove this after delaying parameters and their types
2312 currentTypeParameters.add(functionTypeAliasElement.typeParameters);
2313 functionTypeAliasElement.parameters = serializedTypedef.parameters
2314 .map((p) => new ParameterElementImpl.forSerializedFactory(
2315 p, functionTypeAliasElement))
2316 .toList();
2317 unitHolder.addTypeAlias(functionTypeAliasElement); 2288 unitHolder.addTypeAlias(functionTypeAliasElement);
2318 // TODO(scheglov) remove this after delaying parameters and their types
2319 currentTypeParameters.removeLast();
2320 assert(currentTypeParameters.isEmpty);
2321 } 2289 }
2322 2290
2323 /** 2291 /**
2324 * Resynthesize a [TypeParameterElement], handling all parts of its except 2292 * Resynthesize a [TypeParameterElement], handling all parts of its except
2325 * its bound. 2293 * its bound.
2326 * 2294 *
2327 * The bound is deferred until later since it may refer to other type 2295 * The bound is deferred until later since it may refer to other type
2328 * parameters that have not been resynthesized yet. To handle the bound, 2296 * parameters that have not been resynthesized yet. To handle the bound,
2329 * call [finishTypeParameter]. 2297 * call [finishTypeParameter].
2330 */ 2298 */
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
2748 static String _getElementIdentifier(String name, ReferenceKind kind) { 2716 static String _getElementIdentifier(String name, ReferenceKind kind) {
2749 if (kind == ReferenceKind.topLevelPropertyAccessor || 2717 if (kind == ReferenceKind.topLevelPropertyAccessor ||
2750 kind == ReferenceKind.propertyAccessor) { 2718 kind == ReferenceKind.propertyAccessor) {
2751 if (!name.endsWith('=')) { 2719 if (!name.endsWith('=')) {
2752 return name + '?'; 2720 return name + '?';
2753 } 2721 }
2754 } 2722 }
2755 return name; 2723 return name;
2756 } 2724 }
2757 } 2725 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/element.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698