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/token.dart'; | 7 import 'package:analyzer/dart/ast/token.dart'; |
7 import 'package:analyzer/src/dart/ast/token.dart'; | 8 import 'package:analyzer/src/dart/ast/token.dart'; |
8 import 'package:analyzer/src/generated/utilities_dart.dart'; | 9 import 'package:analyzer/src/generated/utilities_dart.dart'; |
9 import 'package:logging/logging.dart' as logger; | 10 import 'package:logging/logging.dart' as logger; |
10 | 11 |
11 final _log = new logger.Logger('dev_compiler.ast_builder'); | 12 final _log = new logger.Logger('dev_compiler.ast_builder'); |
12 | 13 |
13 // Wrappers around constructors for the dart ast. The AstBuilder class | 14 // Wrappers around constructors for the dart ast. The AstBuilder class |
14 // provides a higher-level interface, abstracting both from the lexical | 15 // provides a higher-level interface, abstracting both from the lexical |
15 // details and some of helper classes. The RawAstBuilder class provides | 16 // details and some of helper classes. The RawAstBuilder class provides |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 if (exp is Identifier || | 96 if (exp is Identifier || |
96 exp is ParenthesizedExpression || | 97 exp is ParenthesizedExpression || |
97 exp is FunctionExpressionInvocation || | 98 exp is FunctionExpressionInvocation || |
98 exp is MethodInvocation) return exp; | 99 exp is MethodInvocation) return exp; |
99 return parenthesizedExpression(exp); | 100 return parenthesizedExpression(exp); |
100 } | 101 } |
101 | 102 |
102 static PropertyAccess propertyAccess( | 103 static PropertyAccess propertyAccess( |
103 Expression target, SimpleIdentifier name) { | 104 Expression target, SimpleIdentifier name) { |
104 var p = new Token(TokenType.PERIOD, 0); | 105 var p = new Token(TokenType.PERIOD, 0); |
105 return new PropertyAccess(target, p, name); | 106 return astFactory.propertyAccess(target, p, name); |
106 } | 107 } |
107 | 108 |
108 static MethodInvocation methodInvoke(Expression target, SimpleIdentifier name, | 109 static MethodInvocation methodInvoke(Expression target, SimpleIdentifier name, |
109 TypeArgumentList typeArguments, NodeList<Expression> args) { | 110 TypeArgumentList typeArguments, NodeList<Expression> args) { |
110 var p = new Token(TokenType.PERIOD, 0); | 111 var p = new Token(TokenType.PERIOD, 0); |
111 return new MethodInvocation( | 112 return astFactory.methodInvocation( |
112 target, p, name, typeArguments, argumentList(args)); | 113 target, p, name, typeArguments, argumentList(args)); |
113 } | 114 } |
114 | 115 |
115 static TokenType getTokenType(String lexeme) { | 116 static TokenType getTokenType(String lexeme) { |
116 switch (lexeme) { | 117 switch (lexeme) { |
117 case "&": | 118 case "&": |
118 return TokenType.AMPERSAND; | 119 return TokenType.AMPERSAND; |
119 case "&&": | 120 case "&&": |
120 return TokenType.AMPERSAND_AMPERSAND; | 121 return TokenType.AMPERSAND_AMPERSAND; |
121 case "&=": | 122 case "&=": |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 static NamedExpression namedExpression(String s, Expression e) { | 353 static NamedExpression namedExpression(String s, Expression e) { |
353 return RawAstBuilder.namedExpression(identifierFromString(s), e); | 354 return RawAstBuilder.namedExpression(identifierFromString(s), e); |
354 } | 355 } |
355 | 356 |
356 /// Declares a single variable `var <name> = <init>` with the type and name | 357 /// Declares a single variable `var <name> = <init>` with the type and name |
357 /// specified by the VariableElement. See also [variableStatement]. | 358 /// specified by the VariableElement. See also [variableStatement]. |
358 static VariableDeclarationList declareVariable(SimpleIdentifier name, | 359 static VariableDeclarationList declareVariable(SimpleIdentifier name, |
359 [Expression init]) { | 360 [Expression init]) { |
360 var eqToken = init != null ? new Token(TokenType.EQ, 0) : null; | 361 var eqToken = init != null ? new Token(TokenType.EQ, 0) : null; |
361 var varToken = new KeywordToken(Keyword.VAR, 0); | 362 var varToken = new KeywordToken(Keyword.VAR, 0); |
362 return new VariableDeclarationList(null, null, varToken, null, | 363 return astFactory.variableDeclarationList(null, null, varToken, null, |
363 [new VariableDeclaration(name, eqToken, init)]); | 364 [astFactory.variableDeclaration(name, eqToken, init)]); |
364 } | 365 } |
365 | 366 |
366 static VariableDeclarationStatement variableStatement(SimpleIdentifier name, | 367 static VariableDeclarationStatement variableStatement(SimpleIdentifier name, |
367 [Expression init]) { | 368 [Expression init]) { |
368 return RawAstBuilder | 369 return RawAstBuilder |
369 .variableDeclarationStatement(declareVariable(name, init)); | 370 .variableDeclarationStatement(declareVariable(name, init)); |
370 } | 371 } |
371 | 372 |
372 static InstanceCreationExpression instanceCreation( | 373 static InstanceCreationExpression instanceCreation( |
373 ConstructorName ctor, List<Expression> args) { | 374 ConstructorName ctor, List<Expression> args) { |
374 var newToken = new KeywordToken(Keyword.NEW, 0); | 375 var newToken = new KeywordToken(Keyword.NEW, 0); |
375 return new InstanceCreationExpression( | 376 return astFactory.instanceCreationExpression( |
376 newToken, ctor, RawAstBuilder.argumentList(args)); | 377 newToken, ctor, RawAstBuilder.argumentList(args)); |
377 } | 378 } |
378 } | 379 } |
379 | 380 |
380 // This class provides a low-level wrapper around the constructors for | 381 // This class provides a low-level wrapper around the constructors for |
381 // the AST. It mostly simply abstracts from the lexical tokens. | 382 // the AST. It mostly simply abstracts from the lexical tokens. |
382 class RawAstBuilder { | 383 class RawAstBuilder { |
383 static ConstructorName constructorName(TypeName type, | 384 static ConstructorName constructorName(TypeName type, |
384 [SimpleIdentifier name]) { | 385 [SimpleIdentifier name]) { |
385 Token period = name != null ? new Token(TokenType.PERIOD, 0) : null; | 386 Token period = name != null ? new Token(TokenType.PERIOD, 0) : null; |
386 return new ConstructorName(type, period, name); | 387 return astFactory.constructorName(type, period, name); |
387 } | 388 } |
388 | 389 |
389 static SimpleIdentifier identifierFromString(String name) { | 390 static SimpleIdentifier identifierFromString(String name) { |
390 StringToken token = new SyntheticStringToken(TokenType.IDENTIFIER, name, 0); | 391 StringToken token = new SyntheticStringToken(TokenType.IDENTIFIER, name, 0); |
391 return new SimpleIdentifier(token); | 392 return astFactory.simpleIdentifier(token); |
392 } | 393 } |
393 | 394 |
394 static PrefixedIdentifier prefixedIdentifier( | 395 static PrefixedIdentifier prefixedIdentifier( |
395 SimpleIdentifier pre, SimpleIdentifier id) { | 396 SimpleIdentifier pre, SimpleIdentifier id) { |
396 Token period = new Token(TokenType.PERIOD, 0); | 397 Token period = new Token(TokenType.PERIOD, 0); |
397 return new PrefixedIdentifier(pre, period, id); | 398 return astFactory.prefixedIdentifier(pre, period, id); |
398 } | 399 } |
399 | 400 |
400 static TypeParameter typeParameter(SimpleIdentifier name, | 401 static TypeParameter typeParameter(SimpleIdentifier name, |
401 [TypeName bound = null]) { | 402 [TypeName bound = null]) { |
402 Token keyword = | 403 Token keyword = |
403 (bound == null) ? null : new KeywordToken(Keyword.EXTENDS, 0); | 404 (bound == null) ? null : new KeywordToken(Keyword.EXTENDS, 0); |
404 return new TypeParameter(null, null, name, keyword, bound); | 405 return astFactory.typeParameter(null, null, name, keyword, bound); |
405 } | 406 } |
406 | 407 |
407 static TypeParameterList typeParameterList(List<TypeParameter> params) { | 408 static TypeParameterList typeParameterList(List<TypeParameter> params) { |
408 Token lb = new Token(TokenType.LT, 0); | 409 Token lb = new Token(TokenType.LT, 0); |
409 Token rb = new Token(TokenType.GT, 0); | 410 Token rb = new Token(TokenType.GT, 0); |
410 return new TypeParameterList(lb, params, rb); | 411 return astFactory.typeParameterList(lb, params, rb); |
411 } | 412 } |
412 | 413 |
413 static TypeArgumentList typeArgumentList(List<TypeName> args) { | 414 static TypeArgumentList typeArgumentList(List<TypeName> args) { |
414 Token lb = new Token(TokenType.LT, 0); | 415 Token lb = new Token(TokenType.LT, 0); |
415 Token rb = new Token(TokenType.GT, 0); | 416 Token rb = new Token(TokenType.GT, 0); |
416 return new TypeArgumentList(lb, args, rb); | 417 return astFactory.typeArgumentList(lb, args, rb); |
417 } | 418 } |
418 | 419 |
419 static ArgumentList argumentList(List<Expression> args) { | 420 static ArgumentList argumentList(List<Expression> args) { |
420 Token lp = new BeginToken(TokenType.OPEN_PAREN, 0); | 421 Token lp = new BeginToken(TokenType.OPEN_PAREN, 0); |
421 Token rp = new Token(TokenType.CLOSE_PAREN, 0); | 422 Token rp = new Token(TokenType.CLOSE_PAREN, 0); |
422 return new ArgumentList(lp, args, rp); | 423 return astFactory.argumentList(lp, args, rp); |
423 } | 424 } |
424 | 425 |
425 static TypeName typeName(Identifier id, TypeArgumentList l) { | 426 static TypeName typeName(Identifier id, TypeArgumentList l) { |
426 return new TypeName(id, l); | 427 return astFactory.typeName(id, l); |
427 } | 428 } |
428 | 429 |
429 static FunctionTypeAlias functionTypeAlias(TypeName ret, | 430 static FunctionTypeAlias functionTypeAlias(TypeName ret, |
430 SimpleIdentifier name, TypeParameterList tps, FormalParameterList fps) { | 431 SimpleIdentifier name, TypeParameterList tps, FormalParameterList fps) { |
431 Token semi = new Token(TokenType.SEMICOLON, 0); | 432 Token semi = new Token(TokenType.SEMICOLON, 0); |
432 Token td = new KeywordToken(Keyword.TYPEDEF, 0); | 433 Token td = new KeywordToken(Keyword.TYPEDEF, 0); |
433 return new FunctionTypeAlias(null, null, td, ret, name, tps, fps, semi); | 434 return astFactory.functionTypeAlias( |
| 435 null, null, td, ret, name, tps, fps, semi); |
434 } | 436 } |
435 | 437 |
436 static BooleanLiteral booleanLiteral(bool b) { | 438 static BooleanLiteral booleanLiteral(bool b) { |
437 var k = new KeywordToken(b ? Keyword.TRUE : Keyword.FALSE, 0); | 439 var k = new KeywordToken(b ? Keyword.TRUE : Keyword.FALSE, 0); |
438 return new BooleanLiteral(k, b); | 440 return astFactory.booleanLiteral(k, b); |
439 } | 441 } |
440 | 442 |
441 static NullLiteral nullLiteral() { | 443 static NullLiteral nullLiteral() { |
442 var n = new KeywordToken(Keyword.NULL, 0); | 444 var n = new KeywordToken(Keyword.NULL, 0); |
443 return new NullLiteral(n); | 445 return astFactory.nullLiteral(n); |
444 } | 446 } |
445 | 447 |
446 static IntegerLiteral integerLiteral(int i) { | 448 static IntegerLiteral integerLiteral(int i) { |
447 StringToken token = new StringToken(TokenType.INT, '$i', 0); | 449 StringToken token = new StringToken(TokenType.INT, '$i', 0); |
448 return new IntegerLiteral(token, i); | 450 return astFactory.integerLiteral(token, i); |
449 } | 451 } |
450 | 452 |
451 static SimpleStringLiteral simpleStringLiteral(String s) { | 453 static SimpleStringLiteral simpleStringLiteral(String s) { |
452 StringToken token = new StringToken(TokenType.STRING, "\"" + s + "\"", 0); | 454 StringToken token = new StringToken(TokenType.STRING, "\"" + s + "\"", 0); |
453 return new SimpleStringLiteral(token, s); | 455 return astFactory.simpleStringLiteral(token, s); |
454 } | 456 } |
455 | 457 |
456 static SimpleStringLiteral tripleQuotedStringLiteral(String s) { | 458 static SimpleStringLiteral tripleQuotedStringLiteral(String s) { |
457 StringToken token = new StringToken(TokenType.STRING, '"""' + s + '"""', 0); | 459 StringToken token = new StringToken(TokenType.STRING, '"""' + s + '"""', 0); |
458 return new SimpleStringLiteral(token, s); | 460 return astFactory.simpleStringLiteral(token, s); |
459 } | 461 } |
460 | 462 |
461 static AsExpression asExpression(Expression exp, TypeName type) { | 463 static AsExpression asExpression(Expression exp, TypeName type) { |
462 Token token = new KeywordToken(Keyword.AS, 0); | 464 Token token = new KeywordToken(Keyword.AS, 0); |
463 return new AsExpression(exp, token, type); | 465 return astFactory.asExpression(exp, token, type); |
464 } | 466 } |
465 | 467 |
466 static IsExpression isExpression(Expression exp, TypeName type) { | 468 static IsExpression isExpression(Expression exp, TypeName type) { |
467 Token token = new KeywordToken(Keyword.IS, 0); | 469 Token token = new KeywordToken(Keyword.IS, 0); |
468 return new IsExpression(exp, token, null, type); | 470 return astFactory.isExpression(exp, token, null, type); |
469 } | 471 } |
470 | 472 |
471 static ParenthesizedExpression parenthesizedExpression(Expression exp) { | 473 static ParenthesizedExpression parenthesizedExpression(Expression exp) { |
472 Token lp = new BeginToken(TokenType.OPEN_PAREN, exp.offset); | 474 Token lp = new BeginToken(TokenType.OPEN_PAREN, exp.offset); |
473 Token rp = new Token(TokenType.CLOSE_PAREN, exp.end); | 475 Token rp = new Token(TokenType.CLOSE_PAREN, exp.end); |
474 return new ParenthesizedExpression(lp, exp, rp); | 476 return astFactory.parenthesizedExpression(lp, exp, rp); |
475 } | 477 } |
476 | 478 |
477 static BinaryExpression binaryExpression( | 479 static BinaryExpression binaryExpression( |
478 Expression l, Token op, Expression r) { | 480 Expression l, Token op, Expression r) { |
479 return new BinaryExpression(l, op, r); | 481 return astFactory.binaryExpression(l, op, r); |
480 } | 482 } |
481 | 483 |
482 static ConditionalExpression conditionalExpression( | 484 static ConditionalExpression conditionalExpression( |
483 Expression cond, Expression tExp, Expression fExp) { | 485 Expression cond, Expression tExp, Expression fExp) { |
484 var q = new Token(TokenType.QUESTION, 0); | 486 var q = new Token(TokenType.QUESTION, 0); |
485 var c = new Token(TokenType.COLON, 0); | 487 var c = new Token(TokenType.COLON, 0); |
486 return new ConditionalExpression(cond, q, tExp, c, fExp); | 488 return astFactory.conditionalExpression(cond, q, tExp, c, fExp); |
487 } | 489 } |
488 | 490 |
489 static Expression functionExpressionInvocation( | 491 static Expression functionExpressionInvocation( |
490 Expression function, ArgumentList es) { | 492 Expression function, ArgumentList es) { |
491 return new FunctionExpressionInvocation(function, null, es); | 493 return astFactory.functionExpressionInvocation(function, null, es); |
492 } | 494 } |
493 | 495 |
494 static FormalParameterList formalParameterList(List<FormalParameter> params) { | 496 static FormalParameterList formalParameterList(List<FormalParameter> params) { |
495 Token lp = new BeginToken(TokenType.OPEN_PAREN, 0); | 497 Token lp = new BeginToken(TokenType.OPEN_PAREN, 0); |
496 Token rp = new Token(TokenType.CLOSE_PAREN, 0); | 498 Token rp = new Token(TokenType.CLOSE_PAREN, 0); |
497 bool hasOptional = params.any((p) => p.kind == ParameterKind.POSITIONAL); | 499 bool hasOptional = params.any((p) => p.kind == ParameterKind.POSITIONAL); |
498 bool hasNamed = params.any((p) => p.kind == ParameterKind.NAMED); | 500 bool hasNamed = params.any((p) => p.kind == ParameterKind.NAMED); |
499 assert(!(hasOptional && hasNamed)); | 501 assert(!(hasOptional && hasNamed)); |
500 Token ld = null; | 502 Token ld = null; |
501 Token rd = null; | 503 Token rd = null; |
502 if (hasOptional) { | 504 if (hasOptional) { |
503 ld = new BeginToken(TokenType.OPEN_SQUARE_BRACKET, 0); | 505 ld = new BeginToken(TokenType.OPEN_SQUARE_BRACKET, 0); |
504 rd = new Token(TokenType.CLOSE_SQUARE_BRACKET, 0); | 506 rd = new Token(TokenType.CLOSE_SQUARE_BRACKET, 0); |
505 } | 507 } |
506 if (hasNamed) { | 508 if (hasNamed) { |
507 ld = new BeginToken(TokenType.OPEN_CURLY_BRACKET, 0); | 509 ld = new BeginToken(TokenType.OPEN_CURLY_BRACKET, 0); |
508 rd = new Token(TokenType.CLOSE_CURLY_BRACKET, 0); | 510 rd = new Token(TokenType.CLOSE_CURLY_BRACKET, 0); |
509 } | 511 } |
510 return new FormalParameterList(lp, params, ld, rd, rp); | 512 return astFactory.formalParameterList(lp, params, ld, rd, rp); |
511 } | 513 } |
512 | 514 |
513 static Block block(List<Statement> statements) { | 515 static Block block(List<Statement> statements) { |
514 Token ld = new BeginToken(TokenType.OPEN_CURLY_BRACKET, 0); | 516 Token ld = new BeginToken(TokenType.OPEN_CURLY_BRACKET, 0); |
515 Token rd = new Token(TokenType.CLOSE_CURLY_BRACKET, 0); | 517 Token rd = new Token(TokenType.CLOSE_CURLY_BRACKET, 0); |
516 return new Block(ld, statements, rd); | 518 return astFactory.block(ld, statements, rd); |
517 } | 519 } |
518 | 520 |
519 static BlockFunctionBody blockFunctionBody(Block b) { | 521 static BlockFunctionBody blockFunctionBody(Block b) { |
520 return new BlockFunctionBody(null, null, b); | 522 return astFactory.blockFunctionBody(null, null, b); |
521 } | 523 } |
522 | 524 |
523 static ExpressionFunctionBody expressionFunctionBody(Expression body, | 525 static ExpressionFunctionBody expressionFunctionBody(Expression body, |
524 [bool decl = false]) { | 526 [bool decl = false]) { |
525 Token semi = (decl) ? new Token(TokenType.SEMICOLON, 0) : null; | 527 Token semi = (decl) ? new Token(TokenType.SEMICOLON, 0) : null; |
526 return new ExpressionFunctionBody(null, null, body, semi); | 528 return astFactory.expressionFunctionBody(null, null, body, semi); |
527 } | 529 } |
528 | 530 |
529 static ExpressionStatement expressionStatement(Expression expression) { | 531 static ExpressionStatement expressionStatement(Expression expression) { |
530 Token semi = new Token(TokenType.SEMICOLON, 0); | 532 Token semi = new Token(TokenType.SEMICOLON, 0); |
531 return new ExpressionStatement(expression, semi); | 533 return astFactory.expressionStatement(expression, semi); |
532 } | 534 } |
533 | 535 |
534 static FunctionDeclaration functionDeclaration( | 536 static FunctionDeclaration functionDeclaration( |
535 TypeName rt, SimpleIdentifier f, FunctionExpression fexp) { | 537 TypeName rt, SimpleIdentifier f, FunctionExpression fexp) { |
536 return new FunctionDeclaration(null, null, null, rt, null, f, fexp); | 538 return astFactory.functionDeclaration(null, null, null, rt, null, f, fexp); |
537 } | 539 } |
538 | 540 |
539 static MethodDeclaration methodDeclaration(TypeName rt, SimpleIdentifier m, | 541 static MethodDeclaration methodDeclaration(TypeName rt, SimpleIdentifier m, |
540 FormalParameterList fl, FunctionBody body, | 542 FormalParameterList fl, FunctionBody body, |
541 {bool isStatic: false}) { | 543 {bool isStatic: false}) { |
542 Token st = isStatic ? new KeywordToken(Keyword.STATIC, 0) : null; | 544 Token st = isStatic ? new KeywordToken(Keyword.STATIC, 0) : null; |
543 return new MethodDeclaration( | 545 return astFactory.methodDeclaration( |
544 null, null, null, st, rt, null, null, m, null, fl, body); | 546 null, null, null, st, rt, null, null, m, null, fl, body); |
545 } | 547 } |
546 | 548 |
547 static FunctionExpression functionExpression( | 549 static FunctionExpression functionExpression( |
548 FormalParameterList fl, FunctionBody body) { | 550 FormalParameterList fl, FunctionBody body) { |
549 return new FunctionExpression(null, fl, body); | 551 return astFactory.functionExpression(null, fl, body); |
550 } | 552 } |
551 | 553 |
552 static FunctionDeclarationStatement functionDeclarationStatement( | 554 static FunctionDeclarationStatement functionDeclarationStatement( |
553 FunctionDeclaration fd) { | 555 FunctionDeclaration fd) { |
554 return new FunctionDeclarationStatement(fd); | 556 return astFactory.functionDeclarationStatement(fd); |
555 } | 557 } |
556 | 558 |
557 static Statement returnExpression([Expression e]) { | 559 static Statement returnExpression([Expression e]) { |
558 Token ret = new KeywordToken(Keyword.RETURN, 0); | 560 Token ret = new KeywordToken(Keyword.RETURN, 0); |
559 Token semi = new Token(TokenType.SEMICOLON, 0); | 561 Token semi = new Token(TokenType.SEMICOLON, 0); |
560 return new ReturnStatement(ret, e, semi); | 562 return astFactory.returnStatement(ret, e, semi); |
561 } | 563 } |
562 | 564 |
563 static SimpleFormalParameter simpleFormalParameter( | 565 static SimpleFormalParameter simpleFormalParameter( |
564 SimpleIdentifier v, TypeName t) { | 566 SimpleIdentifier v, TypeName t) { |
565 return new SimpleFormalParameter(null, <Annotation>[], null, t, v); | 567 return astFactory.simpleFormalParameter(null, <Annotation>[], null, t, v); |
566 } | 568 } |
567 | 569 |
568 static FunctionTypedFormalParameter functionTypedFormalParameter( | 570 static FunctionTypedFormalParameter functionTypedFormalParameter( |
569 TypeName ret, SimpleIdentifier v, FormalParameterList ps) { | 571 TypeName ret, SimpleIdentifier v, FormalParameterList ps) { |
570 return new FunctionTypedFormalParameter( | 572 return astFactory.functionTypedFormalParameter( |
571 null, <Annotation>[], ret, v, null, ps); | 573 null, <Annotation>[], ret, v, null, ps); |
572 } | 574 } |
573 | 575 |
574 static FormalParameter requiredFormalParameter(NormalFormalParameter fp) { | 576 static FormalParameter requiredFormalParameter(NormalFormalParameter fp) { |
575 return fp; | 577 return fp; |
576 } | 578 } |
577 | 579 |
578 static FormalParameter optionalFormalParameter(NormalFormalParameter fp) { | 580 static FormalParameter optionalFormalParameter(NormalFormalParameter fp) { |
579 return new DefaultFormalParameter(fp, ParameterKind.POSITIONAL, null, null); | 581 return astFactory.defaultFormalParameter( |
| 582 fp, ParameterKind.POSITIONAL, null, null); |
580 } | 583 } |
581 | 584 |
582 static FormalParameter namedFormalParameter(NormalFormalParameter fp) { | 585 static FormalParameter namedFormalParameter(NormalFormalParameter fp) { |
583 return new DefaultFormalParameter(fp, ParameterKind.NAMED, null, null); | 586 return astFactory.defaultFormalParameter( |
| 587 fp, ParameterKind.NAMED, null, null); |
584 } | 588 } |
585 | 589 |
586 static NamedExpression namedParameter(SimpleIdentifier s, Expression e) { | 590 static NamedExpression namedParameter(SimpleIdentifier s, Expression e) { |
587 return namedExpression(s, e); | 591 return namedExpression(s, e); |
588 } | 592 } |
589 | 593 |
590 static NamedExpression namedExpression(SimpleIdentifier s, Expression e) { | 594 static NamedExpression namedExpression(SimpleIdentifier s, Expression e) { |
591 Label l = new Label(s, new Token(TokenType.COLON, 0)); | 595 Label l = astFactory.label(s, new Token(TokenType.COLON, 0)); |
592 return new NamedExpression(l, e); | 596 return astFactory.namedExpression(l, e); |
593 } | 597 } |
594 | 598 |
595 static VariableDeclarationStatement variableDeclarationStatement( | 599 static VariableDeclarationStatement variableDeclarationStatement( |
596 VariableDeclarationList varDecl) { | 600 VariableDeclarationList varDecl) { |
597 var semi = new Token(TokenType.SEMICOLON, 0); | 601 var semi = new Token(TokenType.SEMICOLON, 0); |
598 return new VariableDeclarationStatement(varDecl, semi); | 602 return astFactory.variableDeclarationStatement(varDecl, semi); |
599 } | 603 } |
600 } | 604 } |
OLD | NEW |