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

Side by Side Diff: pkg/analyzer/lib/src/generated/testing/ast_test_factory.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) 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.generated.testing.ast_test_factory; 5 library analyzer.src.generated.testing.ast_test_factory;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; 8 import 'package:analyzer/dart/ast/standard_ast_factory.dart';
9 import 'package:analyzer/dart/ast/token.dart'; 9 import 'package:analyzer/dart/ast/token.dart';
10 import 'package:analyzer/dart/element/element.dart'; 10 import 'package:analyzer/dart/element/element.dart';
(...skipping 27 matching lines...) Expand all
38 constructorName == null 38 constructorName == null
39 ? null 39 ? null
40 : TokenFactory.tokenFromType(TokenType.PERIOD), 40 : TokenFactory.tokenFromType(TokenType.PERIOD),
41 constructorName, 41 constructorName,
42 arguments); 42 arguments);
43 43
44 static ArgumentList argumentList([List<Expression> arguments]) => 44 static ArgumentList argumentList([List<Expression> arguments]) =>
45 astFactory.argumentList(TokenFactory.tokenFromType(TokenType.OPEN_PAREN), 45 astFactory.argumentList(TokenFactory.tokenFromType(TokenType.OPEN_PAREN),
46 arguments, TokenFactory.tokenFromType(TokenType.CLOSE_PAREN)); 46 arguments, TokenFactory.tokenFromType(TokenType.CLOSE_PAREN));
47 47
48 static AsExpression asExpression( 48 static AsExpression asExpression(Expression expression, TypeName type) =>
49 Expression expression, TypeAnnotation type) =>
50 astFactory.asExpression( 49 astFactory.asExpression(
51 expression, TokenFactory.tokenFromKeyword(Keyword.AS), type); 50 expression, TokenFactory.tokenFromKeyword(Keyword.AS), type);
52 51
53 static AssertStatement assertStatement(Expression condition, 52 static AssertStatement assertStatement(Expression condition,
54 [Expression message]) => 53 [Expression message]) =>
55 astFactory.assertStatement( 54 astFactory.assertStatement(
56 TokenFactory.tokenFromKeyword(Keyword.ASSERT), 55 TokenFactory.tokenFromKeyword(Keyword.ASSERT),
57 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), 56 TokenFactory.tokenFromType(TokenType.OPEN_PAREN),
58 condition, 57 condition,
59 message == null ? null : TokenFactory.tokenFromType(TokenType.COMMA), 58 message == null ? null : TokenFactory.tokenFromType(TokenType.COMMA),
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 151
153 static CatchClause catchClause(String exceptionParameter, 152 static CatchClause catchClause(String exceptionParameter,
154 [List<Statement> statements]) => 153 [List<Statement> statements]) =>
155 catchClause5(null, exceptionParameter, null, statements); 154 catchClause5(null, exceptionParameter, null, statements);
156 155
157 static CatchClause catchClause2( 156 static CatchClause catchClause2(
158 String exceptionParameter, String stackTraceParameter, 157 String exceptionParameter, String stackTraceParameter,
159 [List<Statement> statements]) => 158 [List<Statement> statements]) =>
160 catchClause5(null, exceptionParameter, stackTraceParameter, statements); 159 catchClause5(null, exceptionParameter, stackTraceParameter, statements);
161 160
162 static CatchClause catchClause3(TypeAnnotation exceptionType, 161 static CatchClause catchClause3(TypeName exceptionType,
163 [List<Statement> statements]) => 162 [List<Statement> statements]) =>
164 catchClause5(exceptionType, null, null, statements); 163 catchClause5(exceptionType, null, null, statements);
165 164
166 static CatchClause catchClause4( 165 static CatchClause catchClause4(
167 TypeAnnotation exceptionType, String exceptionParameter, 166 TypeName exceptionType, String exceptionParameter,
168 [List<Statement> statements]) => 167 [List<Statement> statements]) =>
169 catchClause5(exceptionType, exceptionParameter, null, statements); 168 catchClause5(exceptionType, exceptionParameter, null, statements);
170 169
171 static CatchClause catchClause5(TypeAnnotation exceptionType, 170 static CatchClause catchClause5(TypeName exceptionType,
172 String exceptionParameter, String stackTraceParameter, 171 String exceptionParameter, String stackTraceParameter,
173 [List<Statement> statements]) => 172 [List<Statement> statements]) =>
174 astFactory.catchClause( 173 astFactory.catchClause(
175 exceptionType == null 174 exceptionType == null
176 ? null 175 ? null
177 : TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "on"), 176 : TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "on"),
178 exceptionType, 177 exceptionType,
179 exceptionParameter == null 178 exceptionParameter == null
180 ? null 179 ? null
181 : TokenFactory.tokenFromKeyword(Keyword.CATCH), 180 : TokenFactory.tokenFromKeyword(Keyword.CATCH),
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 astFactory.continueStatement( 360 astFactory.continueStatement(
362 TokenFactory.tokenFromKeyword(Keyword.CONTINUE), 361 TokenFactory.tokenFromKeyword(Keyword.CONTINUE),
363 label == null ? null : identifier3(label), 362 label == null ? null : identifier3(label),
364 TokenFactory.tokenFromType(TokenType.SEMICOLON)); 363 TokenFactory.tokenFromType(TokenType.SEMICOLON));
365 364
366 static DeclaredIdentifier declaredIdentifier( 365 static DeclaredIdentifier declaredIdentifier(
367 Keyword keyword, String identifier) => 366 Keyword keyword, String identifier) =>
368 declaredIdentifier2(keyword, null, identifier); 367 declaredIdentifier2(keyword, null, identifier);
369 368
370 static DeclaredIdentifier declaredIdentifier2( 369 static DeclaredIdentifier declaredIdentifier2(
371 Keyword keyword, TypeAnnotation type, String identifier) => 370 Keyword keyword, TypeName type, String identifier) =>
372 astFactory.declaredIdentifier( 371 astFactory.declaredIdentifier(
373 null, 372 null,
374 null, 373 null,
375 keyword == null ? null : TokenFactory.tokenFromKeyword(keyword), 374 keyword == null ? null : TokenFactory.tokenFromKeyword(keyword),
376 type, 375 type,
377 identifier3(identifier)); 376 identifier3(identifier));
378 377
379 static DeclaredIdentifier declaredIdentifier3(String identifier) => 378 static DeclaredIdentifier declaredIdentifier3(String identifier) =>
380 declaredIdentifier2(Keyword.VAR, null, identifier); 379 declaredIdentifier2(Keyword.VAR, null, identifier);
381 380
382 static DeclaredIdentifier declaredIdentifier4( 381 static DeclaredIdentifier declaredIdentifier4(
383 TypeAnnotation type, String identifier) => 382 TypeName type, String identifier) =>
384 declaredIdentifier2(null, type, identifier); 383 declaredIdentifier2(null, type, identifier);
385 384
386 static Comment documentationComment( 385 static Comment documentationComment(
387 List<Token> tokens, List<CommentReference> references) { 386 List<Token> tokens, List<CommentReference> references) {
388 return astFactory.documentationComment(tokens, references); 387 return astFactory.documentationComment(tokens, references);
389 } 388 }
390 389
391 static DoStatement doStatement(Statement body, Expression condition) => 390 static DoStatement doStatement(Statement body, Expression condition) =>
392 astFactory.doStatement( 391 astFactory.doStatement(
393 TokenFactory.tokenFromKeyword(Keyword.DO), 392 TokenFactory.tokenFromKeyword(Keyword.DO),
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 TokenFactory.tokenFromType(TokenType.SEMICOLON)); 452 TokenFactory.tokenFromType(TokenType.SEMICOLON));
454 453
455 static ExpressionStatement expressionStatement(Expression expression) => 454 static ExpressionStatement expressionStatement(Expression expression) =>
456 astFactory.expressionStatement( 455 astFactory.expressionStatement(
457 expression, TokenFactory.tokenFromType(TokenType.SEMICOLON)); 456 expression, TokenFactory.tokenFromType(TokenType.SEMICOLON));
458 457
459 static ExtendsClause extendsClause(TypeName type) => astFactory.extendsClause( 458 static ExtendsClause extendsClause(TypeName type) => astFactory.extendsClause(
460 TokenFactory.tokenFromKeyword(Keyword.EXTENDS), type); 459 TokenFactory.tokenFromKeyword(Keyword.EXTENDS), type);
461 460
462 static FieldDeclaration fieldDeclaration(bool isStatic, Keyword keyword, 461 static FieldDeclaration fieldDeclaration(bool isStatic, Keyword keyword,
463 TypeAnnotation type, List<VariableDeclaration> variables) => 462 TypeName type, List<VariableDeclaration> variables) =>
464 astFactory.fieldDeclaration( 463 astFactory.fieldDeclaration(
465 null, 464 null,
466 null, 465 null,
467 isStatic ? TokenFactory.tokenFromKeyword(Keyword.STATIC) : null, 466 isStatic ? TokenFactory.tokenFromKeyword(Keyword.STATIC) : null,
468 variableDeclarationList(keyword, type, variables), 467 variableDeclarationList(keyword, type, variables),
469 TokenFactory.tokenFromType(TokenType.SEMICOLON)); 468 TokenFactory.tokenFromType(TokenType.SEMICOLON));
470 469
471 static FieldDeclaration fieldDeclaration2(bool isStatic, Keyword keyword, 470 static FieldDeclaration fieldDeclaration2(bool isStatic, Keyword keyword,
472 List<VariableDeclaration> variables) => 471 List<VariableDeclaration> variables) =>
473 fieldDeclaration(isStatic, keyword, null, variables); 472 fieldDeclaration(isStatic, keyword, null, variables);
474 473
475 static FieldFormalParameter fieldFormalParameter( 474 static FieldFormalParameter fieldFormalParameter(
476 Keyword keyword, TypeAnnotation type, String identifier, 475 Keyword keyword, TypeName type, String identifier,
477 [FormalParameterList parameterList]) => 476 [FormalParameterList parameterList]) =>
478 astFactory.fieldFormalParameter( 477 astFactory.fieldFormalParameter(
479 null, 478 null,
480 null, 479 null,
481 keyword == null ? null : TokenFactory.tokenFromKeyword(keyword), 480 keyword == null ? null : TokenFactory.tokenFromKeyword(keyword),
482 type, 481 type,
483 TokenFactory.tokenFromKeyword(Keyword.THIS), 482 TokenFactory.tokenFromKeyword(Keyword.THIS),
484 TokenFactory.tokenFromType(TokenType.PERIOD), 483 TokenFactory.tokenFromType(TokenType.PERIOD),
485 identifier3(identifier), 484 identifier3(identifier),
486 null, 485 null,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), 542 TokenFactory.tokenFromType(TokenType.OPEN_PAREN),
544 variableList, 543 variableList,
545 null, 544 null,
546 TokenFactory.tokenFromType(TokenType.SEMICOLON), 545 TokenFactory.tokenFromType(TokenType.SEMICOLON),
547 condition, 546 condition,
548 TokenFactory.tokenFromType(TokenType.SEMICOLON), 547 TokenFactory.tokenFromType(TokenType.SEMICOLON),
549 updaters, 548 updaters,
550 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), 549 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN),
551 body); 550 body);
552 551
553 static FunctionDeclaration functionDeclaration( 552 static FunctionDeclaration functionDeclaration(TypeName type, Keyword keyword,
554 TypeAnnotation type, 553 String name, FunctionExpression functionExpression) =>
555 Keyword keyword,
556 String name,
557 FunctionExpression functionExpression) =>
558 astFactory.functionDeclaration( 554 astFactory.functionDeclaration(
559 null, 555 null,
560 null, 556 null,
561 null, 557 null,
562 type, 558 type,
563 keyword == null ? null : TokenFactory.tokenFromKeyword(keyword), 559 keyword == null ? null : TokenFactory.tokenFromKeyword(keyword),
564 identifier3(name), 560 identifier3(name),
565 functionExpression); 561 functionExpression);
566 562
567 static FunctionDeclarationStatement functionDeclarationStatement( 563 static FunctionDeclarationStatement functionDeclarationStatement(
568 TypeAnnotation type, 564 TypeName type,
569 Keyword keyword, 565 Keyword keyword,
570 String name, 566 String name,
571 FunctionExpression functionExpression) => 567 FunctionExpression functionExpression) =>
572 astFactory.functionDeclarationStatement( 568 astFactory.functionDeclarationStatement(
573 functionDeclaration(type, keyword, name, functionExpression)); 569 functionDeclaration(type, keyword, name, functionExpression));
574 570
575 static FunctionExpression functionExpression() => astFactory 571 static FunctionExpression functionExpression() => astFactory
576 .functionExpression(null, formalParameterList(), blockFunctionBody2()); 572 .functionExpression(null, formalParameterList(), blockFunctionBody2());
577 573
578 static FunctionExpression functionExpression2( 574 static FunctionExpression functionExpression2(
(...skipping 12 matching lines...) Expand all
591 functionExpressionInvocation2(function, null, arguments); 587 functionExpressionInvocation2(function, null, arguments);
592 588
593 static FunctionExpressionInvocation functionExpressionInvocation2( 589 static FunctionExpressionInvocation functionExpressionInvocation2(
594 Expression function, 590 Expression function,
595 [TypeArgumentList typeArguments, 591 [TypeArgumentList typeArguments,
596 List<Expression> arguments]) => 592 List<Expression> arguments]) =>
597 astFactory.functionExpressionInvocation( 593 astFactory.functionExpressionInvocation(
598 function, typeArguments, argumentList(arguments)); 594 function, typeArguments, argumentList(arguments));
599 595
600 static FunctionTypedFormalParameter functionTypedFormalParameter( 596 static FunctionTypedFormalParameter functionTypedFormalParameter(
601 TypeAnnotation returnType, String identifier, 597 TypeName returnType, String identifier,
602 [List<FormalParameter> parameters]) => 598 [List<FormalParameter> parameters]) =>
603 astFactory.functionTypedFormalParameter(null, null, returnType, 599 astFactory.functionTypedFormalParameter(null, null, returnType,
604 identifier3(identifier), null, formalParameterList(parameters)); 600 identifier3(identifier), null, formalParameterList(parameters));
605 601
606 static HideCombinator hideCombinator(List<SimpleIdentifier> identifiers) => 602 static HideCombinator hideCombinator(List<SimpleIdentifier> identifiers) =>
607 astFactory.hideCombinator( 603 astFactory.hideCombinator(
608 TokenFactory.tokenFromString("hide"), identifiers); 604 TokenFactory.tokenFromString("hide"), identifiers);
609 605
610 static HideCombinator hideCombinator2(List<String> identifiers) => 606 static HideCombinator hideCombinator2(List<String> identifiers) =>
611 astFactory.hideCombinator( 607 astFactory.hideCombinator(
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 TokenFactory.tokenFromType(TokenType.STRING_INTERPOLATION_IDENTIFIER), 730 TokenFactory.tokenFromType(TokenType.STRING_INTERPOLATION_IDENTIFIER),
735 identifier3(identifier), 731 identifier3(identifier),
736 null); 732 null);
737 733
738 static InterpolationString interpolationString( 734 static InterpolationString interpolationString(
739 String contents, String value) => 735 String contents, String value) =>
740 astFactory.interpolationString( 736 astFactory.interpolationString(
741 TokenFactory.tokenFromString(contents), value); 737 TokenFactory.tokenFromString(contents), value);
742 738
743 static IsExpression isExpression( 739 static IsExpression isExpression(
744 Expression expression, bool negated, TypeAnnotation type) => 740 Expression expression, bool negated, TypeName type) =>
745 astFactory.isExpression( 741 astFactory.isExpression(
746 expression, 742 expression,
747 TokenFactory.tokenFromKeyword(Keyword.IS), 743 TokenFactory.tokenFromKeyword(Keyword.IS),
748 negated ? TokenFactory.tokenFromType(TokenType.BANG) : null, 744 negated ? TokenFactory.tokenFromType(TokenType.BANG) : null,
749 type); 745 type);
750 746
751 static Label label(SimpleIdentifier label) => 747 static Label label(SimpleIdentifier label) =>
752 astFactory.label(label, TokenFactory.tokenFromType(TokenType.COLON)); 748 astFactory.label(label, TokenFactory.tokenFromType(TokenType.COLON));
753 749
754 static Label label2(String label) => AstTestFactory.label(identifier3(label)); 750 static Label label2(String label) => AstTestFactory.label(identifier3(label));
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 static MapLiteralEntry mapLiteralEntry(String key, Expression value) => 806 static MapLiteralEntry mapLiteralEntry(String key, Expression value) =>
811 astFactory.mapLiteralEntry( 807 astFactory.mapLiteralEntry(
812 string2(key), TokenFactory.tokenFromType(TokenType.COLON), value); 808 string2(key), TokenFactory.tokenFromType(TokenType.COLON), value);
813 809
814 static MapLiteralEntry mapLiteralEntry2(Expression key, Expression value) => 810 static MapLiteralEntry mapLiteralEntry2(Expression key, Expression value) =>
815 astFactory.mapLiteralEntry( 811 astFactory.mapLiteralEntry(
816 key, TokenFactory.tokenFromType(TokenType.COLON), value); 812 key, TokenFactory.tokenFromType(TokenType.COLON), value);
817 813
818 static MethodDeclaration methodDeclaration( 814 static MethodDeclaration methodDeclaration(
819 Keyword modifier, 815 Keyword modifier,
820 TypeAnnotation returnType, 816 TypeName returnType,
821 Keyword property, 817 Keyword property,
822 Keyword operator, 818 Keyword operator,
823 SimpleIdentifier name, 819 SimpleIdentifier name,
824 FormalParameterList parameters) => 820 FormalParameterList parameters) =>
825 astFactory.methodDeclaration( 821 astFactory.methodDeclaration(
826 null, 822 null,
827 null, 823 null,
828 TokenFactory.tokenFromKeyword(Keyword.EXTERNAL), 824 TokenFactory.tokenFromKeyword(Keyword.EXTERNAL),
829 modifier == null ? null : TokenFactory.tokenFromKeyword(modifier), 825 modifier == null ? null : TokenFactory.tokenFromKeyword(modifier),
830 returnType, 826 returnType,
831 property == null ? null : TokenFactory.tokenFromKeyword(property), 827 property == null ? null : TokenFactory.tokenFromKeyword(property),
832 operator == null ? null : TokenFactory.tokenFromKeyword(operator), 828 operator == null ? null : TokenFactory.tokenFromKeyword(operator),
833 name, 829 name,
834 null, 830 null,
835 parameters, 831 parameters,
836 emptyFunctionBody()); 832 emptyFunctionBody());
837 833
838 static MethodDeclaration methodDeclaration2( 834 static MethodDeclaration methodDeclaration2(
839 Keyword modifier, 835 Keyword modifier,
840 TypeAnnotation returnType, 836 TypeName returnType,
841 Keyword property, 837 Keyword property,
842 Keyword operator, 838 Keyword operator,
843 SimpleIdentifier name, 839 SimpleIdentifier name,
844 FormalParameterList parameters, 840 FormalParameterList parameters,
845 FunctionBody body) => 841 FunctionBody body) =>
846 astFactory.methodDeclaration( 842 astFactory.methodDeclaration(
847 null, 843 null,
848 null, 844 null,
849 null, 845 null,
850 modifier == null ? null : TokenFactory.tokenFromKeyword(modifier), 846 modifier == null ? null : TokenFactory.tokenFromKeyword(modifier),
851 returnType, 847 returnType,
852 property == null ? null : TokenFactory.tokenFromKeyword(property), 848 property == null ? null : TokenFactory.tokenFromKeyword(property),
853 operator == null ? null : TokenFactory.tokenFromKeyword(operator), 849 operator == null ? null : TokenFactory.tokenFromKeyword(operator),
854 name, 850 name,
855 null, 851 null,
856 parameters, 852 parameters,
857 body); 853 body);
858 854
859 static MethodDeclaration methodDeclaration3( 855 static MethodDeclaration methodDeclaration3(
860 Keyword modifier, 856 Keyword modifier,
861 TypeAnnotation returnType, 857 TypeName returnType,
862 Keyword property, 858 Keyword property,
863 Keyword operator, 859 Keyword operator,
864 SimpleIdentifier name, 860 SimpleIdentifier name,
865 TypeParameterList typeParameters, 861 TypeParameterList typeParameters,
866 FormalParameterList parameters, 862 FormalParameterList parameters,
867 FunctionBody body) => 863 FunctionBody body) =>
868 astFactory.methodDeclaration( 864 astFactory.methodDeclaration(
869 null, 865 null,
870 null, 866 null,
871 null, 867 null,
872 modifier == null ? null : TokenFactory.tokenFromKeyword(modifier), 868 modifier == null ? null : TokenFactory.tokenFromKeyword(modifier),
873 returnType, 869 returnType,
874 property == null ? null : TokenFactory.tokenFromKeyword(property), 870 property == null ? null : TokenFactory.tokenFromKeyword(property),
875 operator == null ? null : TokenFactory.tokenFromKeyword(operator), 871 operator == null ? null : TokenFactory.tokenFromKeyword(operator),
876 name, 872 name,
877 typeParameters, 873 typeParameters,
878 parameters, 874 parameters,
879 body); 875 body);
880 876
881 static MethodDeclaration methodDeclaration4( 877 static MethodDeclaration methodDeclaration4(
882 {bool external: false, 878 {bool external: false,
883 Keyword modifier, 879 Keyword modifier,
884 TypeAnnotation returnType, 880 TypeName returnType,
885 Keyword property, 881 Keyword property,
886 bool operator: false, 882 bool operator: false,
887 String name, 883 String name,
888 FormalParameterList parameters, 884 FormalParameterList parameters,
889 FunctionBody body}) => 885 FunctionBody body}) =>
890 astFactory.methodDeclaration( 886 astFactory.methodDeclaration(
891 null, 887 null,
892 null, 888 null,
893 external ? TokenFactory.tokenFromKeyword(Keyword.EXTERNAL) : null, 889 external ? TokenFactory.tokenFromKeyword(Keyword.EXTERNAL) : null,
894 modifier == null ? null : TokenFactory.tokenFromKeyword(modifier), 890 modifier == null ? null : TokenFactory.tokenFromKeyword(modifier),
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 1044
1049 static ShowCombinator showCombinator2(List<String> identifiers) => 1045 static ShowCombinator showCombinator2(List<String> identifiers) =>
1050 astFactory.showCombinator( 1046 astFactory.showCombinator(
1051 TokenFactory.tokenFromString("show"), identifierList(identifiers)); 1047 TokenFactory.tokenFromString("show"), identifierList(identifiers));
1052 1048
1053 static SimpleFormalParameter simpleFormalParameter( 1049 static SimpleFormalParameter simpleFormalParameter(
1054 Keyword keyword, String parameterName) => 1050 Keyword keyword, String parameterName) =>
1055 simpleFormalParameter2(keyword, null, parameterName); 1051 simpleFormalParameter2(keyword, null, parameterName);
1056 1052
1057 static SimpleFormalParameter simpleFormalParameter2( 1053 static SimpleFormalParameter simpleFormalParameter2(
1058 Keyword keyword, TypeAnnotation type, String parameterName) => 1054 Keyword keyword, TypeName type, String parameterName) =>
1059 astFactory.simpleFormalParameter( 1055 astFactory.simpleFormalParameter(
1060 null, 1056 null,
1061 null, 1057 null,
1062 keyword == null ? null : TokenFactory.tokenFromKeyword(keyword), 1058 keyword == null ? null : TokenFactory.tokenFromKeyword(keyword),
1063 type, 1059 type,
1064 identifier3(parameterName)); 1060 identifier3(parameterName));
1065 1061
1066 static SimpleFormalParameter simpleFormalParameter3(String parameterName) => 1062 static SimpleFormalParameter simpleFormalParameter3(String parameterName) =>
1067 simpleFormalParameter2(null, null, parameterName); 1063 simpleFormalParameter2(null, null, parameterName);
1068 1064
1069 static SimpleFormalParameter simpleFormalParameter4( 1065 static SimpleFormalParameter simpleFormalParameter4(
1070 TypeAnnotation type, String parameterName) => 1066 TypeName type, String parameterName) =>
1071 simpleFormalParameter2(null, type, parameterName); 1067 simpleFormalParameter2(null, type, parameterName);
1072 1068
1073 static StringInterpolation string([List<InterpolationElement> elements]) => 1069 static StringInterpolation string([List<InterpolationElement> elements]) =>
1074 astFactory.stringInterpolation(elements); 1070 astFactory.stringInterpolation(elements);
1075 1071
1076 static SimpleStringLiteral string2(String content) => astFactory 1072 static SimpleStringLiteral string2(String content) => astFactory
1077 .simpleStringLiteral(TokenFactory.tokenFromString("'$content'"), content); 1073 .simpleStringLiteral(TokenFactory.tokenFromString("'$content'"), content);
1078 1074
1079 static SuperConstructorInvocation superConstructorInvocation( 1075 static SuperConstructorInvocation superConstructorInvocation(
1080 [List<Expression> arguments]) => 1076 [List<Expression> arguments]) =>
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 astFactory.thisExpression(TokenFactory.tokenFromKeyword(Keyword.THIS)); 1146 astFactory.thisExpression(TokenFactory.tokenFromKeyword(Keyword.THIS));
1151 1147
1152 static ThrowExpression throwExpression() => throwExpression2(null); 1148 static ThrowExpression throwExpression() => throwExpression2(null);
1153 1149
1154 static ThrowExpression throwExpression2(Expression expression) => 1150 static ThrowExpression throwExpression2(Expression expression) =>
1155 astFactory.throwExpression( 1151 astFactory.throwExpression(
1156 TokenFactory.tokenFromKeyword(Keyword.THROW), expression); 1152 TokenFactory.tokenFromKeyword(Keyword.THROW), expression);
1157 1153
1158 static TopLevelVariableDeclaration topLevelVariableDeclaration( 1154 static TopLevelVariableDeclaration topLevelVariableDeclaration(
1159 Keyword keyword, 1155 Keyword keyword,
1160 TypeAnnotation type, 1156 TypeName type,
1161 List<VariableDeclaration> variables) => 1157 List<VariableDeclaration> variables) =>
1162 astFactory.topLevelVariableDeclaration( 1158 astFactory.topLevelVariableDeclaration(
1163 null, 1159 null,
1164 null, 1160 null,
1165 variableDeclarationList(keyword, type, variables), 1161 variableDeclarationList(keyword, type, variables),
1166 TokenFactory.tokenFromType(TokenType.SEMICOLON)); 1162 TokenFactory.tokenFromType(TokenType.SEMICOLON));
1167 1163
1168 static TopLevelVariableDeclaration topLevelVariableDeclaration2( 1164 static TopLevelVariableDeclaration topLevelVariableDeclaration2(
1169 Keyword keyword, List<VariableDeclaration> variables) => 1165 Keyword keyword, List<VariableDeclaration> variables) =>
1170 astFactory.topLevelVariableDeclaration( 1166 astFactory.topLevelVariableDeclaration(
(...skipping 13 matching lines...) Expand all
1184 Block body, List<CatchClause> catchClauses, Block finallyClause) => 1180 Block body, List<CatchClause> catchClauses, Block finallyClause) =>
1185 astFactory.tryStatement( 1181 astFactory.tryStatement(
1186 TokenFactory.tokenFromKeyword(Keyword.TRY), 1182 TokenFactory.tokenFromKeyword(Keyword.TRY),
1187 body, 1183 body,
1188 catchClauses, 1184 catchClauses,
1189 finallyClause == null 1185 finallyClause == null
1190 ? null 1186 ? null
1191 : TokenFactory.tokenFromKeyword(Keyword.FINALLY), 1187 : TokenFactory.tokenFromKeyword(Keyword.FINALLY),
1192 finallyClause); 1188 finallyClause);
1193 1189
1194 static FunctionTypeAlias typeAlias(TypeAnnotation returnType, String name, 1190 static FunctionTypeAlias typeAlias(TypeName returnType, String name,
1195 TypeParameterList typeParameters, FormalParameterList parameters) => 1191 TypeParameterList typeParameters, FormalParameterList parameters) =>
1196 astFactory.functionTypeAlias( 1192 astFactory.functionTypeAlias(
1197 null, 1193 null,
1198 null, 1194 null,
1199 TokenFactory.tokenFromKeyword(Keyword.TYPEDEF), 1195 TokenFactory.tokenFromKeyword(Keyword.TYPEDEF),
1200 returnType, 1196 returnType,
1201 identifier3(name), 1197 identifier3(name),
1202 typeParameters, 1198 typeParameters,
1203 parameters, 1199 parameters,
1204 TokenFactory.tokenFromType(TokenType.SEMICOLON)); 1200 TokenFactory.tokenFromType(TokenType.SEMICOLON));
1205 1201
1206 static TypeArgumentList typeArgumentList(List<TypeAnnotation> types) { 1202 static TypeArgumentList typeArgumentList(List<TypeName> typeNames) {
1207 if (types == null || types.length == 0) { 1203 if (typeNames == null || typeNames.length == 0) {
1208 return null; 1204 return null;
1209 } 1205 }
1210 return astFactory.typeArgumentList(TokenFactory.tokenFromType(TokenType.LT), 1206 return astFactory.typeArgumentList(TokenFactory.tokenFromType(TokenType.LT),
1211 types, TokenFactory.tokenFromType(TokenType.GT)); 1207 typeNames, TokenFactory.tokenFromType(TokenType.GT));
1212 } 1208 }
1213 1209
1214 /** 1210 /**
1215 * Create a type name whose name has been resolved to the given [element] and 1211 * Create a type name whose name has been resolved to the given [element] and
1216 * whose type has been resolved to the type of the given element. 1212 * whose type has been resolved to the type of the given element.
1217 * 1213 *
1218 * <b>Note:</b> This method does not correctly handle class elements that have 1214 * <b>Note:</b> This method does not correctly handle class elements that have
1219 * type parameters. 1215 * type parameters.
1220 */ 1216 */
1221 static TypeName typeName(ClassElement element, 1217 static TypeName typeName(ClassElement element, [List<TypeName> arguments]) {
1222 [List<TypeAnnotation> arguments]) {
1223 SimpleIdentifier name = identifier3(element.name); 1218 SimpleIdentifier name = identifier3(element.name);
1224 name.staticElement = element; 1219 name.staticElement = element;
1225 TypeName typeName = typeName3(name, arguments); 1220 TypeName typeName = typeName3(name, arguments);
1226 typeName.type = element.type; 1221 typeName.type = element.type;
1227 return typeName; 1222 return typeName;
1228 } 1223 }
1229 1224
1230 static TypeName typeName3(Identifier name, 1225 static TypeName typeName3(Identifier name, [List<TypeName> arguments]) =>
1231 [List<TypeAnnotation> arguments]) =>
1232 astFactory.typeName(name, typeArgumentList(arguments)); 1226 astFactory.typeName(name, typeArgumentList(arguments));
1233 1227
1234 static TypeName typeName4(String name, [List<TypeAnnotation> arguments]) => 1228 static TypeName typeName4(String name, [List<TypeName> arguments]) =>
1235 astFactory.typeName(identifier3(name), typeArgumentList(arguments)); 1229 astFactory.typeName(identifier3(name), typeArgumentList(arguments));
1236 1230
1237 static TypeParameter typeParameter(String name) => 1231 static TypeParameter typeParameter(String name) =>
1238 astFactory.typeParameter(null, null, identifier3(name), null, null); 1232 astFactory.typeParameter(null, null, identifier3(name), null, null);
1239 1233
1240 static TypeParameter typeParameter2(String name, TypeAnnotation bound) => 1234 static TypeParameter typeParameter2(String name, TypeName bound) =>
1241 astFactory.typeParameter(null, null, identifier3(name), 1235 astFactory.typeParameter(null, null, identifier3(name),
1242 TokenFactory.tokenFromKeyword(Keyword.EXTENDS), bound); 1236 TokenFactory.tokenFromKeyword(Keyword.EXTENDS), bound);
1243 1237
1244 static TypeParameterList typeParameterList([List<String> typeNames]) { 1238 static TypeParameterList typeParameterList([List<String> typeNames]) {
1245 List<TypeParameter> typeParameters = null; 1239 List<TypeParameter> typeParameters = null;
1246 if (typeNames != null && !typeNames.isEmpty) { 1240 if (typeNames != null && !typeNames.isEmpty) {
1247 typeParameters = new List<TypeParameter>(); 1241 typeParameters = new List<TypeParameter>();
1248 for (String typeName in typeNames) { 1242 for (String typeName in typeNames) {
1249 typeParameters.add(typeParameter(typeName)); 1243 typeParameters.add(typeParameter(typeName));
1250 } 1244 }
1251 } 1245 }
1252 return astFactory.typeParameterList( 1246 return astFactory.typeParameterList(
1253 TokenFactory.tokenFromType(TokenType.LT), 1247 TokenFactory.tokenFromType(TokenType.LT),
1254 typeParameters, 1248 typeParameters,
1255 TokenFactory.tokenFromType(TokenType.GT)); 1249 TokenFactory.tokenFromType(TokenType.GT));
1256 } 1250 }
1257 1251
1258 static VariableDeclaration variableDeclaration(String name) => 1252 static VariableDeclaration variableDeclaration(String name) =>
1259 astFactory.variableDeclaration(identifier3(name), null, null); 1253 astFactory.variableDeclaration(identifier3(name), null, null);
1260 1254
1261 static VariableDeclaration variableDeclaration2( 1255 static VariableDeclaration variableDeclaration2(
1262 String name, Expression initializer) => 1256 String name, Expression initializer) =>
1263 astFactory.variableDeclaration(identifier3(name), 1257 astFactory.variableDeclaration(identifier3(name),
1264 TokenFactory.tokenFromType(TokenType.EQ), initializer); 1258 TokenFactory.tokenFromType(TokenType.EQ), initializer);
1265 1259
1266 static VariableDeclarationList variableDeclarationList(Keyword keyword, 1260 static VariableDeclarationList variableDeclarationList(Keyword keyword,
1267 TypeAnnotation type, List<VariableDeclaration> variables) => 1261 TypeName type, List<VariableDeclaration> variables) =>
1268 astFactory.variableDeclarationList( 1262 astFactory.variableDeclarationList(
1269 null, 1263 null,
1270 null, 1264 null,
1271 keyword == null ? null : TokenFactory.tokenFromKeyword(keyword), 1265 keyword == null ? null : TokenFactory.tokenFromKeyword(keyword),
1272 type, 1266 type,
1273 variables); 1267 variables);
1274 1268
1275 static VariableDeclarationList variableDeclarationList2( 1269 static VariableDeclarationList variableDeclarationList2(
1276 Keyword keyword, List<VariableDeclaration> variables) => 1270 Keyword keyword, List<VariableDeclaration> variables) =>
1277 variableDeclarationList(keyword, null, variables); 1271 variableDeclarationList(keyword, null, variables);
1278 1272
1279 static VariableDeclarationStatement variableDeclarationStatement( 1273 static VariableDeclarationStatement variableDeclarationStatement(
1280 Keyword keyword, 1274 Keyword keyword,
1281 TypeAnnotation type, 1275 TypeName type,
1282 List<VariableDeclaration> variables) => 1276 List<VariableDeclaration> variables) =>
1283 astFactory.variableDeclarationStatement( 1277 astFactory.variableDeclarationStatement(
1284 variableDeclarationList(keyword, type, variables), 1278 variableDeclarationList(keyword, type, variables),
1285 TokenFactory.tokenFromType(TokenType.SEMICOLON)); 1279 TokenFactory.tokenFromType(TokenType.SEMICOLON));
1286 1280
1287 static VariableDeclarationStatement variableDeclarationStatement2( 1281 static VariableDeclarationStatement variableDeclarationStatement2(
1288 Keyword keyword, List<VariableDeclaration> variables) => 1282 Keyword keyword, List<VariableDeclaration> variables) =>
1289 variableDeclarationStatement(keyword, null, variables); 1283 variableDeclarationStatement(keyword, null, variables);
1290 1284
1291 static WhileStatement whileStatement(Expression condition, Statement body) => 1285 static WhileStatement whileStatement(Expression condition, Statement body) =>
(...skipping 14 matching lines...) Expand all
1306 expression, 1300 expression,
1307 TokenFactory.tokenFromType(TokenType.SEMICOLON)); 1301 TokenFactory.tokenFromType(TokenType.SEMICOLON));
1308 1302
1309 static YieldStatement yieldStatement(Expression expression) => 1303 static YieldStatement yieldStatement(Expression expression) =>
1310 astFactory.yieldStatement( 1304 astFactory.yieldStatement(
1311 TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "yield"), 1305 TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "yield"),
1312 null, 1306 null,
1313 expression, 1307 expression,
1314 TokenFactory.tokenFromType(TokenType.SEMICOLON)); 1308 TokenFactory.tokenFromType(TokenType.SEMICOLON));
1315 } 1309 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/static_type_analyzer.dart ('k') | pkg/analyzer/lib/src/summary/resynthesize.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698