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

Side by Side Diff: pkg/analyzer/lib/src/dart/element/element.dart

Issue 2814443005: Fix for summarization of generic function type aliases and support for resynthesizing. (Closed)
Patch Set: Created 3 years, 8 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 analyzer.src.dart.element.element; 5 library analyzer.src.dart.element.element;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:math' show min; 8 import 'dart:math' show min;
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 5215 matching lines...) Expand 10 before | Expand all | Expand 10 after
5226 ElementImpl getChild(String identifier) { 5226 ElementImpl getChild(String identifier) {
5227 for (TypeParameterElement typeParameter in typeParameters) { 5227 for (TypeParameterElement typeParameter in typeParameters) {
5228 TypeParameterElementImpl typeParameterImpl = typeParameter; 5228 TypeParameterElementImpl typeParameterImpl = typeParameter;
5229 if (typeParameterImpl.identifier == identifier) { 5229 if (typeParameterImpl.identifier == identifier) {
5230 return typeParameterImpl; 5230 return typeParameterImpl;
5231 } 5231 }
5232 } 5232 }
5233 return null; 5233 return null;
5234 } 5234 }
5235 5235
5236 /**
5237 * Return the type of the function defined by this typedef after substituting
5238 * the given [typeArguments] for the type parameters defined for this typedef
5239 * (but not the type parameters defined by the function). If the number of
5240 * [typeArguments] does not match the number of type parameters, then
5241 * `dynamic` will be used in place of each of the type arguments.
5242 */
5243 FunctionType typeAfterSubstitution(List<DartType> typeArguments) {
5244 FunctionType functionType = function.type;
5245 List<TypeParameterElement> parameterElements = typeParameters;
5246 List<DartType> parameterTypes =
5247 TypeParameterTypeImpl.getTypes(parameterElements);
5248 int parameterCount = parameterTypes.length;
5249 if (typeArguments == null ||
5250 parameterElements.length != typeArguments.length) {
5251 DartType dynamicType = DynamicElementImpl.instance.type;
5252 typeArguments = new List<DartType>.filled(parameterCount, dynamicType);
5253 }
5254 return functionType.substitute2(typeArguments, parameterTypes);
5255 }
5256
5236 @override 5257 @override
5237 void visitChildren(ElementVisitor visitor) { 5258 void visitChildren(ElementVisitor visitor) {
5238 super.visitChildren(visitor); 5259 super.visitChildren(visitor);
5239 safelyVisitChildren(typeParameters, visitor); 5260 safelyVisitChildren(typeParameters, visitor);
5240 function?.accept(visitor); 5261 function?.accept(visitor);
5241 } 5262 }
5242 } 5263 }
5243 5264
5244 /** 5265 /**
5245 * A concrete implementation of a [HideElementCombinator]. 5266 * A concrete implementation of a [HideElementCombinator].
(...skipping 3838 matching lines...) Expand 10 before | Expand all | Expand 10 after
9084 9105
9085 @override 9106 @override
9086 void visitElement(Element element) { 9107 void visitElement(Element element) {
9087 int offset = element.nameOffset; 9108 int offset = element.nameOffset;
9088 if (offset != -1) { 9109 if (offset != -1) {
9089 map[offset] = element; 9110 map[offset] = element;
9090 } 9111 }
9091 super.visitElement(element); 9112 super.visitElement(element);
9092 } 9113 }
9093 } 9114 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/analysis/driver.dart ('k') | pkg/analyzer/lib/src/dart/element/handle.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698