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

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

Issue 2624283003: Revert "Add support for generic function type syntax, part 1" (TBR) (Closed)
Patch Set: Created 3 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/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; 10 import 'package:analyzer/dart/ast/standard_ast_factory.dart';
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 break; 470 break;
471 // invokeMethodRef 471 // invokeMethodRef
472 case UnlinkedExprOperation.invokeMethodRef: 472 case UnlinkedExprOperation.invokeMethodRef:
473 _pushInvokeMethodRef(); 473 _pushInvokeMethodRef();
474 break; 474 break;
475 // containers 475 // containers
476 case UnlinkedExprOperation.makeUntypedList: 476 case UnlinkedExprOperation.makeUntypedList:
477 _pushList(null); 477 _pushList(null);
478 break; 478 break;
479 case UnlinkedExprOperation.makeTypedList: 479 case UnlinkedExprOperation.makeTypedList:
480 TypeAnnotation itemType = _newTypeName(); 480 TypeName itemType = _newTypeName();
481 _pushList( 481 _pushList(AstTestFactory.typeArgumentList(<TypeName>[itemType]));
482 AstTestFactory.typeArgumentList(<TypeAnnotation>[itemType]));
483 break; 482 break;
484 case UnlinkedExprOperation.makeUntypedMap: 483 case UnlinkedExprOperation.makeUntypedMap:
485 _pushMap(null); 484 _pushMap(null);
486 break; 485 break;
487 case UnlinkedExprOperation.makeTypedMap: 486 case UnlinkedExprOperation.makeTypedMap:
488 TypeAnnotation keyType = _newTypeName(); 487 TypeName keyType = _newTypeName();
489 TypeAnnotation valueType = _newTypeName(); 488 TypeName valueType = _newTypeName();
490 _pushMap(AstTestFactory 489 _pushMap(
491 .typeArgumentList(<TypeAnnotation>[keyType, valueType])); 490 AstTestFactory.typeArgumentList(<TypeName>[keyType, valueType]));
492 break; 491 break;
493 case UnlinkedExprOperation.pushReference: 492 case UnlinkedExprOperation.pushReference:
494 _pushReference(); 493 _pushReference();
495 break; 494 break;
496 case UnlinkedExprOperation.extractProperty: 495 case UnlinkedExprOperation.extractProperty:
497 _pushExtractProperty(); 496 _pushExtractProperty();
498 break; 497 break;
499 case UnlinkedExprOperation.invokeConstructor: 498 case UnlinkedExprOperation.invokeConstructor:
500 _pushInstanceCreation(); 499 _pushInstanceCreation();
501 break; 500 break;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 if (enclosing is SimpleIdentifier) { 572 if (enclosing is SimpleIdentifier) {
574 SimpleIdentifier identifier = AstTestFactory.identifier3(info.name) 573 SimpleIdentifier identifier = AstTestFactory.identifier3(info.name)
575 ..staticElement = element; 574 ..staticElement = element;
576 return AstTestFactory.identifier(enclosing, identifier); 575 return AstTestFactory.identifier(enclosing, identifier);
577 } 576 }
578 SimpleIdentifier property = AstTestFactory.identifier3(info.name) 577 SimpleIdentifier property = AstTestFactory.identifier3(info.name)
579 ..staticElement = element; 578 ..staticElement = element;
580 return AstTestFactory.propertyAccess(enclosing, property); 579 return AstTestFactory.propertyAccess(enclosing, property);
581 } 580 }
582 581
583 TypeAnnotation _buildTypeAst(DartType type) { 582 TypeName _buildTypeAst(DartType type) {
584 List<TypeAnnotation> argumentNodes; 583 List<TypeName> argumentNodes;
585 if (type is ParameterizedType) { 584 if (type is ParameterizedType) {
586 if (!resynthesizer.libraryResynthesizer.typesWithImplicitTypeArguments 585 if (!resynthesizer.libraryResynthesizer.typesWithImplicitTypeArguments
587 .contains(type)) { 586 .contains(type)) {
588 List<DartType> typeArguments = type.typeArguments; 587 List<DartType> typeArguments = type.typeArguments;
589 argumentNodes = typeArguments.every((a) => a.isDynamic) 588 argumentNodes = typeArguments.every((a) => a.isDynamic)
590 ? null 589 ? null
591 : typeArguments.map(_buildTypeAst).toList(); 590 : typeArguments.map(_buildTypeAst).toList();
592 } 591 }
593 } 592 }
594 TypeName node = AstTestFactory.typeName4(type.name, argumentNodes); 593 TypeName node = AstTestFactory.typeName4(type.name, argumentNodes);
(...skipping 13 matching lines...) Expand all
608 TokenFactory.tokenFromType(TokenType.STRING_INTERPOLATION_EXPRESSION), 607 TokenFactory.tokenFromType(TokenType.STRING_INTERPOLATION_EXPRESSION),
609 expr, 608 expr,
610 TokenFactory.tokenFromType(TokenType.CLOSE_CURLY_BRACKET)); 609 TokenFactory.tokenFromType(TokenType.CLOSE_CURLY_BRACKET));
611 } 610 }
612 } 611 }
613 612
614 /** 613 /**
615 * Convert the next reference to the [DartType] and return the AST 614 * Convert the next reference to the [DartType] and return the AST
616 * corresponding to this type. 615 * corresponding to this type.
617 */ 616 */
618 TypeAnnotation _newTypeName() { 617 TypeName _newTypeName() {
619 EntityRef typeRef = uc.references[refPtr++]; 618 EntityRef typeRef = uc.references[refPtr++];
620 DartType type = 619 DartType type =
621 resynthesizer.buildType(typeRef, context?.typeParameterContext); 620 resynthesizer.buildType(typeRef, context?.typeParameterContext);
622 return _buildTypeAst(type); 621 return _buildTypeAst(type);
623 } 622 }
624 623
625 Expression _pop() => stack.removeLast(); 624 Expression _pop() => stack.removeLast();
626 625
627 void _push(Expression expr) { 626 void _push(Expression expr) {
628 stack.add(expr); 627 stack.add(expr);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 } 717 }
719 718
720 void _pushInvokeMethodRef() { 719 void _pushInvokeMethodRef() {
721 List<Expression> arguments = _buildArguments(); 720 List<Expression> arguments = _buildArguments();
722 EntityRef ref = uc.references[refPtr++]; 721 EntityRef ref = uc.references[refPtr++];
723 _ReferenceInfo info = resynthesizer.getReferenceInfo(ref.reference); 722 _ReferenceInfo info = resynthesizer.getReferenceInfo(ref.reference);
724 Expression node = _buildIdentifierSequence(info); 723 Expression node = _buildIdentifierSequence(info);
725 TypeArgumentList typeArguments; 724 TypeArgumentList typeArguments;
726 int numTypeArguments = uc.ints[intPtr++]; 725 int numTypeArguments = uc.ints[intPtr++];
727 if (numTypeArguments > 0) { 726 if (numTypeArguments > 0) {
728 List<TypeAnnotation> typeNames = 727 List<TypeName> typeNames = new List<TypeName>(numTypeArguments);
729 new List<TypeAnnotation>(numTypeArguments);
730 for (int i = 0; i < numTypeArguments; i++) { 728 for (int i = 0; i < numTypeArguments; i++) {
731 typeNames[i] = _newTypeName(); 729 typeNames[i] = _newTypeName();
732 } 730 }
733 typeArguments = AstTestFactory.typeArgumentList(typeNames); 731 typeArguments = AstTestFactory.typeArgumentList(typeNames);
734 } 732 }
735 if (node is SimpleIdentifier) { 733 if (node is SimpleIdentifier) {
736 _push(astFactory.methodInvocation( 734 _push(astFactory.methodInvocation(
737 null, 735 null,
738 TokenFactory.tokenFromType(TokenType.PERIOD), 736 TokenFactory.tokenFromType(TokenType.PERIOD),
739 node, 737 node,
(...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1914 static String _getElementIdentifier(String name, ReferenceKind kind) { 1912 static String _getElementIdentifier(String name, ReferenceKind kind) {
1915 if (kind == ReferenceKind.topLevelPropertyAccessor || 1913 if (kind == ReferenceKind.topLevelPropertyAccessor ||
1916 kind == ReferenceKind.propertyAccessor) { 1914 kind == ReferenceKind.propertyAccessor) {
1917 if (!name.endsWith('=')) { 1915 if (!name.endsWith('=')) {
1918 return name + '?'; 1916 return name + '?';
1919 } 1917 }
1920 } 1918 }
1921 return name; 1919 return name;
1922 } 1920 }
1923 } 1921 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/testing/ast_test_factory.dart ('k') | pkg/analyzer/lib/src/summary/summarize_ast.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698