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

Side by Side Diff: pkg/analyzer_experimental/test/generated/ast_test.dart

Issue 16256021: Remove trailing spaces in analyzer_experimental (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
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
4 library engine.ast_test; 3 library engine.ast_test;
5
6 import 'dart:collection'; 4 import 'dart:collection';
7 import 'package:analyzer_experimental/src/generated/java_core.dart'; 5 import 'package:analyzer_experimental/src/generated/java_core.dart';
8 import 'package:analyzer_experimental/src/generated/java_engine.dart'; 6 import 'package:analyzer_experimental/src/generated/java_engine.dart';
9 import 'package:analyzer_experimental/src/generated/java_junit.dart'; 7 import 'package:analyzer_experimental/src/generated/java_junit.dart';
10 import 'package:analyzer_experimental/src/generated/source.dart'; 8 import 'package:analyzer_experimental/src/generated/source.dart';
11 import 'package:analyzer_experimental/src/generated/error.dart'; 9 import 'package:analyzer_experimental/src/generated/error.dart';
12 import 'package:analyzer_experimental/src/generated/scanner.dart'; 10 import 'package:analyzer_experimental/src/generated/scanner.dart';
13 import 'package:analyzer_experimental/src/generated/ast.dart'; 11 import 'package:analyzer_experimental/src/generated/ast.dart';
14 import 'package:analyzer_experimental/src/generated/utilities_dart.dart'; 12 import 'package:analyzer_experimental/src/generated/utilities_dart.dart';
15 import 'package:analyzer_experimental/src/generated/element.dart' show ClassElem ent; 13 import 'package:analyzer_experimental/src/generated/element.dart' show ClassElem ent;
16 import 'package:unittest/unittest.dart' as _ut; 14 import 'package:unittest/unittest.dart' as _ut;
17 import 'parser_test.dart' show ParserTestCase; 15 import 'parser_test.dart' show ParserTestCase;
18 import 'test_support.dart'; 16 import 'test_support.dart';
19 import 'scanner_test.dart' show TokenFactory; 17 import 'scanner_test.dart' show TokenFactory;
20
21 class NodeLocatorTest extends ParserTestCase { 18 class NodeLocatorTest extends ParserTestCase {
22 void test_offset() { 19 void test_offset() {
23 CompilationUnit unit = ParserTestCase.parseCompilationUnit("library myLib;", []); 20 CompilationUnit unit = ParserTestCase.parseCompilationUnit("library myLib;", []);
24 assertLocate(unit, 10, SimpleIdentifier); 21 assertLocate(unit, 10, SimpleIdentifier);
25 } 22 }
26 void test_offsetAfterNode() { 23 void test_offsetAfterNode() {
27 CompilationUnit unit = ParserTestCase.parseCompilationUnit(EngineTestCase.cr eateSource(["class A {}", "class B {}"]), []); 24 CompilationUnit unit = ParserTestCase.parseCompilationUnit(EngineTestCase.cr eateSource(["class A {}", "class B {}"]), []);
28 NodeLocator locator = new NodeLocator.con2(1024, 1024); 25 NodeLocator locator = new NodeLocator.con2(1024, 1024);
29 ASTNode node = locator.searchWithin(unit.declarations[0]); 26 ASTNode node = locator.searchWithin(unit.declarations[0]);
30 JUnitTestCase.assertNull(node); 27 JUnitTestCase.assertNull(node);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 final __test = new IndexExpressionTest(); 175 final __test = new IndexExpressionTest();
179 runJUnitTest(__test, __test.test_inSetterContext_prefix_minusMinus); 176 runJUnitTest(__test, __test.test_inSetterContext_prefix_minusMinus);
180 }); 177 });
181 _ut.test('test_inSetterContext_prefix_plusPlus', () { 178 _ut.test('test_inSetterContext_prefix_plusPlus', () {
182 final __test = new IndexExpressionTest(); 179 final __test = new IndexExpressionTest();
183 runJUnitTest(__test, __test.test_inSetterContext_prefix_plusPlus); 180 runJUnitTest(__test, __test.test_inSetterContext_prefix_plusPlus);
184 }); 181 });
185 }); 182 });
186 } 183 }
187 } 184 }
188
189 /** 185 /**
190 * The class {@code ASTFactory} defines utility methods that can be used to crea te AST nodes. The 186 * The class {@code ASTFactory} defines utility methods that can be used to crea te AST nodes. The
191 * nodes that are created are complete in the sense that all of the tokens that would have been 187 * nodes that are created are complete in the sense that all of the tokens that would have been
192 * associated with the nodes by a parser are also created, but the token stream is not constructed. 188 * associated with the nodes by a parser are also created, but the token stream is not constructed.
193 * None of the nodes are resolved. 189 * None of the nodes are resolved.
194 * <p> 190 * <p>
195 * The general pattern is for the name of the factory method to be the same as t he name of the class 191 * The general pattern is for the name of the factory method to be the same as t he name of the class
196 * of AST node being created. There are two notable exceptions. The first is for methods creating 192 * of AST node being created. There are two notable exceptions. The first is for methods creating
197 * nodes that are part of a cascade expression. These methods are all prefixed w ith 'cascaded'. The 193 * nodes that are part of a cascade expression. These methods are all prefixed w ith 'cascaded'. The
198 * second is places where a shorter name seemed unambiguous and easier to read, such as using 194 * second is places where a shorter name seemed unambiguous and easier to read, such as using
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 static ThisExpression thisExpression() => new ThisExpression.full(TokenFactory .token(Keyword.THIS)); 362 static ThisExpression thisExpression() => new ThisExpression.full(TokenFactory .token(Keyword.THIS));
367 static ThrowExpression throwExpression() => throwExpression2(null); 363 static ThrowExpression throwExpression() => throwExpression2(null);
368 static ThrowExpression throwExpression2(Expression expression) => new ThrowExp ression.full(TokenFactory.token(Keyword.THROW), expression); 364 static ThrowExpression throwExpression2(Expression expression) => new ThrowExp ression.full(TokenFactory.token(Keyword.THROW), expression);
369 static TopLevelVariableDeclaration topLevelVariableDeclaration(Keyword keyword , TypeName type, List<VariableDeclaration> variables) => new TopLevelVariableDec laration.full(null, null, variableDeclarationList(keyword, type, variables), Tok enFactory.token3(TokenType.SEMICOLON)); 365 static TopLevelVariableDeclaration topLevelVariableDeclaration(Keyword keyword , TypeName type, List<VariableDeclaration> variables) => new TopLevelVariableDec laration.full(null, null, variableDeclarationList(keyword, type, variables), Tok enFactory.token3(TokenType.SEMICOLON));
370 static TopLevelVariableDeclaration topLevelVariableDeclaration2(Keyword keywor d, List<VariableDeclaration> variables) => new TopLevelVariableDeclaration.full( null, null, variableDeclarationList(keyword, null, variables), TokenFactory.toke n3(TokenType.SEMICOLON)); 366 static TopLevelVariableDeclaration topLevelVariableDeclaration2(Keyword keywor d, List<VariableDeclaration> variables) => new TopLevelVariableDeclaration.full( null, null, variableDeclarationList(keyword, null, variables), TokenFactory.toke n3(TokenType.SEMICOLON));
371 static TryStatement tryStatement(Block body, Block finallyClause) => tryStatem ent3(body, new List<CatchClause>(), finallyClause); 367 static TryStatement tryStatement(Block body, Block finallyClause) => tryStatem ent3(body, new List<CatchClause>(), finallyClause);
372 static TryStatement tryStatement2(Block body, List<CatchClause> catchClauses) => tryStatement3(body, list(catchClauses), null); 368 static TryStatement tryStatement2(Block body, List<CatchClause> catchClauses) => tryStatement3(body, list(catchClauses), null);
373 static TryStatement tryStatement3(Block body, List<CatchClause> catchClauses, Block finallyClause) => new TryStatement.full(TokenFactory.token(Keyword.TRY), b ody, catchClauses, finallyClause == null ? null : TokenFactory.token(Keyword.FIN ALLY), finallyClause); 369 static TryStatement tryStatement3(Block body, List<CatchClause> catchClauses, Block finallyClause) => new TryStatement.full(TokenFactory.token(Keyword.TRY), b ody, catchClauses, finallyClause == null ? null : TokenFactory.token(Keyword.FIN ALLY), finallyClause);
374 static FunctionTypeAlias typeAlias(TypeName returnType, String name, TypeParam eterList typeParameters, FormalParameterList parameters) => new FunctionTypeAlia s.full(null, null, TokenFactory.token(Keyword.TYPEDEF), returnType, identifier3( name), typeParameters, parameters, TokenFactory.token3(TokenType.SEMICOLON)); 370 static FunctionTypeAlias typeAlias(TypeName returnType, String name, TypeParam eterList typeParameters, FormalParameterList parameters) => new FunctionTypeAlia s.full(null, null, TokenFactory.token(Keyword.TYPEDEF), returnType, identifier3( name), typeParameters, parameters, TokenFactory.token3(TokenType.SEMICOLON));
375 static TypeArgumentList typeArgumentList(List<TypeName> typeNames) => new Type ArgumentList.full(TokenFactory.token3(TokenType.LT), list(typeNames), TokenFacto ry.token3(TokenType.GT)); 371 static TypeArgumentList typeArgumentList(List<TypeName> typeNames) => new Type ArgumentList.full(TokenFactory.token3(TokenType.LT), list(typeNames), TokenFacto ry.token3(TokenType.GT));
376 372
377 /** 373 /**
378 * Create a type name whose name has been resolved to the given element and wh ose type has been 374 * Create a type name whose name has been resolved to the given element and wh ose type has been
379 * resolved to the type of the given element. 375 * resolved to the type of the given element.
380 * <p> 376 * <p>
381 * <b>Note:</b> This method does not correctly handle class elements that have type parameters. 377 * <b>Note:</b> This method does not correctly handle class elements that have type parameters.
382 * @param element the element defining the type represented by the type name 378 * @param element the element defining the type represented by the type name
383 * @return the type name that was created 379 * @return the type name that was created
384 */ 380 */
385 static TypeName typeName(ClassElement element2, List<TypeName> arguments) { 381 static TypeName typeName(ClassElement element2, List<TypeName> arguments) {
386 SimpleIdentifier name2 = identifier3(element2.name); 382 SimpleIdentifier name2 = identifier3(element2.name);
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 ASTFactory.prefixExpression(TokenType.BANG, expression); 555 ASTFactory.prefixExpression(TokenType.BANG, expression);
560 } else if (assignment == AssignmentKind.SIMPLE_LEFT) { 556 } else if (assignment == AssignmentKind.SIMPLE_LEFT) {
561 ASTFactory.assignmentExpression(expression, TokenType.EQ, ASTFactory.ide ntifier3("_")); 557 ASTFactory.assignmentExpression(expression, TokenType.EQ, ASTFactory.ide ntifier3("_"));
562 } else if (assignment == AssignmentKind.SIMPLE_RIGHT) { 558 } else if (assignment == AssignmentKind.SIMPLE_RIGHT) {
563 ASTFactory.assignmentExpression(ASTFactory.identifier3("_"), TokenType.E Q, expression); 559 ASTFactory.assignmentExpression(ASTFactory.identifier3("_"), TokenType.E Q, expression);
564 } 560 }
565 break; 561 break;
566 } 562 }
567 return identifier; 563 return identifier;
568 } 564 }
569 565
570 /** 566 /**
571 * Return the top-most node in the AST structure containing the given identifi er. 567 * Return the top-most node in the AST structure containing the given identifi er.
572 * @param identifier the identifier in the AST structure being traversed 568 * @param identifier the identifier in the AST structure being traversed
573 * @return the root of the AST structure containing the identifier 569 * @return the root of the AST structure containing the identifier
574 */ 570 */
575 ASTNode topMostNode(SimpleIdentifier identifier) { 571 ASTNode topMostNode(SimpleIdentifier identifier) {
576 ASTNode child = identifier; 572 ASTNode child = identifier;
577 ASTNode parent2 = identifier.parent; 573 ASTNode parent2 = identifier.parent;
578 while (parent2 != null) { 574 while (parent2 != null) {
579 child = parent2; 575 child = parent2;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 static final AssignmentKind COMPOUND_LEFT = new AssignmentKind('COMPOUND_LEFT' , 1); 663 static final AssignmentKind COMPOUND_LEFT = new AssignmentKind('COMPOUND_LEFT' , 1);
668 static final AssignmentKind COMPOUND_RIGHT = new AssignmentKind('COMPOUND_RIGH T', 2); 664 static final AssignmentKind COMPOUND_RIGHT = new AssignmentKind('COMPOUND_RIGH T', 2);
669 static final AssignmentKind POSTFIX_INC = new AssignmentKind('POSTFIX_INC', 3) ; 665 static final AssignmentKind POSTFIX_INC = new AssignmentKind('POSTFIX_INC', 3) ;
670 static final AssignmentKind PREFIX_DEC = new AssignmentKind('PREFIX_DEC', 4); 666 static final AssignmentKind PREFIX_DEC = new AssignmentKind('PREFIX_DEC', 4);
671 static final AssignmentKind PREFIX_INC = new AssignmentKind('PREFIX_INC', 5); 667 static final AssignmentKind PREFIX_INC = new AssignmentKind('PREFIX_INC', 5);
672 static final AssignmentKind PREFIX_NOT = new AssignmentKind('PREFIX_NOT', 6); 668 static final AssignmentKind PREFIX_NOT = new AssignmentKind('PREFIX_NOT', 6);
673 static final AssignmentKind SIMPLE_LEFT = new AssignmentKind('SIMPLE_LEFT', 7) ; 669 static final AssignmentKind SIMPLE_LEFT = new AssignmentKind('SIMPLE_LEFT', 7) ;
674 static final AssignmentKind SIMPLE_RIGHT = new AssignmentKind('SIMPLE_RIGHT', 8); 670 static final AssignmentKind SIMPLE_RIGHT = new AssignmentKind('SIMPLE_RIGHT', 8);
675 static final AssignmentKind NONE = new AssignmentKind('NONE', 9); 671 static final AssignmentKind NONE = new AssignmentKind('NONE', 9);
676 static final List<AssignmentKind> values = [BINARY, COMPOUND_LEFT, COMPOUND_RI GHT, POSTFIX_INC, PREFIX_DEC, PREFIX_INC, PREFIX_NOT, SIMPLE_LEFT, SIMPLE_RIGHT, NONE]; 672 static final List<AssignmentKind> values = [BINARY, COMPOUND_LEFT, COMPOUND_RI GHT, POSTFIX_INC, PREFIX_DEC, PREFIX_INC, PREFIX_NOT, SIMPLE_LEFT, SIMPLE_RIGHT, NONE];
677 673
678 /// The name of this enum constant, as declared in the enum declaration. 674 /// The name of this enum constant, as declared in the enum declaration.
679 final String name; 675 final String name;
680 676
681 /// The position in the enum declaration. 677 /// The position in the enum declaration.
682 final int ordinal; 678 final int ordinal;
683 AssignmentKind(this.name, this.ordinal) { 679 AssignmentKind(this.name, this.ordinal) {
684 } 680 }
685 int compareTo(AssignmentKind other) => ordinal - other.ordinal; 681 int compareTo(AssignmentKind other) => ordinal - other.ordinal;
686 String toString() => name; 682 String toString() => name;
687 } 683 }
688 class WrapperKind implements Comparable<WrapperKind> { 684 class WrapperKind implements Comparable<WrapperKind> {
689 static final WrapperKind PREFIXED_LEFT = new WrapperKind('PREFIXED_LEFT', 0); 685 static final WrapperKind PREFIXED_LEFT = new WrapperKind('PREFIXED_LEFT', 0);
690 static final WrapperKind PREFIXED_RIGHT = new WrapperKind('PREFIXED_RIGHT', 1) ; 686 static final WrapperKind PREFIXED_RIGHT = new WrapperKind('PREFIXED_RIGHT', 1) ;
691 static final WrapperKind PROPERTY_LEFT = new WrapperKind('PROPERTY_LEFT', 2); 687 static final WrapperKind PROPERTY_LEFT = new WrapperKind('PROPERTY_LEFT', 2);
692 static final WrapperKind PROPERTY_RIGHT = new WrapperKind('PROPERTY_RIGHT', 3) ; 688 static final WrapperKind PROPERTY_RIGHT = new WrapperKind('PROPERTY_RIGHT', 3) ;
693 static final WrapperKind NONE = new WrapperKind('NONE', 4); 689 static final WrapperKind NONE = new WrapperKind('NONE', 4);
694 static final List<WrapperKind> values = [PREFIXED_LEFT, PREFIXED_RIGHT, PROPER TY_LEFT, PROPERTY_RIGHT, NONE]; 690 static final List<WrapperKind> values = [PREFIXED_LEFT, PREFIXED_RIGHT, PROPER TY_LEFT, PROPERTY_RIGHT, NONE];
695 691
696 /// The name of this enum constant, as declared in the enum declaration. 692 /// The name of this enum constant, as declared in the enum declaration.
697 final String name; 693 final String name;
698 694
699 /// The position in the enum declaration. 695 /// The position in the enum declaration.
700 final int ordinal; 696 final int ordinal;
701 WrapperKind(this.name, this.ordinal) { 697 WrapperKind(this.name, this.ordinal) {
702 } 698 }
703 int compareTo(WrapperKind other) => ordinal - other.ordinal; 699 int compareTo(WrapperKind other) => ordinal - other.ordinal;
704 String toString() => name; 700 String toString() => name;
705 } 701 }
706 class BreadthFirstVisitorTest extends ParserTestCase { 702 class BreadthFirstVisitorTest extends ParserTestCase {
707 void testIt() { 703 void testIt() {
708 String source = EngineTestCase.createSource(["class A {", " bool get g => t rue;", "}", "class B {", " int f() {", " num q() {", " return 3;", " }", " return q() + 4;", " }", "}", "A f(var p) {", " if ((p as A).g) {", " return p;", " } else {", " return null;", " }", "}"]); 704 String source = EngineTestCase.createSource(["class A {", " bool get g => t rue;", "}", "class B {", " int f() {", " num q() {", " return 3;", " }", " return q() + 4;", " }", "}", "A f(var p) {", " if ((p as A).g) {", " return p;", " } else {", " return null;", " }", "}"]);
(...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1914 } 1910 }
1915 void test_visitWhileStatement() { 1911 void test_visitWhileStatement() {
1916 assertSource("while (c) {}", ASTFactory.whileStatement(ASTFactory.identifier 3("c"), ASTFactory.block([]))); 1912 assertSource("while (c) {}", ASTFactory.whileStatement(ASTFactory.identifier 3("c"), ASTFactory.block([])));
1917 } 1913 }
1918 void test_visitWithClause_multiple() { 1914 void test_visitWithClause_multiple() {
1919 assertSource("with A, B, C", ASTFactory.withClause([ASTFactory.typeName4("A" , []), ASTFactory.typeName4("B", []), ASTFactory.typeName4("C", [])])); 1915 assertSource("with A, B, C", ASTFactory.withClause([ASTFactory.typeName4("A" , []), ASTFactory.typeName4("B", []), ASTFactory.typeName4("C", [])]));
1920 } 1916 }
1921 void test_visitWithClause_single() { 1917 void test_visitWithClause_single() {
1922 assertSource("with A", ASTFactory.withClause([ASTFactory.typeName4("A", [])] )); 1918 assertSource("with A", ASTFactory.withClause([ASTFactory.typeName4("A", [])] ));
1923 } 1919 }
1924 1920
1925 /** 1921 /**
1926 * Assert that a {@code ToSourceVisitor} will produce the expected source when visiting the given 1922 * Assert that a {@code ToSourceVisitor} will produce the expected source when visiting the given
1927 * node. 1923 * node.
1928 * @param expectedSource the source string that the visitor is expected to pro duce 1924 * @param expectedSource the source string that the visitor is expected to pro duce
1929 * @param node the AST node being visited to produce the actual source 1925 * @param node the AST node being visited to produce the actual source
1930 * @throws AFE if the visitor does not produce the expected source for the giv en node 1926 * @throws AFE if the visitor does not produce the expected source for the giv en node
1931 */ 1927 */
1932 void assertSource(String expectedSource, ASTNode node) { 1928 void assertSource(String expectedSource, ASTNode node) {
1933 PrintStringWriter writer = new PrintStringWriter(); 1929 PrintStringWriter writer = new PrintStringWriter();
1934 node.accept(new ToSourceVisitor(writer)); 1930 node.accept(new ToSourceVisitor(writer));
(...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after
2908 } 2904 }
2909 } 2905 }
2910 main() { 2906 main() {
2911 ConstantEvaluatorTest.dartSuite(); 2907 ConstantEvaluatorTest.dartSuite();
2912 NodeLocatorTest.dartSuite(); 2908 NodeLocatorTest.dartSuite();
2913 ToSourceVisitorTest.dartSuite(); 2909 ToSourceVisitorTest.dartSuite();
2914 BreadthFirstVisitorTest.dartSuite(); 2910 BreadthFirstVisitorTest.dartSuite();
2915 IndexExpressionTest.dartSuite(); 2911 IndexExpressionTest.dartSuite();
2916 SimpleIdentifierTest.dartSuite(); 2912 SimpleIdentifierTest.dartSuite();
2917 } 2913 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698