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

Side by Side Diff: pkg/analyzer/lib/dart/ast/ast_factory.dart

Issue 2613383003: Add support for generic function type syntax, part 1 (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
« no previous file with comments | « pkg/analyzer/lib/dart/ast/ast.dart ('k') | pkg/analyzer/lib/dart/ast/resolution_map.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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 import 'package:analyzer/dart/ast/ast.dart'; 5 import 'package:analyzer/dart/ast/ast.dart';
6 import 'package:analyzer/src/generated/utilities_dart.dart'; 6 import 'package:analyzer/src/generated/utilities_dart.dart';
7 import 'package:front_end/src/scanner/token.dart'; 7 import 'package:front_end/src/scanner/token.dart';
8 8
9 /** 9 /**
10 * A collection of factory methods which may be used to create concrete 10 * A collection of factory methods which may be used to create concrete
(...skipping 21 matching lines...) Expand all
32 * Returns a newly created list of arguments. The list of [arguments] can 32 * Returns a newly created list of arguments. The list of [arguments] can
33 * be `null` if there are no arguments. 33 * be `null` if there are no arguments.
34 */ 34 */
35 ArgumentList argumentList(Token leftParenthesis, List<Expression> arguments, 35 ArgumentList argumentList(Token leftParenthesis, List<Expression> arguments,
36 Token rightParenthesis); 36 Token rightParenthesis);
37 37
38 /** 38 /**
39 * Returns a newly created as expression. 39 * Returns a newly created as expression.
40 */ 40 */
41 AsExpression asExpression( 41 AsExpression asExpression(
42 Expression expression, Token asOperator, TypeName type); 42 Expression expression, Token asOperator, TypeAnnotation type);
43 43
44 /** 44 /**
45 * Returns a newly created assert initializer. The [comma] and [message] 45 * Returns a newly created assert initializer. The [comma] and [message]
46 * can be `null` if there is no message. 46 * can be `null` if there is no message.
47 */ 47 */
48 AssertInitializer assertInitializer( 48 AssertInitializer assertInitializer(
49 Token assertKeyword, 49 Token assertKeyword,
50 Token leftParenthesis, 50 Token leftParenthesis,
51 Expression condition, 51 Expression condition,
52 Token comma, 52 Token comma,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 Expression target, List<Expression> cascadeSections); 121 Expression target, List<Expression> cascadeSections);
122 122
123 /** 123 /**
124 * Returns a newly created catch clause. The [onKeyword] and 124 * Returns a newly created catch clause. The [onKeyword] and
125 * [exceptionType] can be `null` if the clause will catch all exceptions. The 125 * [exceptionType] can be `null` if the clause will catch all exceptions. The
126 * [comma] and [stackTraceParameter] can be `null` if the stack trace 126 * [comma] and [stackTraceParameter] can be `null` if the stack trace
127 * parameter is not defined. 127 * parameter is not defined.
128 */ 128 */
129 CatchClause catchClause( 129 CatchClause catchClause(
130 Token onKeyword, 130 Token onKeyword,
131 TypeName exceptionType, 131 TypeAnnotation exceptionType,
132 Token catchKeyword, 132 Token catchKeyword,
133 Token leftParenthesis, 133 Token leftParenthesis,
134 SimpleIdentifier exceptionParameter, 134 SimpleIdentifier exceptionParameter,
135 Token comma, 135 Token comma,
136 SimpleIdentifier stackTraceParameter, 136 SimpleIdentifier stackTraceParameter,
137 Token rightParenthesis, 137 Token rightParenthesis,
138 Block body); 138 Block body);
139 139
140 /** 140 /**
141 * Returns a newly created class declaration. Either or both of the 141 * Returns a newly created class declaration. Either or both of the
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 /** 283 /**
284 * Returns a newly created formal parameter. Either or both of the 284 * Returns a newly created formal parameter. Either or both of the
285 * [comment] and [metadata] can be `null` if the declaration does not have the 285 * [comment] and [metadata] can be `null` if the declaration does not have the
286 * corresponding attribute. The [keyword] can be `null` if a type name is 286 * corresponding attribute. The [keyword] can be `null` if a type name is
287 * given. The [type] must be `null` if the keyword is 'var'. 287 * given. The [type] must be `null` if the keyword is 'var'.
288 */ 288 */
289 DeclaredIdentifier declaredIdentifier( 289 DeclaredIdentifier declaredIdentifier(
290 Comment comment, 290 Comment comment,
291 List<Annotation> metadata, 291 List<Annotation> metadata,
292 Token keyword, 292 Token keyword,
293 TypeName type, 293 TypeAnnotation type,
294 SimpleIdentifier identifier); 294 SimpleIdentifier identifier);
295 295
296 /** 296 /**
297 * Returns a newly created default formal parameter. The [separator] and 297 * Returns a newly created default formal parameter. The [separator] and
298 * [defaultValue] can be `null` if there is no default value. 298 * [defaultValue] can be `null` if there is no default value.
299 */ 299 */
300 DefaultFormalParameter defaultFormalParameter(NormalFormalParameter parameter, 300 DefaultFormalParameter defaultFormalParameter(NormalFormalParameter parameter,
301 ParameterKind kind, Token separator, Expression defaultValue); 301 ParameterKind kind, Token separator, Expression defaultValue);
302 302
303 /** 303 /**
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 * corresponding attribute. The [keyword] can be `null` if there is a type. 416 * corresponding attribute. The [keyword] can be `null` if there is a type.
417 * The [type] must be `null` if the keyword is 'var'. The [thisKeyword] and 417 * The [type] must be `null` if the keyword is 'var'. The [thisKeyword] and
418 * [period] can be `null` if the keyword 'this' was not provided. The 418 * [period] can be `null` if the keyword 'this' was not provided. The
419 * [parameters] can be `null` if this is not a function-typed field formal 419 * [parameters] can be `null` if this is not a function-typed field formal
420 * parameter. 420 * parameter.
421 */ 421 */
422 FieldFormalParameter fieldFormalParameter( 422 FieldFormalParameter fieldFormalParameter(
423 Comment comment, 423 Comment comment,
424 List<Annotation> metadata, 424 List<Annotation> metadata,
425 Token keyword, 425 Token keyword,
426 TypeName type, 426 TypeAnnotation type,
427 Token thisKeyword, 427 Token thisKeyword,
428 Token period, 428 Token period,
429 SimpleIdentifier identifier, 429 SimpleIdentifier identifier,
430 TypeParameterList typeParameters, 430 TypeParameterList typeParameters,
431 FormalParameterList parameters); 431 FormalParameterList parameters);
432 432
433 /** 433 /**
434 * Returns a newly created for-each statement whose loop control variable 434 * Returns a newly created for-each statement whose loop control variable
435 * is declared internally (in the for-loop part). The [awaitKeyword] can be 435 * is declared internally (in the for-loop part). The [awaitKeyword] can be
436 * `null` if this is not an asynchronous for loop. 436 * `null` if this is not an asynchronous for loop.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 * [comment] and [metadata] can be `null` if the function does not have the 495 * [comment] and [metadata] can be `null` if the function does not have the
496 * corresponding attribute. The [externalKeyword] can be `null` if the 496 * corresponding attribute. The [externalKeyword] can be `null` if the
497 * function is not an external function. The [returnType] can be `null` if no 497 * function is not an external function. The [returnType] can be `null` if no
498 * return type was specified. The [propertyKeyword] can be `null` if the 498 * return type was specified. The [propertyKeyword] can be `null` if the
499 * function is neither a getter or a setter. 499 * function is neither a getter or a setter.
500 */ 500 */
501 FunctionDeclaration functionDeclaration( 501 FunctionDeclaration functionDeclaration(
502 Comment comment, 502 Comment comment,
503 List<Annotation> metadata, 503 List<Annotation> metadata,
504 Token externalKeyword, 504 Token externalKeyword,
505 TypeName returnType, 505 TypeAnnotation returnType,
506 Token propertyKeyword, 506 Token propertyKeyword,
507 SimpleIdentifier name, 507 SimpleIdentifier name,
508 FunctionExpression functionExpression); 508 FunctionExpression functionExpression);
509 509
510 /** 510 /**
511 * Returns a newly created function declaration statement. 511 * Returns a newly created function declaration statement.
512 */ 512 */
513 FunctionDeclarationStatement functionDeclarationStatement( 513 FunctionDeclarationStatement functionDeclarationStatement(
514 FunctionDeclaration functionDeclaration); 514 FunctionDeclaration functionDeclaration);
515 515
(...skipping 13 matching lines...) Expand all
529 * Returns a newly created function type alias. Either or both of the 529 * Returns a newly created function type alias. Either or both of the
530 * [comment] and [metadata] can be `null` if the function does not have the 530 * [comment] and [metadata] can be `null` if the function does not have the
531 * corresponding attribute. The [returnType] can be `null` if no return type 531 * corresponding attribute. The [returnType] can be `null` if no return type
532 * was specified. The [typeParameters] can be `null` if the function has no 532 * was specified. The [typeParameters] can be `null` if the function has no
533 * type parameters. 533 * type parameters.
534 */ 534 */
535 FunctionTypeAlias functionTypeAlias( 535 FunctionTypeAlias functionTypeAlias(
536 Comment comment, 536 Comment comment,
537 List<Annotation> metadata, 537 List<Annotation> metadata,
538 Token keyword, 538 Token keyword,
539 TypeName returnType, 539 TypeAnnotation returnType,
540 SimpleIdentifier name, 540 SimpleIdentifier name,
541 TypeParameterList typeParameters, 541 TypeParameterList typeParameters,
542 FormalParameterList parameters, 542 FormalParameterList parameters,
543 Token semicolon); 543 Token semicolon);
544 544
545 /** 545 /**
546 * Returns a newly created formal parameter. Either or both of the 546 * Returns a newly created formal parameter. Either or both of the
547 * [comment] and [metadata] can be `null` if the parameter does not have the 547 * [comment] and [metadata] can be `null` if the parameter does not have the
548 * corresponding attribute. The [returnType] can be `null` if no return type 548 * corresponding attribute. The [returnType] can be `null` if no return type
549 * was specified. 549 * was specified.
550 */ 550 */
551 FunctionTypedFormalParameter functionTypedFormalParameter( 551 FunctionTypedFormalParameter functionTypedFormalParameter(
552 Comment comment, 552 Comment comment,
553 List<Annotation> metadata, 553 List<Annotation> metadata,
554 TypeName returnType, 554 TypeAnnotation returnType,
555 SimpleIdentifier identifier, 555 SimpleIdentifier identifier,
556 TypeParameterList typeParameters, 556 TypeParameterList typeParameters,
557 FormalParameterList parameters, 557 FormalParameterList parameters,
558 {Token question: null}); 558 {Token question: null});
559 559
560 /** 560 /**
561 * Returns a newly created import show combinator. 561 * Returns a newly created import show combinator.
562 */ 562 */
563 HideCombinator hideCombinator( 563 HideCombinator hideCombinator(
564 Token keyword, List<SimpleIdentifier> hiddenNames); 564 Token keyword, List<SimpleIdentifier> hiddenNames);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 * Returns a newly created string of characters that are part of a string 635 * Returns a newly created string of characters that are part of a string
636 * interpolation. 636 * interpolation.
637 */ 637 */
638 InterpolationString interpolationString(Token contents, String value); 638 InterpolationString interpolationString(Token contents, String value);
639 639
640 /** 640 /**
641 * Returns a newly created is expression. The [notOperator] can be `null` 641 * Returns a newly created is expression. The [notOperator] can be `null`
642 * if the sense of the test is not negated. 642 * if the sense of the test is not negated.
643 */ 643 */
644 IsExpression isExpression(Expression expression, Token isOperator, 644 IsExpression isExpression(Expression expression, Token isOperator,
645 Token notOperator, TypeName type); 645 Token notOperator, TypeAnnotation type);
646 646
647 /** 647 /**
648 * Returns a newly created label. 648 * Returns a newly created label.
649 */ 649 */
650 Label label(SimpleIdentifier label, Token colon); 650 Label label(SimpleIdentifier label, Token colon);
651 651
652 /** 652 /**
653 * Returns a newly created labeled statement. 653 * Returns a newly created labeled statement.
654 */ 654 */
655 LabeledStatement labeledStatement(List<Label> labels, Statement statement); 655 LabeledStatement labeledStatement(List<Label> labels, Statement statement);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 * type was specified. The [propertyKeyword] can be `null` if the method is 699 * type was specified. The [propertyKeyword] can be `null` if the method is
700 * neither a getter or a setter. The [operatorKeyword] can be `null` if the 700 * neither a getter or a setter. The [operatorKeyword] can be `null` if the
701 * method does not implement an operator. The [parameters] must be `null` if 701 * method does not implement an operator. The [parameters] must be `null` if
702 * this method declares a getter. 702 * this method declares a getter.
703 */ 703 */
704 MethodDeclaration methodDeclaration( 704 MethodDeclaration methodDeclaration(
705 Comment comment, 705 Comment comment,
706 List<Annotation> metadata, 706 List<Annotation> metadata,
707 Token externalKeyword, 707 Token externalKeyword,
708 Token modifierKeyword, 708 Token modifierKeyword,
709 TypeName returnType, 709 TypeAnnotation returnType,
710 Token propertyKeyword, 710 Token propertyKeyword,
711 Token operatorKeyword, 711 Token operatorKeyword,
712 SimpleIdentifier name, 712 SimpleIdentifier name,
713 TypeParameterList typeParameters, 713 TypeParameterList typeParameters,
714 FormalParameterList parameters, 714 FormalParameterList parameters,
715 FunctionBody body); 715 FunctionBody body);
716 716
717 /** 717 /**
718 * Returns a newly created method invocation. The [target] and [operator] 718 * Returns a newly created method invocation. The [target] and [operator]
719 * can be `null` if there is no target. 719 * can be `null` if there is no target.
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 /** 842 /**
843 * Returns a newly created formal parameter. Either or both of the 843 * Returns a newly created formal parameter. Either or both of the
844 * [comment] and [metadata] can be `null` if the parameter does not have the 844 * [comment] and [metadata] can be `null` if the parameter does not have the
845 * corresponding attribute. The [keyword] can be `null` if a type was 845 * corresponding attribute. The [keyword] can be `null` if a type was
846 * specified. The [type] must be `null` if the keyword is 'var'. 846 * specified. The [type] must be `null` if the keyword is 'var'.
847 */ 847 */
848 SimpleFormalParameter simpleFormalParameter( 848 SimpleFormalParameter simpleFormalParameter(
849 Comment comment, 849 Comment comment,
850 List<Annotation> metadata, 850 List<Annotation> metadata,
851 Token keyword, 851 Token keyword,
852 TypeName type, 852 TypeAnnotation type,
853 SimpleIdentifier identifier); 853 SimpleIdentifier identifier);
854 854
855 /** 855 /**
856 * Returns a newly created identifier. 856 * Returns a newly created identifier.
857 */ 857 */
858 SimpleIdentifier simpleIdentifier(Token token, {bool isDeclaration: false}); 858 SimpleIdentifier simpleIdentifier(Token token, {bool isDeclaration: false});
859 859
860 /** 860 /**
861 * Returns a newly created simple string literal. 861 * Returns a newly created simple string literal.
862 */ 862 */
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 * `null` if there are no catch clauses. The [finallyKeyword] and 941 * `null` if there are no catch clauses. The [finallyKeyword] and
942 * [finallyBlock] can be `null` if there is no finally clause. 942 * [finallyBlock] can be `null` if there is no finally clause.
943 */ 943 */
944 TryStatement tryStatement(Token tryKeyword, Block body, 944 TryStatement tryStatement(Token tryKeyword, Block body,
945 List<CatchClause> catchClauses, Token finallyKeyword, Block finallyBlock); 945 List<CatchClause> catchClauses, Token finallyKeyword, Block finallyBlock);
946 946
947 /** 947 /**
948 * Returns a newly created list of type arguments. 948 * Returns a newly created list of type arguments.
949 */ 949 */
950 TypeArgumentList typeArgumentList( 950 TypeArgumentList typeArgumentList(
951 Token leftBracket, List<TypeName> arguments, Token rightBracket); 951 Token leftBracket, List<TypeAnnotation> arguments, Token rightBracket);
952 952
953 /** 953 /**
954 * Returns a newly created type name. The [typeArguments] can be `null` if 954 * Returns a newly created type name. The [typeArguments] can be `null` if
955 * there are no type arguments. 955 * there are no type arguments.
956 */ 956 */
957 TypeName typeName(Identifier name, TypeArgumentList typeArguments, 957 TypeName typeName(Identifier name, TypeArgumentList typeArguments,
958 {Token question: null}); 958 {Token question: null});
959 959
960 /** 960 /**
961 * Returns a newly created type parameter. Either or both of the [comment] 961 * Returns a newly created type parameter. Either or both of the [comment]
962 * and [metadata] can be `null` if the parameter does not have the 962 * and [metadata] can be `null` if the parameter does not have the
963 * corresponding attribute. The [extendsKeyword] and [bound] can be `null` if 963 * corresponding attribute. The [extendsKeyword] and [bound] can be `null` if
964 * the parameter does not have an upper bound. 964 * the parameter does not have an upper bound.
965 */ 965 */
966 TypeParameter typeParameter(Comment comment, List<Annotation> metadata, 966 TypeParameter typeParameter(Comment comment, List<Annotation> metadata,
967 SimpleIdentifier name, Token extendsKeyword, TypeName bound); 967 SimpleIdentifier name, Token extendsKeyword, TypeAnnotation bound);
968 968
969 /** 969 /**
970 * Returns a newly created list of type parameters. 970 * Returns a newly created list of type parameters.
971 */ 971 */
972 TypeParameterList typeParameterList(Token leftBracket, 972 TypeParameterList typeParameterList(Token leftBracket,
973 List<TypeParameter> typeParameters, Token rightBracket); 973 List<TypeParameter> typeParameters, Token rightBracket);
974 974
975 /** 975 /**
976 * Returns a newly created variable declaration. The [equals] and 976 * Returns a newly created variable declaration. The [equals] and
977 * [initializer] can be `null` if there is no initializer. 977 * [initializer] can be `null` if there is no initializer.
978 */ 978 */
979 VariableDeclaration variableDeclaration( 979 VariableDeclaration variableDeclaration(
980 SimpleIdentifier name, Token equals, Expression initializer); 980 SimpleIdentifier name, Token equals, Expression initializer);
981 981
982 /** 982 /**
983 * Returns a newly created variable declaration list. Either or both of the 983 * Returns a newly created variable declaration list. Either or both of the
984 * [comment] and [metadata] can be `null` if the variable list does not have 984 * [comment] and [metadata] can be `null` if the variable list does not have
985 * the corresponding attribute. The [keyword] can be `null` if a type was 985 * the corresponding attribute. The [keyword] can be `null` if a type was
986 * specified. The [type] must be `null` if the keyword is 'var'. 986 * specified. The [type] must be `null` if the keyword is 'var'.
987 */ 987 */
988 VariableDeclarationList variableDeclarationList( 988 VariableDeclarationList variableDeclarationList(
989 Comment comment, 989 Comment comment,
990 List<Annotation> metadata, 990 List<Annotation> metadata,
991 Token keyword, 991 Token keyword,
992 TypeName type, 992 TypeAnnotation type,
993 List<VariableDeclaration> variables); 993 List<VariableDeclaration> variables);
994 994
995 /** 995 /**
996 * Returns a newly created generic type alias. Either or both of the
997 * [comment] and [metadata] can be `null` if the variable list does not have
998 * the corresponding attribute. The [typeParameters] can be `null` if there
999 * are no type parameters.
1000 */
1001 GenericTypeAlias genericTypeAlias(Comment comment, List<Annotation> metadata, Token typedefKeyword, SimpleIdentifier name, TypeParameterList typeParameters, T oken equals, GenericFunctionType functionType, Token semicolon);
1002
1003 /**
1004 * Initialize a newly created generic function type.
1005 */
1006 GenericFunctionType genericFunctionType(TypeAnnotation returnType, Token funct ionKeyword, TypeParameterList typeParameters, FormalParameterList _parameters);
1007
1008 /**
996 * Returns a newly created variable declaration statement. 1009 * Returns a newly created variable declaration statement.
997 */ 1010 */
998 VariableDeclarationStatement variableDeclarationStatement( 1011 VariableDeclarationStatement variableDeclarationStatement(
999 VariableDeclarationList variableList, Token semicolon); 1012 VariableDeclarationList variableList, Token semicolon);
1000 1013
1001 /** 1014 /**
1002 * Returns a newly created while statement. 1015 * Returns a newly created while statement.
1003 */ 1016 */
1004 WhileStatement whileStatement(Token whileKeyword, Token leftParenthesis, 1017 WhileStatement whileStatement(Token whileKeyword, Token leftParenthesis,
1005 Expression condition, Token rightParenthesis, Statement body); 1018 Expression condition, Token rightParenthesis, Statement body);
1006 1019
1007 /** 1020 /**
1008 * Returns a newly created with clause. 1021 * Returns a newly created with clause.
1009 */ 1022 */
1010 WithClause withClause(Token withKeyword, List<TypeName> mixinTypes); 1023 WithClause withClause(Token withKeyword, List<TypeName> mixinTypes);
1011 1024
1012 /** 1025 /**
1013 * Returns a newly created yield expression. The [star] can be `null` if no 1026 * Returns a newly created yield expression. The [star] can be `null` if no
1014 * star was provided. 1027 * star was provided.
1015 */ 1028 */
1016 YieldStatement yieldStatement( 1029 YieldStatement yieldStatement(
1017 Token yieldKeyword, Token star, Expression expression, Token semicolon); 1030 Token yieldKeyword, Token star, Expression expression, Token semicolon);
1018 } 1031 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/dart/ast/ast.dart ('k') | pkg/analyzer/lib/dart/ast/resolution_map.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698