OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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/dart/ast/visitor.dart'; | 8 import 'package:analyzer/dart/ast/visitor.dart'; |
9 import 'package:analyzer/error/error.dart'; | 9 import 'package:analyzer/error/error.dart'; |
10 import 'package:analyzer/error/listener.dart'; | 10 import 'package:analyzer/error/listener.dart'; |
(...skipping 10747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10758 List<CommentReference> references = parser.parseCommentReferences(tokens); | 10758 List<CommentReference> references = parser.parseCommentReferences(tokens); |
10759 expectNotNullIfNoErrors(references); | 10759 expectNotNullIfNoErrors(references); |
10760 listener.assertNoErrors(); | 10760 listener.assertNoErrors(); |
10761 expect(references, hasLength(1)); | 10761 expect(references, hasLength(1)); |
10762 CommentReference reference = references[0]; | 10762 CommentReference reference = references[0]; |
10763 expect(reference, isNotNull); | 10763 expect(reference, isNotNull); |
10764 expect(reference.identifier, isNotNull); | 10764 expect(reference.identifier, isNotNull); |
10765 expect(reference.offset, 15); | 10765 expect(reference.offset, 15); |
10766 } | 10766 } |
10767 | 10767 |
| 10768 void test_parseFunctionBody_skip_block() { |
| 10769 ParserTestCase.parseFunctionBodies = false; |
| 10770 createParser('{}'); |
| 10771 FunctionBody functionBody = parser.parseFunctionBody(false, null, false); |
| 10772 expectNotNullIfNoErrors(functionBody); |
| 10773 listener.assertNoErrors(); |
| 10774 expect(functionBody, new isInstanceOf<EmptyFunctionBody>()); |
| 10775 } |
| 10776 |
| 10777 void test_parseFunctionBody_skip_block_invalid() { |
| 10778 ParserTestCase.parseFunctionBodies = false; |
| 10779 createParser('{'); |
| 10780 FunctionBody functionBody = parser.parseFunctionBody(false, null, false); |
| 10781 expectNotNullIfNoErrors(functionBody); |
| 10782 listener.assertErrorsWithCodes([ |
| 10783 fe.Scanner.useFasta |
| 10784 ? ScannerErrorCode.EXPECTED_TOKEN |
| 10785 : ParserErrorCode.EXPECTED_TOKEN |
| 10786 ]); |
| 10787 expect(functionBody, new isInstanceOf<EmptyFunctionBody>()); |
| 10788 } |
| 10789 |
| 10790 void test_parseFunctionBody_skip_blocks() { |
| 10791 ParserTestCase.parseFunctionBodies = false; |
| 10792 createParser('{ {} }'); |
| 10793 FunctionBody functionBody = parser.parseFunctionBody(false, null, false); |
| 10794 expectNotNullIfNoErrors(functionBody); |
| 10795 listener.assertNoErrors(); |
| 10796 expect(functionBody, new isInstanceOf<EmptyFunctionBody>()); |
| 10797 } |
| 10798 |
| 10799 void test_parseFunctionBody_skip_expression() { |
| 10800 ParserTestCase.parseFunctionBodies = false; |
| 10801 createParser('=> y;'); |
| 10802 FunctionBody functionBody = parser.parseFunctionBody(false, null, false); |
| 10803 expectNotNullIfNoErrors(functionBody); |
| 10804 listener.assertNoErrors(); |
| 10805 expect(functionBody, new isInstanceOf<EmptyFunctionBody>()); |
| 10806 } |
| 10807 |
10768 void test_Parser() { | 10808 void test_Parser() { |
10769 expect(new Parser(null, null), isNotNull); | 10809 expect(new Parser(null, null), isNotNull); |
10770 } | 10810 } |
10771 | 10811 |
10772 void test_skipPrefixedIdentifier_invalid() { | 10812 void test_skipPrefixedIdentifier_invalid() { |
10773 createParser('+'); | 10813 createParser('+'); |
10774 Token following = parser.skipPrefixedIdentifier(parser.currentToken); | 10814 Token following = parser.skipPrefixedIdentifier(parser.currentToken); |
10775 expect(following, isNull); | 10815 expect(following, isNull); |
10776 } | 10816 } |
10777 | 10817 |
(...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11744 expect(body.keyword, isNotNull); | 11784 expect(body.keyword, isNotNull); |
11745 expect(body.keyword.lexeme, Parser.ASYNC); | 11785 expect(body.keyword.lexeme, Parser.ASYNC); |
11746 expect(body.functionDefinition, isNotNull); | 11786 expect(body.functionDefinition, isNotNull); |
11747 expect(body.expression, isNotNull); | 11787 expect(body.expression, isNotNull); |
11748 expect(body.semicolon, isNotNull); | 11788 expect(body.semicolon, isNotNull); |
11749 expect(body.isAsynchronous, isTrue); | 11789 expect(body.isAsynchronous, isTrue); |
11750 expect(body.isGenerator, isFalse); | 11790 expect(body.isGenerator, isFalse); |
11751 expect(body.isSynchronous, isFalse); | 11791 expect(body.isSynchronous, isFalse); |
11752 } | 11792 } |
11753 | 11793 |
11754 void test_parseFunctionBody_skip_block() { | |
11755 ParserTestCase.parseFunctionBodies = false; | |
11756 createParser('{}'); | |
11757 FunctionBody functionBody = parser.parseFunctionBody(false, null, false); | |
11758 expectNotNullIfNoErrors(functionBody); | |
11759 listener.assertNoErrors(); | |
11760 expect(functionBody, new isInstanceOf<EmptyFunctionBody>()); | |
11761 } | |
11762 | |
11763 void test_parseFunctionBody_skip_block_invalid() { | |
11764 ParserTestCase.parseFunctionBodies = false; | |
11765 createParser('{'); | |
11766 FunctionBody functionBody = parser.parseFunctionBody(false, null, false); | |
11767 expectNotNullIfNoErrors(functionBody); | |
11768 listener.assertErrorsWithCodes([ | |
11769 fe.Scanner.useFasta | |
11770 ? ScannerErrorCode.EXPECTED_TOKEN | |
11771 : ParserErrorCode.EXPECTED_TOKEN | |
11772 ]); | |
11773 expect(functionBody, new isInstanceOf<EmptyFunctionBody>()); | |
11774 } | |
11775 | |
11776 void test_parseFunctionBody_skip_blocks() { | |
11777 ParserTestCase.parseFunctionBodies = false; | |
11778 createParser('{ {} }'); | |
11779 FunctionBody functionBody = parser.parseFunctionBody(false, null, false); | |
11780 expectNotNullIfNoErrors(functionBody); | |
11781 listener.assertNoErrors(); | |
11782 expect(functionBody, new isInstanceOf<EmptyFunctionBody>()); | |
11783 } | |
11784 | |
11785 void test_parseFunctionBody_skip_expression() { | |
11786 ParserTestCase.parseFunctionBodies = false; | |
11787 createParser('=> y;'); | |
11788 FunctionBody functionBody = parser.parseFunctionBody(false, null, false); | |
11789 expectNotNullIfNoErrors(functionBody); | |
11790 listener.assertNoErrors(); | |
11791 expect(functionBody, new isInstanceOf<EmptyFunctionBody>()); | |
11792 } | |
11793 | |
11794 void test_parseIdentifierList_multiple() { | 11794 void test_parseIdentifierList_multiple() { |
11795 createParser('a, b, c'); | 11795 createParser('a, b, c'); |
11796 List<SimpleIdentifier> list = parser.parseIdentifierList(); | 11796 List<SimpleIdentifier> list = parser.parseIdentifierList(); |
11797 expectNotNullIfNoErrors(list); | 11797 expectNotNullIfNoErrors(list); |
11798 listener.assertNoErrors(); | 11798 listener.assertNoErrors(); |
11799 expect(list, hasLength(3)); | 11799 expect(list, hasLength(3)); |
11800 } | 11800 } |
11801 | 11801 |
11802 void test_parseIdentifierList_single() { | 11802 void test_parseIdentifierList_single() { |
11803 createParser('a'); | 11803 createParser('a'); |
(...skipping 3676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15480 expectCommentText(typeVariable.documentationComment, '/// Doc'); | 15480 expectCommentText(typeVariable.documentationComment, '/// Doc'); |
15481 } | 15481 } |
15482 | 15482 |
15483 /** | 15483 /** |
15484 * Assert that the given [name] is in declaration context. | 15484 * Assert that the given [name] is in declaration context. |
15485 */ | 15485 */ |
15486 void _assertIsDeclarationName(SimpleIdentifier name) { | 15486 void _assertIsDeclarationName(SimpleIdentifier name) { |
15487 expect(name.inDeclarationContext(), isTrue); | 15487 expect(name.inDeclarationContext(), isTrue); |
15488 } | 15488 } |
15489 } | 15489 } |
OLD | NEW |