| OLD | NEW |
| 1 // This code was auto-generated, is not intended to be edited, and is subject to | 1 // This code was auto-generated, is not intended to be edited, and is subject to |
| 2 // significant change. Please see the README file for more information. | 2 // significant change. Please see the README file for more information. |
| 3 library engine.ast_test; | 3 library engine.ast_test; |
| 4 import 'dart:collection'; | 4 import 'dart:collection'; |
| 5 import 'package:analyzer_experimental/src/generated/java_core.dart'; | 5 import 'package:analyzer_experimental/src/generated/java_core.dart'; |
| 6 import 'package:analyzer_experimental/src/generated/java_engine.dart'; | 6 import 'package:analyzer_experimental/src/generated/java_engine.dart'; |
| 7 import 'package:analyzer_experimental/src/generated/java_junit.dart'; | 7 import 'package:analyzer_experimental/src/generated/java_junit.dart'; |
| 8 import 'package:analyzer_experimental/src/generated/source.dart'; | 8 import 'package:analyzer_experimental/src/generated/source.dart'; |
| 9 import 'package:analyzer_experimental/src/generated/error.dart'; | 9 import 'package:analyzer_experimental/src/generated/error.dart'; |
| 10 import 'package:analyzer_experimental/src/generated/scanner.dart'; | 10 import 'package:analyzer_experimental/src/generated/scanner.dart'; |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 | 401 |
| 402 /** | 402 /** |
| 403 * Create a type name whose name has been resolved to the given element and wh
ose type has been | 403 * Create a type name whose name has been resolved to the given element and wh
ose type has been |
| 404 * resolved to the type of the given element. | 404 * resolved to the type of the given element. |
| 405 * <p> | 405 * <p> |
| 406 * <b>Note:</b> This method does not correctly handle class elements that have
type parameters. | 406 * <b>Note:</b> This method does not correctly handle class elements that have
type parameters. |
| 407 * @param element the element defining the type represented by the type name | 407 * @param element the element defining the type represented by the type name |
| 408 * @return the type name that was created | 408 * @return the type name that was created |
| 409 */ | 409 */ |
| 410 static TypeName typeName(ClassElement element2, List<TypeName> arguments) { | 410 static TypeName typeName(ClassElement element2, List<TypeName> arguments) { |
| 411 SimpleIdentifier name2 = identifier3(element2.name); | 411 SimpleIdentifier name = identifier3(element2.name); |
| 412 name2.element = element2; | 412 name.element = element2; |
| 413 TypeName typeName = typeName3(name2, arguments); | 413 TypeName typeName = typeName3(name, arguments); |
| 414 typeName.type = element2.type; | 414 typeName.type = element2.type; |
| 415 return typeName; | 415 return typeName; |
| 416 } | 416 } |
| 417 static TypeName typeName3(Identifier name, List<TypeName> arguments) { | 417 static TypeName typeName3(Identifier name, List<TypeName> arguments) { |
| 418 if (arguments.length == 0) { | 418 if (arguments.length == 0) { |
| 419 return new TypeName.full(name, null); | 419 return new TypeName.full(name, null); |
| 420 } | 420 } |
| 421 return new TypeName.full(name, typeArgumentList(arguments)); | 421 return new TypeName.full(name, typeArgumentList(arguments)); |
| 422 } | 422 } |
| 423 static TypeName typeName4(String name, List<TypeName> arguments) { | 423 static TypeName typeName4(String name, List<TypeName> arguments) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 439 static VariableDeclaration variableDeclaration2(String name, Expression initia
lizer) => new VariableDeclaration.full(null, null, identifier3(name), TokenFacto
ry.token3(TokenType.EQ), initializer); | 439 static VariableDeclaration variableDeclaration2(String name, Expression initia
lizer) => new VariableDeclaration.full(null, null, identifier3(name), TokenFacto
ry.token3(TokenType.EQ), initializer); |
| 440 static VariableDeclarationList variableDeclarationList(Keyword keyword, TypeNa
me type, List<VariableDeclaration> variables) => new VariableDeclarationList.ful
l(null, null, keyword == null ? null : TokenFactory.token(keyword), type, list(v
ariables)); | 440 static VariableDeclarationList variableDeclarationList(Keyword keyword, TypeNa
me type, List<VariableDeclaration> variables) => new VariableDeclarationList.ful
l(null, null, keyword == null ? null : TokenFactory.token(keyword), type, list(v
ariables)); |
| 441 static VariableDeclarationList variableDeclarationList2(Keyword keyword, List<
VariableDeclaration> variables) => variableDeclarationList(keyword, null, variab
les); | 441 static VariableDeclarationList variableDeclarationList2(Keyword keyword, List<
VariableDeclaration> variables) => variableDeclarationList(keyword, null, variab
les); |
| 442 static VariableDeclarationStatement variableDeclarationStatement(Keyword keywo
rd, TypeName type, List<VariableDeclaration> variables) => new VariableDeclarati
onStatement.full(variableDeclarationList(keyword, type, variables), TokenFactory
.token3(TokenType.SEMICOLON)); | 442 static VariableDeclarationStatement variableDeclarationStatement(Keyword keywo
rd, TypeName type, List<VariableDeclaration> variables) => new VariableDeclarati
onStatement.full(variableDeclarationList(keyword, type, variables), TokenFactory
.token3(TokenType.SEMICOLON)); |
| 443 static VariableDeclarationStatement variableDeclarationStatement2(Keyword keyw
ord, List<VariableDeclaration> variables) => variableDeclarationStatement(keywor
d, null, variables); | 443 static VariableDeclarationStatement variableDeclarationStatement2(Keyword keyw
ord, List<VariableDeclaration> variables) => variableDeclarationStatement(keywor
d, null, variables); |
| 444 static WhileStatement whileStatement(Expression condition, Statement body) =>
new WhileStatement.full(TokenFactory.token(Keyword.WHILE), TokenFactory.token3(T
okenType.OPEN_PAREN), condition, TokenFactory.token3(TokenType.CLOSE_PAREN), bod
y); | 444 static WhileStatement whileStatement(Expression condition, Statement body) =>
new WhileStatement.full(TokenFactory.token(Keyword.WHILE), TokenFactory.token3(T
okenType.OPEN_PAREN), condition, TokenFactory.token3(TokenType.CLOSE_PAREN), bod
y); |
| 445 static WithClause withClause(List<TypeName> types) => new WithClause.full(Toke
nFactory.token(Keyword.WITH), list(types)); | 445 static WithClause withClause(List<TypeName> types) => new WithClause.full(Toke
nFactory.token(Keyword.WITH), list(types)); |
| 446 } | 446 } |
| 447 class SimpleIdentifierTest extends ParserTestCase { | 447 class SimpleIdentifierTest extends ParserTestCase { |
| 448 void test_inDeclarationContext_argumentDefinition() { | 448 void test_inDeclarationContext_argumentDefinition() { |
| 449 SimpleIdentifier identifier2 = ASTFactory.argumentDefinitionTest("p").identi
fier; | 449 SimpleIdentifier identifier = ASTFactory.argumentDefinitionTest("p").identif
ier; |
| 450 JUnitTestCase.assertFalse(identifier2.inDeclarationContext()); | 450 JUnitTestCase.assertFalse(identifier.inDeclarationContext()); |
| 451 } | 451 } |
| 452 void test_inDeclarationContext_catch_exception() { | 452 void test_inDeclarationContext_catch_exception() { |
| 453 SimpleIdentifier identifier = ASTFactory.catchClause("e", []).exceptionParam
eter; | 453 SimpleIdentifier identifier = ASTFactory.catchClause("e", []).exceptionParam
eter; |
| 454 JUnitTestCase.assertTrue(identifier.inDeclarationContext()); | 454 JUnitTestCase.assertTrue(identifier.inDeclarationContext()); |
| 455 } | 455 } |
| 456 void test_inDeclarationContext_catch_stack() { | 456 void test_inDeclarationContext_catch_stack() { |
| 457 SimpleIdentifier identifier = ASTFactory.catchClause2("e", "s", []).stackTra
ceParameter; | 457 SimpleIdentifier identifier = ASTFactory.catchClause2("e", "s", []).stackTra
ceParameter; |
| 458 JUnitTestCase.assertTrue(identifier.inDeclarationContext()); | 458 JUnitTestCase.assertTrue(identifier.inDeclarationContext()); |
| 459 } | 459 } |
| 460 void test_inDeclarationContext_classDeclaration() { | 460 void test_inDeclarationContext_classDeclaration() { |
| 461 SimpleIdentifier identifier = ASTFactory.classDeclaration(null, "C", null, n
ull, null, null, []).name; | 461 SimpleIdentifier identifier = ASTFactory.classDeclaration(null, "C", null, n
ull, null, null, []).name; |
| 462 JUnitTestCase.assertTrue(identifier.inDeclarationContext()); | 462 JUnitTestCase.assertTrue(identifier.inDeclarationContext()); |
| 463 } | 463 } |
| 464 void test_inDeclarationContext_classTypeAlias() { | 464 void test_inDeclarationContext_classTypeAlias() { |
| 465 SimpleIdentifier identifier = ASTFactory.classTypeAlias("C", null, null, nul
l, null, null).name; | 465 SimpleIdentifier identifier = ASTFactory.classTypeAlias("C", null, null, nul
l, null, null).name; |
| 466 JUnitTestCase.assertTrue(identifier.inDeclarationContext()); | 466 JUnitTestCase.assertTrue(identifier.inDeclarationContext()); |
| 467 } | 467 } |
| 468 void test_inDeclarationContext_constructorDeclaration() { | 468 void test_inDeclarationContext_constructorDeclaration() { |
| 469 SimpleIdentifier identifier = ASTFactory.constructorDeclaration(ASTFactory.i
dentifier3("C"), "c", null, null).name; | 469 SimpleIdentifier identifier = ASTFactory.constructorDeclaration(ASTFactory.i
dentifier3("C"), "c", null, null).name; |
| 470 JUnitTestCase.assertTrue(identifier.inDeclarationContext()); | 470 JUnitTestCase.assertTrue(identifier.inDeclarationContext()); |
| 471 } | 471 } |
| 472 void test_inDeclarationContext_fieldFormalParameter() { | 472 void test_inDeclarationContext_fieldFormalParameter() { |
| 473 SimpleIdentifier identifier2 = ASTFactory.fieldFormalParameter2("p").identif
ier; | 473 SimpleIdentifier identifier = ASTFactory.fieldFormalParameter2("p").identifi
er; |
| 474 JUnitTestCase.assertFalse(identifier2.inDeclarationContext()); | 474 JUnitTestCase.assertFalse(identifier.inDeclarationContext()); |
| 475 } | 475 } |
| 476 void test_inDeclarationContext_functionDeclaration() { | 476 void test_inDeclarationContext_functionDeclaration() { |
| 477 SimpleIdentifier identifier = ASTFactory.functionDeclaration(null, null, "f"
, null).name; | 477 SimpleIdentifier identifier = ASTFactory.functionDeclaration(null, null, "f"
, null).name; |
| 478 JUnitTestCase.assertTrue(identifier.inDeclarationContext()); | 478 JUnitTestCase.assertTrue(identifier.inDeclarationContext()); |
| 479 } | 479 } |
| 480 void test_inDeclarationContext_functionTypeAlias() { | 480 void test_inDeclarationContext_functionTypeAlias() { |
| 481 SimpleIdentifier identifier = ASTFactory.typeAlias(null, "F", null, null).na
me; | 481 SimpleIdentifier identifier = ASTFactory.typeAlias(null, "F", null, null).na
me; |
| 482 JUnitTestCase.assertTrue(identifier.inDeclarationContext()); | 482 JUnitTestCase.assertTrue(identifier.inDeclarationContext()); |
| 483 } | 483 } |
| 484 void test_inDeclarationContext_label_false() { | 484 void test_inDeclarationContext_label_false() { |
| 485 SimpleIdentifier identifier = ASTFactory.namedExpression2("l", ASTFactory.in
teger(0)).name.label; | 485 SimpleIdentifier identifier = ASTFactory.namedExpression2("l", ASTFactory.in
teger(0)).name.label; |
| 486 JUnitTestCase.assertFalse(identifier.inDeclarationContext()); | 486 JUnitTestCase.assertFalse(identifier.inDeclarationContext()); |
| 487 } | 487 } |
| 488 void test_inDeclarationContext_label_true() { | 488 void test_inDeclarationContext_label_true() { |
| 489 Label label = ASTFactory.label2("l"); | 489 Label label = ASTFactory.label2("l"); |
| 490 SimpleIdentifier identifier = label.label; | 490 SimpleIdentifier identifier = label.label; |
| 491 ASTFactory.labeledStatement(ASTFactory.list([label]), ASTFactory.emptyStatem
ent()); | 491 ASTFactory.labeledStatement(ASTFactory.list([label]), ASTFactory.emptyStatem
ent()); |
| 492 JUnitTestCase.assertTrue(identifier.inDeclarationContext()); | 492 JUnitTestCase.assertTrue(identifier.inDeclarationContext()); |
| 493 } | 493 } |
| 494 void test_inDeclarationContext_methodDeclaration() { | 494 void test_inDeclarationContext_methodDeclaration() { |
| 495 SimpleIdentifier identifier = ASTFactory.identifier3("m"); | 495 SimpleIdentifier identifier = ASTFactory.identifier3("m"); |
| 496 ASTFactory.methodDeclaration2(null, null, null, null, identifier, null, null
); | 496 ASTFactory.methodDeclaration2(null, null, null, null, identifier, null, null
); |
| 497 JUnitTestCase.assertTrue(identifier.inDeclarationContext()); | 497 JUnitTestCase.assertTrue(identifier.inDeclarationContext()); |
| 498 } | 498 } |
| 499 void test_inDeclarationContext_simpleFormalParameter() { | 499 void test_inDeclarationContext_simpleFormalParameter() { |
| 500 SimpleIdentifier identifier2 = ASTFactory.simpleFormalParameter3("p").identi
fier; | 500 SimpleIdentifier identifier = ASTFactory.simpleFormalParameter3("p").identif
ier; |
| 501 JUnitTestCase.assertTrue(identifier2.inDeclarationContext()); | 501 JUnitTestCase.assertTrue(identifier.inDeclarationContext()); |
| 502 } | 502 } |
| 503 void test_inDeclarationContext_typeParameter_bound() { | 503 void test_inDeclarationContext_typeParameter_bound() { |
| 504 TypeName bound = ASTFactory.typeName4("A", []); | 504 TypeName bound = ASTFactory.typeName4("A", []); |
| 505 SimpleIdentifier identifier = bound.name as SimpleIdentifier; | 505 SimpleIdentifier identifier = bound.name as SimpleIdentifier; |
| 506 ASTFactory.typeParameter2("E", bound); | 506 ASTFactory.typeParameter2("E", bound); |
| 507 JUnitTestCase.assertFalse(identifier.inDeclarationContext()); | 507 JUnitTestCase.assertFalse(identifier.inDeclarationContext()); |
| 508 } | 508 } |
| 509 void test_inDeclarationContext_typeParameter_name() { | 509 void test_inDeclarationContext_typeParameter_name() { |
| 510 SimpleIdentifier identifier = ASTFactory.typeParameter("E").name; | 510 SimpleIdentifier identifier = ASTFactory.typeParameter("E").name; |
| 511 JUnitTestCase.assertTrue(identifier.inDeclarationContext()); | 511 JUnitTestCase.assertTrue(identifier.inDeclarationContext()); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 return identifier; | 592 return identifier; |
| 593 } | 593 } |
| 594 | 594 |
| 595 /** | 595 /** |
| 596 * Return the top-most node in the AST structure containing the given identifi
er. | 596 * Return the top-most node in the AST structure containing the given identifi
er. |
| 597 * @param identifier the identifier in the AST structure being traversed | 597 * @param identifier the identifier in the AST structure being traversed |
| 598 * @return the root of the AST structure containing the identifier | 598 * @return the root of the AST structure containing the identifier |
| 599 */ | 599 */ |
| 600 ASTNode topMostNode(SimpleIdentifier identifier) { | 600 ASTNode topMostNode(SimpleIdentifier identifier) { |
| 601 ASTNode child = identifier; | 601 ASTNode child = identifier; |
| 602 ASTNode parent2 = identifier.parent; | 602 ASTNode parent = identifier.parent; |
| 603 while (parent2 != null) { | 603 while (parent != null) { |
| 604 child = parent2; | 604 child = parent; |
| 605 parent2 = parent2.parent; | 605 parent = parent.parent; |
| 606 } | 606 } |
| 607 return child; | 607 return child; |
| 608 } | 608 } |
| 609 static dartSuite() { | 609 static dartSuite() { |
| 610 _ut.group('SimpleIdentifierTest', () { | 610 _ut.group('SimpleIdentifierTest', () { |
| 611 _ut.test('test_inDeclarationContext_argumentDefinition', () { | 611 _ut.test('test_inDeclarationContext_argumentDefinition', () { |
| 612 final __test = new SimpleIdentifierTest(); | 612 final __test = new SimpleIdentifierTest(); |
| 613 runJUnitTest(__test, __test.test_inDeclarationContext_argumentDefinition
); | 613 runJUnitTest(__test, __test.test_inDeclarationContext_argumentDefinition
); |
| 614 }); | 614 }); |
| 615 _ut.test('test_inDeclarationContext_catch_exception', () { | 615 _ut.test('test_inDeclarationContext_catch_exception', () { |
| (...skipping 2320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2936 } | 2936 } |
| 2937 main() { | 2937 main() { |
| 2938 ConstantEvaluatorTest.dartSuite(); | 2938 ConstantEvaluatorTest.dartSuite(); |
| 2939 NodeLocatorTest.dartSuite(); | 2939 NodeLocatorTest.dartSuite(); |
| 2940 ToSourceVisitorTest.dartSuite(); | 2940 ToSourceVisitorTest.dartSuite(); |
| 2941 BreadthFirstVisitorTest.dartSuite(); | 2941 BreadthFirstVisitorTest.dartSuite(); |
| 2942 IndexExpressionTest.dartSuite(); | 2942 IndexExpressionTest.dartSuite(); |
| 2943 SimpleIdentifierTest.dartSuite(); | 2943 SimpleIdentifierTest.dartSuite(); |
| 2944 VariableDeclarationTest.dartSuite(); | 2944 VariableDeclarationTest.dartSuite(); |
| 2945 } | 2945 } |
| OLD | NEW |