| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'package:analyzer/dart/ast/ast.dart'; | 5 import 'package:analyzer/dart/ast/ast.dart'; |
| 6 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; | 6 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; |
| 7 import 'package:analyzer/dart/ast/token.dart'; | 7 import 'package:analyzer/dart/ast/token.dart'; |
| 8 import 'package:analyzer/src/dart/ast/token.dart'; | 8 import 'package:analyzer/src/dart/ast/token.dart'; |
| 9 import 'package:analyzer/src/generated/utilities_dart.dart'; | 9 import 'package:analyzer/src/generated/utilities_dart.dart'; |
| 10 import 'package:logging/logging.dart' as logger; | 10 import 'package:logging/logging.dart' as logger; |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 return RawAstBuilder.returnExpression(e); | 315 return RawAstBuilder.returnExpression(e); |
| 316 } | 316 } |
| 317 | 317 |
| 318 // let b = e1 in e2 == (\b.e2)(e1) | 318 // let b = e1 in e2 == (\b.e2)(e1) |
| 319 static Expression letExpression( | 319 static Expression letExpression( |
| 320 FormalParameter b, Expression e1, Expression e2) { | 320 FormalParameter b, Expression e1, Expression e2) { |
| 321 FunctionExpression l = expressionFunction(<FormalParameter>[b], e2); | 321 FunctionExpression l = expressionFunction(<FormalParameter>[b], e2); |
| 322 return application(parenthesize(l), <Expression>[e1]); | 322 return application(parenthesize(l), <Expression>[e1]); |
| 323 } | 323 } |
| 324 | 324 |
| 325 static SimpleFormalParameter simpleFormal(SimpleIdentifier v, TypeName t) { | |
| 326 return RawAstBuilder.simpleFormalParameter(v, t); | |
| 327 } | |
| 328 | |
| 329 static FunctionTypedFormalParameter functionTypedFormal( | |
| 330 TypeName ret, SimpleIdentifier v, List<FormalParameter> params) { | |
| 331 FormalParameterList ps = formalParameterList(params); | |
| 332 return RawAstBuilder.functionTypedFormalParameter(ret, v, ps); | |
| 333 } | |
| 334 | |
| 335 static FormalParameter requiredFormal(NormalFormalParameter fp) { | 325 static FormalParameter requiredFormal(NormalFormalParameter fp) { |
| 336 return RawAstBuilder.requiredFormalParameter(fp); | 326 return RawAstBuilder.requiredFormalParameter(fp); |
| 337 } | 327 } |
| 338 | 328 |
| 339 static FormalParameter optionalFormal(NormalFormalParameter fp) { | 329 static FormalParameter optionalFormal(NormalFormalParameter fp) { |
| 340 return RawAstBuilder.optionalFormalParameter(fp); | 330 return RawAstBuilder.optionalFormalParameter(fp); |
| 341 } | 331 } |
| 342 | 332 |
| 343 static FormalParameter namedFormal(NormalFormalParameter fp) { | 333 static FormalParameter namedFormal(NormalFormalParameter fp) { |
| 344 return RawAstBuilder.namedFormalParameter(fp); | 334 return RawAstBuilder.namedFormalParameter(fp); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 FunctionDeclaration fd) { | 543 FunctionDeclaration fd) { |
| 554 return astFactory.functionDeclarationStatement(fd); | 544 return astFactory.functionDeclarationStatement(fd); |
| 555 } | 545 } |
| 556 | 546 |
| 557 static Statement returnExpression([Expression e]) { | 547 static Statement returnExpression([Expression e]) { |
| 558 Token ret = new KeywordToken(Keyword.RETURN, 0); | 548 Token ret = new KeywordToken(Keyword.RETURN, 0); |
| 559 Token semi = new Token(TokenType.SEMICOLON, 0); | 549 Token semi = new Token(TokenType.SEMICOLON, 0); |
| 560 return astFactory.returnStatement(ret, e, semi); | 550 return astFactory.returnStatement(ret, e, semi); |
| 561 } | 551 } |
| 562 | 552 |
| 563 static SimpleFormalParameter simpleFormalParameter( | |
| 564 SimpleIdentifier v, TypeName t) { | |
| 565 return astFactory.simpleFormalParameter(null, <Annotation>[], null, t, v); | |
| 566 } | |
| 567 | |
| 568 static FunctionTypedFormalParameter functionTypedFormalParameter( | |
| 569 TypeName ret, SimpleIdentifier v, FormalParameterList ps) { | |
| 570 return astFactory.functionTypedFormalParameter( | |
| 571 null, <Annotation>[], ret, v, null, ps); | |
| 572 } | |
| 573 | |
| 574 static FormalParameter requiredFormalParameter(NormalFormalParameter fp) { | 553 static FormalParameter requiredFormalParameter(NormalFormalParameter fp) { |
| 575 return fp; | 554 return fp; |
| 576 } | 555 } |
| 577 | 556 |
| 578 static FormalParameter optionalFormalParameter(NormalFormalParameter fp) { | 557 static FormalParameter optionalFormalParameter(NormalFormalParameter fp) { |
| 579 return astFactory.defaultFormalParameter( | 558 return astFactory.defaultFormalParameter( |
| 580 fp, ParameterKind.POSITIONAL, null, null); | 559 fp, ParameterKind.POSITIONAL, null, null); |
| 581 } | 560 } |
| 582 | 561 |
| 583 static FormalParameter namedFormalParameter(NormalFormalParameter fp) { | 562 static FormalParameter namedFormalParameter(NormalFormalParameter fp) { |
| 584 return astFactory.defaultFormalParameter( | 563 return astFactory.defaultFormalParameter( |
| 585 fp, ParameterKind.NAMED, null, null); | 564 fp, ParameterKind.NAMED, null, null); |
| 586 } | 565 } |
| 587 | 566 |
| 588 static NamedExpression namedParameter(SimpleIdentifier s, Expression e) { | 567 static NamedExpression namedParameter(SimpleIdentifier s, Expression e) { |
| 589 return namedExpression(s, e); | 568 return namedExpression(s, e); |
| 590 } | 569 } |
| 591 | 570 |
| 592 static NamedExpression namedExpression(SimpleIdentifier s, Expression e) { | 571 static NamedExpression namedExpression(SimpleIdentifier s, Expression e) { |
| 593 Label l = astFactory.label(s, new Token(TokenType.COLON, 0)); | 572 Label l = astFactory.label(s, new Token(TokenType.COLON, 0)); |
| 594 return astFactory.namedExpression(l, e); | 573 return astFactory.namedExpression(l, e); |
| 595 } | 574 } |
| 596 | 575 |
| 597 static VariableDeclarationStatement variableDeclarationStatement( | 576 static VariableDeclarationStatement variableDeclarationStatement( |
| 598 VariableDeclarationList varDecl) { | 577 VariableDeclarationList varDecl) { |
| 599 var semi = new Token(TokenType.SEMICOLON, 0); | 578 var semi = new Token(TokenType.SEMICOLON, 0); |
| 600 return astFactory.variableDeclarationStatement(varDecl, semi); | 579 return astFactory.variableDeclarationStatement(varDecl, semi); |
| 601 } | 580 } |
| 602 } | 581 } |
| OLD | NEW |