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

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

Issue 2770143002: More generic function type cases working (Closed)
Patch Set: Created 3 years, 9 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/error/error.dart ('k') | pkg/analyzer/lib/src/dart/element/element.dart » ('j') | 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) 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.builder; 5 library analyzer.src.dart.element.builder;
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 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 SimpleIdentifier aliasName = node.name; 449 SimpleIdentifier aliasName = node.name;
450 List<TypeParameterElement> typeParameters = holder.typeParameters; 450 List<TypeParameterElement> typeParameters = holder.typeParameters;
451 GenericTypeAliasElementImpl element = 451 GenericTypeAliasElementImpl element =
452 new GenericTypeAliasElementImpl.forNode(aliasName); 452 new GenericTypeAliasElementImpl.forNode(aliasName);
453 _setCodeRange(element, node); 453 _setCodeRange(element, node);
454 element.metadata = _createElementAnnotations(node.metadata); 454 element.metadata = _createElementAnnotations(node.metadata);
455 setElementDocumentationComment(element, node); 455 setElementDocumentationComment(element, node);
456 element.typeParameters = typeParameters; 456 element.typeParameters = typeParameters;
457 _createTypeParameterTypes(typeParameters); 457 _createTypeParameterTypes(typeParameters);
458 element.type = new FunctionTypeImpl.forTypedef(element); 458 element.type = new FunctionTypeImpl.forTypedef(element);
459 element.function = node.functionType.type.element; 459 element.function = node.functionType?.type?.element;
460 _currentHolder.addTypeAlias(element); 460 _currentHolder.addTypeAlias(element);
461 aliasName.staticElement = element; 461 aliasName.staticElement = element;
462 holder.validate(); 462 holder.validate();
463 return null; 463 return null;
464 } 464 }
465 465
466 @override 466 @override
467 Object visitImportDirective(ImportDirective node) { 467 Object visitImportDirective(ImportDirective node) {
468 List<ElementAnnotation> annotations = 468 List<ElementAnnotation> annotations =
469 _createElementAnnotations(node.metadata); 469 _createElementAnnotations(node.metadata);
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 // visible range 1439 // visible range
1440 _setParameterVisibleRange(node, parameter); 1440 _setParameterVisibleRange(node, parameter);
1441 if (normalParameter is SimpleFormalParameter && 1441 if (normalParameter is SimpleFormalParameter &&
1442 normalParameter.type == null) { 1442 normalParameter.type == null) {
1443 parameter.hasImplicitType = true; 1443 parameter.hasImplicitType = true;
1444 } 1444 }
1445 _currentHolder.addParameter(parameter); 1445 _currentHolder.addParameter(parameter);
1446 if (normalParameter is SimpleFormalParameterImpl) { 1446 if (normalParameter is SimpleFormalParameterImpl) {
1447 normalParameter.element = parameter; 1447 normalParameter.element = parameter;
1448 } 1448 }
1449 parameterName.staticElement = parameter; 1449 parameterName?.staticElement = parameter;
1450 normalParameter.accept(this); 1450 normalParameter.accept(this);
1451 return null; 1451 return null;
1452 } 1452 }
1453 1453
1454 @override 1454 @override
1455 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { 1455 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) {
1456 if (node.parent is! DefaultFormalParameter) { 1456 if (node.parent is! DefaultFormalParameter) {
1457 SimpleIdentifier parameterName = node.identifier; 1457 SimpleIdentifier parameterName = node.identifier;
1458 ParameterElementImpl parameter = 1458 ParameterElementImpl parameter =
1459 new ParameterElementImpl.forNode(parameterName); 1459 new ParameterElementImpl.forNode(parameterName);
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1668 return null; 1668 return null;
1669 } 1669 }
1670 1670
1671 /** 1671 /**
1672 * Return the lexical identifiers associated with the given [identifiers]. 1672 * Return the lexical identifiers associated with the given [identifiers].
1673 */ 1673 */
1674 static List<String> _getIdentifiers(NodeList<SimpleIdentifier> identifiers) { 1674 static List<String> _getIdentifiers(NodeList<SimpleIdentifier> identifiers) {
1675 return identifiers.map((identifier) => identifier.name).toList(); 1675 return identifiers.map((identifier) => identifier.name).toList();
1676 } 1676 }
1677 } 1677 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/error/error.dart ('k') | pkg/analyzer/lib/src/dart/element/element.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698