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

Side by Side Diff: observatory_pub_packages/analyzer/src/generated/testing/ast_factory.dart

Issue 816693004: Add observatory_pub_packages snapshot to third_party (Closed) Base URL: http://dart.googlecode.com/svn/third_party/
Patch Set: Created 6 years 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information.
7
8 library engine.testing.ast_factory;
9
10 import 'package:analyzer/src/generated/utilities_dart.dart';
11 import 'package:analyzer/src/generated/ast.dart';
12 import 'package:analyzer/src/generated/element.dart';
13 import 'package:analyzer/src/generated/scanner.dart';
14 import 'package:analyzer/src/generated/testing/token_factory.dart';
15
16 /**
17 * The class `AstFactory` defines utility methods that can be used to create AST nodes. The
18 * nodes that are created are complete in the sense that all of the tokens that would have been
19 * associated with the nodes by a parser are also created, but the token stream is not constructed.
20 * None of the nodes are resolved.
21 *
22 * The general pattern is for the name of the factory method to be the same as t he name of the class
23 * of AST node being created. There are two notable exceptions. The first is for methods creating
24 * nodes that are part of a cascade expression. These methods are all prefixed w ith 'cascaded'. The
25 * second is places where a shorter name seemed unambiguous and easier to read, such as using
26 * 'identifier' rather than 'prefixedIdentifier', or 'integer' rather than 'inte gerLiteral'.
27 */
28 class AstFactory {
29 static AdjacentStrings adjacentStrings(List<StringLiteral> strings) => new Adj acentStrings(list(strings));
30
31 static Annotation annotation(Identifier name) => new Annotation(TokenFactory.t okenFromType(TokenType.AT), name, null, null, null);
32
33 static Annotation annotation2(Identifier name, SimpleIdentifier constructorNam e, ArgumentList arguments) => new Annotation(TokenFactory.tokenFromType(TokenTyp e.AT), name, TokenFactory.tokenFromType(TokenType.PERIOD), constructorName, argu ments);
34
35 static ArgumentList argumentList(List<Expression> arguments) => new ArgumentLi st(TokenFactory.tokenFromType(TokenType.OPEN_PAREN), list(arguments), TokenFacto ry.tokenFromType(TokenType.CLOSE_PAREN));
36
37 static AsExpression asExpression(Expression expression, TypeName type) => new AsExpression(expression, TokenFactory.tokenFromKeyword(Keyword.AS), type);
38
39 static AssertStatement assertStatement(Expression condition) => new AssertStat ement(TokenFactory.tokenFromKeyword(Keyword.ASSERT), TokenFactory.tokenFromType( TokenType.OPEN_PAREN), condition, TokenFactory.tokenFromType(TokenType.CLOSE_PAR EN), TokenFactory.tokenFromType(TokenType.SEMICOLON));
40
41 static AssignmentExpression assignmentExpression(Expression leftHandSide, Toke nType operator, Expression rightHandSide) => new AssignmentExpression(leftHandSi de, TokenFactory.tokenFromType(operator), rightHandSide);
42
43 static BlockFunctionBody asyncBlockFunctionBody(List<Statement> statements) => new BlockFunctionBody(TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "async"), null, block(statements));
44
45 static ExpressionFunctionBody asyncExpressionFunctionBody(Expression expressio n) => new ExpressionFunctionBody(TokenFactory.tokenFromTypeAndString(TokenType.I DENTIFIER, "async"), TokenFactory.tokenFromType(TokenType.FUNCTION), expression, TokenFactory.tokenFromType(TokenType.SEMICOLON));
46
47 static BlockFunctionBody asyncGeneratorBlockFunctionBody(List<Statement> state ments) => new BlockFunctionBody(TokenFactory.tokenFromTypeAndString(TokenType.ID ENTIFIER, "async"), TokenFactory.tokenFromType(TokenType.STAR), block(statements ));
48
49 static AwaitExpression awaitExpression(Expression expression) => new AwaitExpr ession(TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "await"), expre ssion);
50
51 static BinaryExpression binaryExpression(Expression leftOperand, TokenType ope rator, Expression rightOperand) => new BinaryExpression(leftOperand, TokenFactor y.tokenFromType(operator), rightOperand);
52
53 static Block block(List<Statement> statements) => new Block(TokenFactory.token FromType(TokenType.OPEN_CURLY_BRACKET), list(statements), TokenFactory.tokenFrom Type(TokenType.CLOSE_CURLY_BRACKET));
54
55 static BlockFunctionBody blockFunctionBody(Block block) => new BlockFunctionBo dy(null, null, block);
56
57 static BlockFunctionBody blockFunctionBody2(List<Statement> statements) => new BlockFunctionBody(null, null, block(statements));
58
59 static BooleanLiteral booleanLiteral(bool value) => new BooleanLiteral(value ? TokenFactory.tokenFromKeyword(Keyword.TRUE) : TokenFactory.tokenFromKeyword(Key word.FALSE), value);
60
61 static BreakStatement breakStatement() => new BreakStatement(TokenFactory.toke nFromKeyword(Keyword.BREAK), null, TokenFactory.tokenFromType(TokenType.SEMICOLO N));
62
63 static BreakStatement breakStatement2(String label) => new BreakStatement(Toke nFactory.tokenFromKeyword(Keyword.BREAK), identifier3(label), TokenFactory.token FromType(TokenType.SEMICOLON));
64
65 static IndexExpression cascadedIndexExpression(Expression index) => new IndexE xpression.forCascade(TokenFactory.tokenFromType(TokenType.PERIOD_PERIOD), TokenF actory.tokenFromType(TokenType.OPEN_SQUARE_BRACKET), index, TokenFactory.tokenFr omType(TokenType.CLOSE_SQUARE_BRACKET));
66
67 static MethodInvocation cascadedMethodInvocation(String methodName, List<Expre ssion> arguments) => new MethodInvocation(null, TokenFactory.tokenFromType(Token Type.PERIOD_PERIOD), identifier3(methodName), argumentList(arguments));
68
69 static PropertyAccess cascadedPropertyAccess(String propertyName) => new Prope rtyAccess(null, TokenFactory.tokenFromType(TokenType.PERIOD_PERIOD), identifier3 (propertyName));
70
71 static CascadeExpression cascadeExpression(Expression target, List<Expression> cascadeSections) => new CascadeExpression(target, list(cascadeSections));
72
73 static CatchClause catchClause(String exceptionParameter, List<Statement> stat ements) => catchClause5(null, exceptionParameter, null, statements);
74
75 static CatchClause catchClause2(String exceptionParameter, String stackTracePa rameter, List<Statement> statements) => catchClause5(null, exceptionParameter, s tackTraceParameter, statements);
76
77 static CatchClause catchClause3(TypeName exceptionType, List<Statement> statem ents) => catchClause5(exceptionType, null, null, statements);
78
79 static CatchClause catchClause4(TypeName exceptionType, String exceptionParame ter, List<Statement> statements) => catchClause5(exceptionType, exceptionParamet er, null, statements);
80
81 static CatchClause catchClause5(TypeName exceptionType, String exceptionParame ter, String stackTraceParameter, List<Statement> statements) => new CatchClause( exceptionType == null ? null : TokenFactory.tokenFromTypeAndString(TokenType.IDE NTIFIER, "on"), exceptionType, exceptionParameter == null ? null : TokenFactory. tokenFromKeyword(Keyword.CATCH), exceptionParameter == null ? null : TokenFactor y.tokenFromType(TokenType.OPEN_PAREN), exceptionParameter == null ? null : ident ifier3(exceptionParameter), stackTraceParameter == null ? null : TokenFactory.to kenFromType(TokenType.COMMA), stackTraceParameter == null ? null : identifier3(s tackTraceParameter), exceptionParameter == null ? null : TokenFactory.tokenFromT ype(TokenType.CLOSE_PAREN), block(statements));
82
83 static ClassDeclaration classDeclaration(Keyword abstractKeyword, String name, TypeParameterList typeParameters, ExtendsClause extendsClause, WithClause withC lause, ImplementsClause implementsClause, List<ClassMember> members) => new Clas sDeclaration(null, null, abstractKeyword == null ? null : TokenFactory.tokenFrom Keyword(abstractKeyword), TokenFactory.tokenFromKeyword(Keyword.CLASS), identifi er3(name), typeParameters, extendsClause, withClause, implementsClause, TokenFac tory.tokenFromType(TokenType.OPEN_CURLY_BRACKET), list(members), TokenFactory.to kenFromType(TokenType.CLOSE_CURLY_BRACKET));
84
85 static ClassTypeAlias classTypeAlias(String name, TypeParameterList typeParame ters, Keyword abstractKeyword, TypeName superclass, WithClause withClause, Imple mentsClause implementsClause) => new ClassTypeAlias(null, null, TokenFactory.tok enFromKeyword(Keyword.CLASS), identifier3(name), typeParameters, TokenFactory.to kenFromType(TokenType.EQ), abstractKeyword == null ? null : TokenFactory.tokenFr omKeyword(abstractKeyword), superclass, withClause, implementsClause, TokenFacto ry.tokenFromType(TokenType.SEMICOLON));
86
87 static CompilationUnit compilationUnit() => compilationUnit8(null, null, null) ;
88
89 static CompilationUnit compilationUnit2(List<CompilationUnitMember> declaratio ns) => compilationUnit8(null, null, list(declarations));
90
91 static CompilationUnit compilationUnit3(List<Directive> directives) => compila tionUnit8(null, list(directives), null);
92
93 static CompilationUnit compilationUnit4(List<Directive> directives, List<Compi lationUnitMember> declarations) => compilationUnit8(null, directives, declaratio ns);
94
95 static CompilationUnit compilationUnit5(String scriptTag) => compilationUnit8( scriptTag, null, null);
96
97 static CompilationUnit compilationUnit6(String scriptTag, List<CompilationUnit Member> declarations) => compilationUnit8(scriptTag, null, list(declarations));
98
99 static CompilationUnit compilationUnit7(String scriptTag, List<Directive> dire ctives) => compilationUnit8(scriptTag, list(directives), null);
100
101 static CompilationUnit compilationUnit8(String scriptTag, List<Directive> dire ctives, List<CompilationUnitMember> declarations) => new CompilationUnit(TokenFa ctory.tokenFromType(TokenType.EOF), scriptTag == null ? null : AstFactory.script Tag(scriptTag), directives == null ? new List<Directive>() : directives, declara tions == null ? new List<CompilationUnitMember>() : declarations, TokenFactory.t okenFromType(TokenType.EOF));
102
103 static ConditionalExpression conditionalExpression(Expression condition, Expre ssion thenExpression, Expression elseExpression) => new ConditionalExpression(co ndition, TokenFactory.tokenFromType(TokenType.QUESTION), thenExpression, TokenFa ctory.tokenFromType(TokenType.COLON), elseExpression);
104
105 static ConstructorDeclaration constructorDeclaration(Identifier returnType, St ring name, FormalParameterList parameters, List<ConstructorInitializer> initiali zers) => new ConstructorDeclaration(null, null, TokenFactory.tokenFromKeyword(Ke yword.EXTERNAL), null, null, returnType, name == null ? null : TokenFactory.toke nFromType(TokenType.PERIOD), name == null ? null : identifier3(name), parameters , initializers == null || initializers.isEmpty ? null : TokenFactory.tokenFromTy pe(TokenType.PERIOD), initializers == null ? new List<ConstructorInitializer>() : initializers, null, emptyFunctionBody());
106
107 static ConstructorDeclaration constructorDeclaration2(Keyword constKeyword, Ke yword factoryKeyword, Identifier returnType, String name, FormalParameterList pa rameters, List<ConstructorInitializer> initializers, FunctionBody body) => new C onstructorDeclaration(null, null, null, constKeyword == null ? null : TokenFacto ry.tokenFromKeyword(constKeyword), factoryKeyword == null ? null : TokenFactory. tokenFromKeyword(factoryKeyword), returnType, name == null ? null : TokenFactory .tokenFromType(TokenType.PERIOD), name == null ? null : identifier3(name), param eters, initializers == null || initializers.isEmpty ? null : TokenFactory.tokenF romType(TokenType.PERIOD), initializers == null ? new List<ConstructorInitialize r>() : initializers, null, body);
108
109 static ConstructorFieldInitializer constructorFieldInitializer(bool prefixedWi thThis, String fieldName, Expression expression) => new ConstructorFieldInitiali zer(prefixedWithThis ? TokenFactory.tokenFromKeyword(Keyword.THIS) : null, prefi xedWithThis ? TokenFactory.tokenFromType(TokenType.PERIOD) : null, identifier3(f ieldName), TokenFactory.tokenFromType(TokenType.EQ), expression);
110
111 static ConstructorName constructorName(TypeName type, String name) => new Cons tructorName(type, name == null ? null : TokenFactory.tokenFromType(TokenType.PER IOD), name == null ? null : identifier3(name));
112
113 static ContinueStatement continueStatement([String label]) {
114 SimpleIdentifier labelNode = label == null ? null : identifier3(label);
115 return new ContinueStatement(TokenFactory.tokenFromKeyword(Keyword.CONTINUE) , labelNode, TokenFactory.tokenFromType(TokenType.SEMICOLON));
116 }
117
118 static DeclaredIdentifier declaredIdentifier(Keyword keyword, String identifie r) => declaredIdentifier2(keyword, null, identifier);
119
120 static DeclaredIdentifier declaredIdentifier2(Keyword keyword, TypeName type, String identifier) => new DeclaredIdentifier(null, null, keyword == null ? null : TokenFactory.tokenFromKeyword(keyword), type, identifier3(identifier));
121
122 static DeclaredIdentifier declaredIdentifier3(String identifier) => declaredId entifier2(null, null, identifier);
123
124 static DeclaredIdentifier declaredIdentifier4(TypeName type, String identifier ) => declaredIdentifier2(null, type, identifier);
125
126 static DoStatement doStatement(Statement body, Expression condition) => new Do Statement(TokenFactory.tokenFromKeyword(Keyword.DO), body, TokenFactory.tokenFro mKeyword(Keyword.WHILE), TokenFactory.tokenFromType(TokenType.OPEN_PAREN), condi tion, TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), TokenFactory.tokenFromT ype(TokenType.SEMICOLON));
127
128 static DoubleLiteral doubleLiteral(double value) => new DoubleLiteral(TokenFac tory.tokenFromString(value.toString()), value);
129
130 static EmptyFunctionBody emptyFunctionBody() => new EmptyFunctionBody(TokenFac tory.tokenFromType(TokenType.SEMICOLON));
131
132 static EmptyStatement emptyStatement() => new EmptyStatement(TokenFactory.toke nFromType(TokenType.SEMICOLON));
133
134 static EnumDeclaration enumDeclaration(SimpleIdentifier name, List<EnumConstan tDeclaration> constants) => new EnumDeclaration(null, null, TokenFactory.tokenFr omKeyword(Keyword.ENUM), name, TokenFactory.tokenFromType(TokenType.OPEN_CURLY_B RACKET), list(constants), TokenFactory.tokenFromType(TokenType.CLOSE_CURLY_BRACK ET));
135
136 static EnumDeclaration enumDeclaration2(String name, List<String> constantName s) {
137 int count = constantNames.length;
138 List<EnumConstantDeclaration> constants = new List<EnumConstantDeclaration>( count);
139 for (int i = 0; i < count; i++) {
140 constants[i] = new EnumConstantDeclaration(null, null, identifier3(constan tNames[i]));
141 }
142 return enumDeclaration(identifier3(name), constants);
143 }
144
145 static ExportDirective exportDirective(List<Annotation> metadata, String uri, List<Combinator> combinators) => new ExportDirective(null, metadata, TokenFactor y.tokenFromKeyword(Keyword.EXPORT), string2(uri), list(combinators), TokenFactor y.tokenFromType(TokenType.SEMICOLON));
146
147 static ExportDirective exportDirective2(String uri, List<Combinator> combinato rs) => exportDirective(new List<Annotation>(), uri, combinators);
148
149 static ExpressionFunctionBody expressionFunctionBody(Expression expression) => new ExpressionFunctionBody(null, TokenFactory.tokenFromType(TokenType.FUNCTION) , expression, TokenFactory.tokenFromType(TokenType.SEMICOLON));
150
151 static ExpressionStatement expressionStatement(Expression expression) => new E xpressionStatement(expression, TokenFactory.tokenFromType(TokenType.SEMICOLON));
152
153 static ExtendsClause extendsClause(TypeName type) => new ExtendsClause(TokenFa ctory.tokenFromKeyword(Keyword.EXTENDS), type);
154
155 static FieldDeclaration fieldDeclaration(bool isStatic, Keyword keyword, TypeN ame type, List<VariableDeclaration> variables) => new FieldDeclaration(null, nul l, isStatic ? TokenFactory.tokenFromKeyword(Keyword.STATIC) : null, variableDecl arationList(keyword, type, variables), TokenFactory.tokenFromType(TokenType.SEMI COLON));
156
157 static FieldDeclaration fieldDeclaration2(bool isStatic, Keyword keyword, List <VariableDeclaration> variables) => fieldDeclaration(isStatic, keyword, null, va riables);
158
159 static FieldFormalParameter fieldFormalParameter(Keyword keyword, TypeName typ e, String identifier, [FormalParameterList parameterList]) => new FieldFormalPar ameter(null, null, keyword == null ? null : TokenFactory.tokenFromKeyword(keywor d), type, TokenFactory.tokenFromKeyword(Keyword.THIS), TokenFactory.tokenFromTyp e(TokenType.PERIOD), identifier3(identifier), parameterList);
160
161 static FieldFormalParameter fieldFormalParameter2(String identifier) => fieldF ormalParameter(null, null, identifier);
162
163 static ForEachStatement forEachStatement(DeclaredIdentifier loopVariable, Expr ession iterator, Statement body) => new ForEachStatement.con1(null, TokenFactory .tokenFromKeyword(Keyword.FOR), TokenFactory.tokenFromType(TokenType.OPEN_PAREN) , loopVariable, TokenFactory.tokenFromKeyword(Keyword.IN), iterator, TokenFactor y.tokenFromType(TokenType.CLOSE_PAREN), body);
164
165 static ForEachStatement forEachStatement2(SimpleIdentifier identifier, Express ion iterator, Statement body) => new ForEachStatement.con2(null, TokenFactory.to kenFromKeyword(Keyword.FOR), TokenFactory.tokenFromType(TokenType.OPEN_PAREN), i dentifier, TokenFactory.tokenFromKeyword(Keyword.IN), iterator, TokenFactory.tok enFromType(TokenType.CLOSE_PAREN), body);
166
167 static FormalParameterList formalParameterList(List<FormalParameter> parameter s) => new FormalParameterList(TokenFactory.tokenFromType(TokenType.OPEN_PAREN), list(parameters), null, null, TokenFactory.tokenFromType(TokenType.CLOSE_PAREN)) ;
168
169 static ForStatement forStatement(Expression initialization, Expression conditi on, List<Expression> updaters, Statement body) => new ForStatement(TokenFactory. tokenFromKeyword(Keyword.FOR), TokenFactory.tokenFromType(TokenType.OPEN_PAREN), null, initialization, TokenFactory.tokenFromType(TokenType.SEMICOLON), conditio n, TokenFactory.tokenFromType(TokenType.SEMICOLON), updaters, TokenFactory.token FromType(TokenType.CLOSE_PAREN), body);
170
171 static ForStatement forStatement2(VariableDeclarationList variableList, Expres sion condition, List<Expression> updaters, Statement body) => new ForStatement(T okenFactory.tokenFromKeyword(Keyword.FOR), TokenFactory.tokenFromType(TokenType. OPEN_PAREN), variableList, null, TokenFactory.tokenFromType(TokenType.SEMICOLON) , condition, TokenFactory.tokenFromType(TokenType.SEMICOLON), updaters, TokenFac tory.tokenFromType(TokenType.CLOSE_PAREN), body);
172
173 static FunctionDeclaration functionDeclaration(TypeName type, Keyword keyword, String name, FunctionExpression functionExpression) => new FunctionDeclaration( null, null, null, type, keyword == null ? null : TokenFactory.tokenFromKeyword(k eyword), identifier3(name), functionExpression);
174
175 static FunctionDeclarationStatement functionDeclarationStatement(TypeName type , Keyword keyword, String name, FunctionExpression functionExpression) => new Fu nctionDeclarationStatement(functionDeclaration(type, keyword, name, functionExpr ession));
176
177 static FunctionExpression functionExpression() => new FunctionExpression(forma lParameterList([]), blockFunctionBody2([]));
178
179 static FunctionExpression functionExpression2(FormalParameterList parameters, FunctionBody body) => new FunctionExpression(parameters, body);
180
181 static FunctionExpressionInvocation functionExpressionInvocation(Expression fu nction, List<Expression> arguments) => new FunctionExpressionInvocation(function , argumentList(arguments));
182
183 static FunctionTypedFormalParameter functionTypedFormalParameter(TypeName retu rnType, String identifier, List<FormalParameter> parameters) => new FunctionType dFormalParameter(null, null, returnType, identifier3(identifier), formalParamete rList(parameters));
184
185 static HideCombinator hideCombinator(List<SimpleIdentifier> identifiers) => ne w HideCombinator(TokenFactory.tokenFromString("hide"), list(identifiers));
186
187 static HideCombinator hideCombinator2(List<String> identifiers) {
188 List<SimpleIdentifier> identifierList = new List<SimpleIdentifier>();
189 for (String identifier in identifiers) {
190 identifierList.add(identifier3(identifier));
191 }
192 return new HideCombinator(TokenFactory.tokenFromString("hide"), identifierLi st);
193 }
194
195 static PrefixedIdentifier identifier(SimpleIdentifier prefix, SimpleIdentifier identifier) => new PrefixedIdentifier(prefix, TokenFactory.tokenFromType(TokenT ype.PERIOD), identifier);
196
197 static SimpleIdentifier identifier3(String lexeme) => new SimpleIdentifier(Tok enFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, lexeme));
198
199 static PrefixedIdentifier identifier4(String prefix, SimpleIdentifier identifi er) => new PrefixedIdentifier(identifier3(prefix), TokenFactory.tokenFromType(To kenType.PERIOD), identifier);
200
201 static PrefixedIdentifier identifier5(String prefix, String identifier) => new PrefixedIdentifier(identifier3(prefix), TokenFactory.tokenFromType(TokenType.PE RIOD), identifier3(identifier));
202
203 static IfStatement ifStatement(Expression condition, Statement thenStatement) => ifStatement2(condition, thenStatement, null);
204
205 static IfStatement ifStatement2(Expression condition, Statement thenStatement, Statement elseStatement) => new IfStatement(TokenFactory.tokenFromKeyword(Keywo rd.IF), TokenFactory.tokenFromType(TokenType.OPEN_PAREN), condition, TokenFactor y.tokenFromType(TokenType.CLOSE_PAREN), thenStatement, elseStatement == null ? n ull : TokenFactory.tokenFromKeyword(Keyword.ELSE), elseStatement);
206
207 static ImplementsClause implementsClause(List<TypeName> types) => new Implemen tsClause(TokenFactory.tokenFromKeyword(Keyword.IMPLEMENTS), list(types));
208
209 static ImportDirective importDirective(List<Annotation> metadata, String uri, bool isDeferred, String prefix, List<Combinator> combinators) => new ImportDirec tive(null, metadata, TokenFactory.tokenFromKeyword(Keyword.IMPORT), string2(uri) , !isDeferred ? null : TokenFactory.tokenFromKeyword(Keyword.DEFERRED), prefix = = null ? null : TokenFactory.tokenFromKeyword(Keyword.AS), prefix == null ? null : identifier3(prefix), list(combinators), TokenFactory.tokenFromType(TokenType. SEMICOLON));
210
211 static ImportDirective importDirective2(String uri, bool isDeferred, String pr efix, List<Combinator> combinators) => importDirective(new List<Annotation>(), u ri, isDeferred, prefix, combinators);
212
213 static ImportDirective importDirective3(String uri, String prefix, List<Combin ator> combinators) => importDirective(new List<Annotation>(), uri, false, prefix , combinators);
214
215 static IndexExpression indexExpression(Expression array, Expression index) => new IndexExpression.forTarget(array, TokenFactory.tokenFromType(TokenType.OPEN_S QUARE_BRACKET), index, TokenFactory.tokenFromType(TokenType.CLOSE_SQUARE_BRACKET ));
216
217 static InstanceCreationExpression instanceCreationExpression(Keyword keyword, ConstructorName name, List<Expression> arguments) => new InstanceCreationExpress ion(keyword == null ? null : TokenFactory.tokenFromKeyword(keyword), name, argum entList(arguments));
218
219 static InstanceCreationExpression instanceCreationExpression2(Keyword keyword, TypeName type, List<Expression> arguments) => instanceCreationExpression3(keywo rd, type, null, arguments);
220
221 static InstanceCreationExpression instanceCreationExpression3(Keyword keyword, TypeName type, String identifier, List<Expression> arguments) => instanceCreati onExpression(keyword, new ConstructorName(type, identifier == null ? null : Toke nFactory.tokenFromType(TokenType.PERIOD), identifier == null ? null : identifier 3(identifier)), arguments);
222
223 static IntegerLiteral integer(int value) => new IntegerLiteral(TokenFactory.to kenFromTypeAndString(TokenType.INT, value.toString()), value);
224
225 static InterpolationExpression interpolationExpression(Expression expression) => new InterpolationExpression(TokenFactory.tokenFromType(TokenType.STRING_INTER POLATION_EXPRESSION), expression, TokenFactory.tokenFromType(TokenType.CLOSE_CUR LY_BRACKET));
226
227 static InterpolationExpression interpolationExpression2(String identifier) => new InterpolationExpression(TokenFactory.tokenFromType(TokenType.STRING_INTERPOL ATION_IDENTIFIER), identifier3(identifier), null);
228
229 static InterpolationString interpolationString(String contents, String value) => new InterpolationString(TokenFactory.tokenFromString(contents), value);
230
231 static IsExpression isExpression(Expression expression, bool negated, TypeName type) => new IsExpression(expression, TokenFactory.tokenFromKeyword(Keyword.IS) , negated ? TokenFactory.tokenFromType(TokenType.BANG) : null, type);
232
233 static Label label(SimpleIdentifier label) => new Label(label, TokenFactory.to kenFromType(TokenType.COLON));
234
235 static Label label2(String label) => AstFactory.label(identifier3(label));
236
237 static LabeledStatement labeledStatement(List<Label> labels, Statement stateme nt) => new LabeledStatement(labels, statement);
238
239 static LibraryDirective libraryDirective(List<Annotation> metadata, LibraryIde ntifier libraryName) => new LibraryDirective(null, metadata, TokenFactory.tokenF romKeyword(Keyword.LIBRARY), libraryName, TokenFactory.tokenFromType(TokenType.S EMICOLON));
240
241 static LibraryDirective libraryDirective2(String libraryName) => libraryDirect ive(new List<Annotation>(), libraryIdentifier2([libraryName]));
242
243 static LibraryIdentifier libraryIdentifier(List<SimpleIdentifier> components) => new LibraryIdentifier(list(components));
244
245 static LibraryIdentifier libraryIdentifier2(List<String> components) {
246 List<SimpleIdentifier> componentList = new List<SimpleIdentifier>();
247 for (String component in components) {
248 componentList.add(identifier3(component));
249 }
250 return new LibraryIdentifier(componentList);
251 }
252
253 static List list(List<Object> elements) {
254 List elementList = new List();
255 for (Object element in elements) {
256 elementList.add(element);
257 }
258 return elementList;
259 }
260
261 static ListLiteral listLiteral(List<Expression> elements) => listLiteral2(null , null, elements);
262
263 static ListLiteral listLiteral2(Keyword keyword, TypeArgumentList typeArgument s, List<Expression> elements) => new ListLiteral(keyword == null ? null : TokenF actory.tokenFromKeyword(keyword), typeArguments, TokenFactory.tokenFromType(Toke nType.OPEN_SQUARE_BRACKET), list(elements), TokenFactory.tokenFromType(TokenType .CLOSE_SQUARE_BRACKET));
264
265 static MapLiteral mapLiteral(Keyword keyword, TypeArgumentList typeArguments, List<MapLiteralEntry> entries) => new MapLiteral(keyword == null ? null : TokenF actory.tokenFromKeyword(keyword), typeArguments, TokenFactory.tokenFromType(Toke nType.OPEN_CURLY_BRACKET), list(entries), TokenFactory.tokenFromType(TokenType.C LOSE_CURLY_BRACKET));
266
267 static MapLiteral mapLiteral2(List<MapLiteralEntry> entries) => mapLiteral(nul l, null, entries);
268
269 static MapLiteralEntry mapLiteralEntry(String key, Expression value) => new Ma pLiteralEntry(string2(key), TokenFactory.tokenFromType(TokenType.COLON), value);
270
271 static MethodDeclaration methodDeclaration(Keyword modifier, TypeName returnTy pe, Keyword property, Keyword operator, SimpleIdentifier name, FormalParameterLi st parameters) => new MethodDeclaration(null, null, TokenFactory.tokenFromKeywor d(Keyword.EXTERNAL), modifier == null ? null : TokenFactory.tokenFromKeyword(mod ifier), returnType, property == null ? null : TokenFactory.tokenFromKeyword(prop erty), operator == null ? null : TokenFactory.tokenFromKeyword(operator), name, parameters, emptyFunctionBody());
272
273 static MethodDeclaration methodDeclaration2(Keyword modifier, TypeName returnT ype, Keyword property, Keyword operator, SimpleIdentifier name, FormalParameterL ist parameters, FunctionBody body) => new MethodDeclaration(null, null, null, mo difier == null ? null : TokenFactory.tokenFromKeyword(modifier), returnType, pro perty == null ? null : TokenFactory.tokenFromKeyword(property), operator == null ? null : TokenFactory.tokenFromKeyword(operator), name, parameters, body);
274
275 static MethodInvocation methodInvocation(Expression target, String methodName, List<Expression> arguments) => new MethodInvocation(target, target == null ? nu ll : TokenFactory.tokenFromType(TokenType.PERIOD), identifier3(methodName), argu mentList(arguments));
276
277 static MethodInvocation methodInvocation2(String methodName, List<Expression> arguments) => methodInvocation(null, methodName, arguments);
278
279 static NamedExpression namedExpression(Label label, Expression expression) => new NamedExpression(label, expression);
280
281 static NamedExpression namedExpression2(String label, Expression expression) = > namedExpression(label2(label), expression);
282
283 static DefaultFormalParameter namedFormalParameter(NormalFormalParameter param eter, Expression expression) => new DefaultFormalParameter(parameter, ParameterK ind.NAMED, expression == null ? null : TokenFactory.tokenFromType(TokenType.COLO N), expression);
284
285 static NativeClause nativeClause(String nativeCode) => new NativeClause(TokenF actory.tokenFromString("native"), string2(nativeCode));
286
287 static NativeFunctionBody nativeFunctionBody(String nativeMethodName) => new N ativeFunctionBody(TokenFactory.tokenFromString("native"), string2(nativeMethodNa me), TokenFactory.tokenFromType(TokenType.SEMICOLON));
288
289 static NullLiteral nullLiteral() => new NullLiteral(TokenFactory.tokenFromKeyw ord(Keyword.NULL));
290
291 static ParenthesizedExpression parenthesizedExpression(Expression expression) => new ParenthesizedExpression(TokenFactory.tokenFromType(TokenType.OPEN_PAREN), expression, TokenFactory.tokenFromType(TokenType.CLOSE_PAREN));
292
293 static PartDirective partDirective(List<Annotation> metadata, String url) => n ew PartDirective(null, metadata, TokenFactory.tokenFromKeyword(Keyword.PART), st ring2(url), TokenFactory.tokenFromType(TokenType.SEMICOLON));
294
295 static PartDirective partDirective2(String url) => partDirective(new List<Anno tation>(), url);
296
297 static PartOfDirective partOfDirective(LibraryIdentifier libraryName) => partO fDirective2(new List<Annotation>(), libraryName);
298
299 static PartOfDirective partOfDirective2(List<Annotation> metadata, LibraryIden tifier libraryName) => new PartOfDirective(null, metadata, TokenFactory.tokenFro mKeyword(Keyword.PART), TokenFactory.tokenFromString("of"), libraryName, TokenFa ctory.tokenFromType(TokenType.SEMICOLON));
300
301 static DefaultFormalParameter positionalFormalParameter(NormalFormalParameter parameter, Expression expression) => new DefaultFormalParameter(parameter, Param eterKind.POSITIONAL, expression == null ? null : TokenFactory.tokenFromType(Toke nType.EQ), expression);
302
303 static PostfixExpression postfixExpression(Expression expression, TokenType op erator) => new PostfixExpression(expression, TokenFactory.tokenFromType(operator ));
304
305 static PrefixExpression prefixExpression(TokenType operator, Expression expres sion) => new PrefixExpression(TokenFactory.tokenFromType(operator), expression);
306
307 static PropertyAccess propertyAccess(Expression target, SimpleIdentifier prope rtyName) => new PropertyAccess(target, TokenFactory.tokenFromType(TokenType.PERI OD), propertyName);
308
309 static PropertyAccess propertyAccess2(Expression target, String propertyName) => new PropertyAccess(target, TokenFactory.tokenFromType(TokenType.PERIOD), iden tifier3(propertyName));
310
311 static RedirectingConstructorInvocation redirectingConstructorInvocation(List< Expression> arguments) => redirectingConstructorInvocation2(null, arguments);
312
313 static RedirectingConstructorInvocation redirectingConstructorInvocation2(Stri ng constructorName, List<Expression> arguments) => new RedirectingConstructorInv ocation(TokenFactory.tokenFromKeyword(Keyword.THIS), constructorName == null ? n ull : TokenFactory.tokenFromType(TokenType.PERIOD), constructorName == null ? nu ll : identifier3(constructorName), argumentList(arguments));
314
315 static RethrowExpression rethrowExpression() => new RethrowExpression(TokenFac tory.tokenFromKeyword(Keyword.RETHROW));
316
317 static ReturnStatement returnStatement() => returnStatement2(null);
318
319 static ReturnStatement returnStatement2(Expression expression) => new ReturnSt atement(TokenFactory.tokenFromKeyword(Keyword.RETURN), expression, TokenFactory. tokenFromType(TokenType.SEMICOLON));
320
321 static ScriptTag scriptTag(String scriptTag) => new ScriptTag(TokenFactory.tok enFromString(scriptTag));
322
323 static ShowCombinator showCombinator(List<SimpleIdentifier> identifiers) => ne w ShowCombinator(TokenFactory.tokenFromString("show"), list(identifiers));
324
325 static ShowCombinator showCombinator2(List<String> identifiers) {
326 List<SimpleIdentifier> identifierList = new List<SimpleIdentifier>();
327 for (String identifier in identifiers) {
328 identifierList.add(identifier3(identifier));
329 }
330 return new ShowCombinator(TokenFactory.tokenFromString("show"), identifierLi st);
331 }
332
333 static SimpleFormalParameter simpleFormalParameter(Keyword keyword, String par ameterName) => simpleFormalParameter2(keyword, null, parameterName);
334
335 static SimpleFormalParameter simpleFormalParameter2(Keyword keyword, TypeName type, String parameterName) => new SimpleFormalParameter(null, null, keyword == null ? null : TokenFactory.tokenFromKeyword(keyword), type, identifier3(paramete rName));
336
337 static SimpleFormalParameter simpleFormalParameter3(String parameterName) => s impleFormalParameter2(null, null, parameterName);
338
339 static SimpleFormalParameter simpleFormalParameter4(TypeName type, String para meterName) => simpleFormalParameter2(null, type, parameterName);
340
341 static StringInterpolation string(List<InterpolationElement> elements) => new StringInterpolation(list(elements));
342
343 static SimpleStringLiteral string2(String content) => new SimpleStringLiteral( TokenFactory.tokenFromString("'${content}'"), content);
344
345 static SuperConstructorInvocation superConstructorInvocation(List<Expression> arguments) => superConstructorInvocation2(null, arguments);
346
347 static SuperConstructorInvocation superConstructorInvocation2(String name, Lis t<Expression> arguments) => new SuperConstructorInvocation(TokenFactory.tokenFro mKeyword(Keyword.SUPER), name == null ? null : TokenFactory.tokenFromType(TokenT ype.PERIOD), name == null ? null : identifier3(name), argumentList(arguments));
348
349 static SuperExpression superExpression() => new SuperExpression(TokenFactory.t okenFromKeyword(Keyword.SUPER));
350
351 static SwitchCase switchCase(Expression expression, List<Statement> statements ) => switchCase2(new List<Label>(), expression, statements);
352
353 static SwitchCase switchCase2(List<Label> labels, Expression expression, List< Statement> statements) => new SwitchCase(labels, TokenFactory.tokenFromKeyword(K eyword.CASE), expression, TokenFactory.tokenFromType(TokenType.COLON), list(stat ements));
354
355 static SwitchDefault switchDefault(List<Label> labels, List<Statement> stateme nts) => new SwitchDefault(labels, TokenFactory.tokenFromKeyword(Keyword.DEFAULT) , TokenFactory.tokenFromType(TokenType.COLON), list(statements));
356
357 static SwitchDefault switchDefault2(List<Statement> statements) => switchDefau lt(new List<Label>(), statements);
358
359 static SwitchStatement switchStatement(Expression expression, List<SwitchMembe r> members) => new SwitchStatement(TokenFactory.tokenFromKeyword(Keyword.SWITCH) , TokenFactory.tokenFromType(TokenType.OPEN_PAREN), expression, TokenFactory.tok enFromType(TokenType.CLOSE_PAREN), TokenFactory.tokenFromType(TokenType.OPEN_CUR LY_BRACKET), list(members), TokenFactory.tokenFromType(TokenType.CLOSE_CURLY_BRA CKET));
360
361 static SymbolLiteral symbolLiteral(List<String> components) {
362 List<Token> identifierList = new List<Token>();
363 for (String component in components) {
364 identifierList.add(TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIE R, component));
365 }
366 return new SymbolLiteral(TokenFactory.tokenFromType(TokenType.HASH), new Lis t.from(identifierList));
367 }
368
369 static BlockFunctionBody syncBlockFunctionBody(List<Statement> statements) => new BlockFunctionBody(TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "sync"), null, block(statements));
370
371 static BlockFunctionBody syncGeneratorBlockFunctionBody(List<Statement> statem ents) => new BlockFunctionBody(TokenFactory.tokenFromTypeAndString(TokenType.IDE NTIFIER, "sync"), TokenFactory.tokenFromType(TokenType.STAR), block(statements)) ;
372
373 static ThisExpression thisExpression() => new ThisExpression(TokenFactory.toke nFromKeyword(Keyword.THIS));
374
375 static ThrowExpression throwExpression() => throwExpression2(null);
376
377 static ThrowExpression throwExpression2(Expression expression) => new ThrowExp ression(TokenFactory.tokenFromKeyword(Keyword.THROW), expression);
378
379 static TopLevelVariableDeclaration topLevelVariableDeclaration(Keyword keyword , TypeName type, List<VariableDeclaration> variables) => new TopLevelVariableDec laration(null, null, variableDeclarationList(keyword, type, variables), TokenFac tory.tokenFromType(TokenType.SEMICOLON));
380
381 static TopLevelVariableDeclaration topLevelVariableDeclaration2(Keyword keywor d, List<VariableDeclaration> variables) => new TopLevelVariableDeclaration(null, null, variableDeclarationList(keyword, null, variables), TokenFactory.tokenFrom Type(TokenType.SEMICOLON));
382
383 static TryStatement tryStatement(Block body, Block finallyClause) => tryStatem ent3(body, new List<CatchClause>(), finallyClause);
384
385 static TryStatement tryStatement2(Block body, List<CatchClause> catchClauses) => tryStatement3(body, list(catchClauses), null);
386
387 static TryStatement tryStatement3(Block body, List<CatchClause> catchClauses, Block finallyClause) => new TryStatement(TokenFactory.tokenFromKeyword(Keyword.T RY), body, catchClauses, finallyClause == null ? null : TokenFactory.tokenFromKe yword(Keyword.FINALLY), finallyClause);
388
389 static FunctionTypeAlias typeAlias(TypeName returnType, String name, TypeParam eterList typeParameters, FormalParameterList parameters) => new FunctionTypeAlia s(null, null, TokenFactory.tokenFromKeyword(Keyword.TYPEDEF), returnType, identi fier3(name), typeParameters, parameters, TokenFactory.tokenFromType(TokenType.SE MICOLON));
390
391 static TypeArgumentList typeArgumentList(List<TypeName> typeNames) => new Type ArgumentList(TokenFactory.tokenFromType(TokenType.LT), list(typeNames), TokenFac tory.tokenFromType(TokenType.GT));
392
393 /**
394 * Create a type name whose name has been resolved to the given element and wh ose type has been
395 * resolved to the type of the given element.
396 *
397 * <b>Note:</b> This method does not correctly handle class elements that have type parameters.
398 *
399 * @param element the element defining the type represented by the type name
400 * @return the type name that was created
401 */
402 static TypeName typeName(ClassElement element, List<TypeName> arguments) {
403 SimpleIdentifier name = identifier3(element.name);
404 name.staticElement = element;
405 TypeName typeName = typeName3(name, arguments);
406 typeName.type = element.type;
407 return typeName;
408 }
409
410 static TypeName typeName3(Identifier name, List<TypeName> arguments) {
411 if (arguments.length == 0) {
412 return new TypeName(name, null);
413 }
414 return new TypeName(name, typeArgumentList(arguments));
415 }
416
417 static TypeName typeName4(String name, List<TypeName> arguments) {
418 if (arguments.length == 0) {
419 return new TypeName(identifier3(name), null);
420 }
421 return new TypeName(identifier3(name), typeArgumentList(arguments));
422 }
423
424 static TypeParameter typeParameter(String name) => new TypeParameter(null, nul l, identifier3(name), null, null);
425
426 static TypeParameter typeParameter2(String name, TypeName bound) => new TypePa rameter(null, null, identifier3(name), TokenFactory.tokenFromKeyword(Keyword.EXT ENDS), bound);
427
428 static TypeParameterList typeParameterList(List<String> typeNames) {
429 List<TypeParameter> typeParameters = new List<TypeParameter>();
430 for (String typeName in typeNames) {
431 typeParameters.add(typeParameter(typeName));
432 }
433 return new TypeParameterList(TokenFactory.tokenFromType(TokenType.LT), typeP arameters, TokenFactory.tokenFromType(TokenType.GT));
434 }
435
436 static VariableDeclaration variableDeclaration(String name) => new VariableDec laration(null, null, identifier3(name), null, null);
437
438 static VariableDeclaration variableDeclaration2(String name, Expression initia lizer) => new VariableDeclaration(null, null, identifier3(name), TokenFactory.to kenFromType(TokenType.EQ), initializer);
439
440 static VariableDeclarationList variableDeclarationList(Keyword keyword, TypeNa me type, List<VariableDeclaration> variables) => new VariableDeclarationList(nul l, null, keyword == null ? null : TokenFactory.tokenFromKeyword(keyword), type, list(variables));
441
442 static VariableDeclarationList variableDeclarationList2(Keyword keyword, List< VariableDeclaration> variables) => variableDeclarationList(keyword, null, variab les);
443
444 static VariableDeclarationStatement variableDeclarationStatement(Keyword keywo rd, TypeName type, List<VariableDeclaration> variables) => new VariableDeclarati onStatement(variableDeclarationList(keyword, type, variables), TokenFactory.toke nFromType(TokenType.SEMICOLON));
445
446 static VariableDeclarationStatement variableDeclarationStatement2(Keyword keyw ord, List<VariableDeclaration> variables) => variableDeclarationStatement(keywor d, null, variables);
447
448 static WhileStatement whileStatement(Expression condition, Statement body) => new WhileStatement(TokenFactory.tokenFromKeyword(Keyword.WHILE), TokenFactory.to kenFromType(TokenType.OPEN_PAREN), condition, TokenFactory.tokenFromType(TokenTy pe.CLOSE_PAREN), body);
449
450 static WithClause withClause(List<TypeName> types) => new WithClause(TokenFact ory.tokenFromKeyword(Keyword.WITH), list(types));
451
452 static YieldStatement yieldEachStatement(Expression expression) => new YieldSt atement(TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "yield"), Toke nFactory.tokenFromType(TokenType.STAR), expression, TokenFactory.tokenFromType(T okenType.SEMICOLON));
453
454 static YieldStatement yieldStatement(Expression expression) => new YieldStatem ent(TokenFactory.tokenFromTypeAndString(TokenType.IDENTIFIER, "yield"), null, ex pression, TokenFactory.tokenFromType(TokenType.SEMICOLON));
455 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698