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

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

Issue 2734943002: More support for generic function types (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
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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 element.typeParameters = typeParameters; 420 element.typeParameters = typeParameters;
421 _createTypeParameterTypes(typeParameters); 421 _createTypeParameterTypes(typeParameters);
422 element.type = new FunctionTypeImpl.forTypedef(element); 422 element.type = new FunctionTypeImpl.forTypedef(element);
423 _currentHolder.addTypeAlias(element); 423 _currentHolder.addTypeAlias(element);
424 aliasName.staticElement = element; 424 aliasName.staticElement = element;
425 holder.validate(); 425 holder.validate();
426 return null; 426 return null;
427 } 427 }
428 428
429 @override 429 @override
430 Object visitGenericFunctionType(GenericFunctionType node) {
431 ElementHolder holder = new ElementHolder();
432 _visitChildren(holder, node);
433 FunctionElementImpl element =
434 new FunctionElementImpl.forOffset(node.beginToken.offset);
435 _setCodeRange(element, node);
436 element.parameters = holder.parameters;
437 element.typeParameters = holder.typeParameters;
438 FunctionType type = new FunctionTypeImpl(element);
439 element.type = type;
440 if (node.returnType == null) {
441 element.hasImplicitReturnType = true;
442 }
443 _currentHolder.addFunction(element);
444 (node as GenericFunctionTypeImpl).type = type;
445 holder.validate();
446 return null;
447 }
448
449 @override
450 Object visitGenericTypeAlias(GenericTypeAlias node) {
451 ElementHolder holder = new ElementHolder();
452 _visitChildren(holder, node);
453 SimpleIdentifier aliasName = node.name;
454 List<TypeParameterElement> typeParameters = holder.typeParameters;
455 GenericTypeAliasElementImpl element =
456 new GenericTypeAliasElementImpl.forNode(aliasName);
457 _setCodeRange(element, node);
458 element.metadata = _createElementAnnotations(node.metadata);
459 setElementDocumentationComment(element, node);
460 element.typeParameters = typeParameters;
461 _createTypeParameterTypes(typeParameters);
462 element.type = new FunctionTypeImpl.forTypedef(element);
463 element.function = holder.functions[0];
464 _currentHolder.addTypeAlias(element);
465 aliasName.staticElement = element;
466 holder.validate();
467 return null;
468 }
469
470 @override
430 Object visitImportDirective(ImportDirective node) { 471 Object visitImportDirective(ImportDirective node) {
431 List<ElementAnnotation> annotations = 472 List<ElementAnnotation> annotations =
432 _createElementAnnotations(node.metadata); 473 _createElementAnnotations(node.metadata);
433 _unitElement.setAnnotations(node.offset, annotations); 474 _unitElement.setAnnotations(node.offset, annotations);
434 return super.visitImportDirective(node); 475 return super.visitImportDirective(node);
435 } 476 }
436 477
437 @override 478 @override
438 Object visitLibraryDirective(LibraryDirective node) { 479 Object visitLibraryDirective(LibraryDirective node) {
439 List<ElementAnnotation> annotations = 480 List<ElementAnnotation> annotations =
(...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1631 return null; 1672 return null;
1632 } 1673 }
1633 1674
1634 /** 1675 /**
1635 * Return the lexical identifiers associated with the given [identifiers]. 1676 * Return the lexical identifiers associated with the given [identifiers].
1636 */ 1677 */
1637 static List<String> _getIdentifiers(NodeList<SimpleIdentifier> identifiers) { 1678 static List<String> _getIdentifiers(NodeList<SimpleIdentifier> identifiers) {
1638 return identifiers.map((identifier) => identifier.name).toList(); 1679 return identifiers.map((identifier) => identifier.name).toList();
1639 } 1680 }
1640 } 1681 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698