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

Side by Side Diff: pkg/analyzer/test/generated/parser_test.dart

Issue 1068263002: improve parser recovery for import statements (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 5 years, 8 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
« no previous file with comments | « pkg/analyzer/lib/src/generated/parser.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 library engine.parser_test; 5 library engine.parser_test;
6 6
7 import 'package:analyzer/src/generated/ast.dart'; 7 import 'package:analyzer/src/generated/ast.dart';
8 import 'package:analyzer/src/generated/element.dart'; 8 import 'package:analyzer/src/generated/element.dart';
9 import 'package:analyzer/src/generated/engine.dart'; 9 import 'package:analyzer/src/generated/engine.dart';
10 import 'package:analyzer/src/generated/error.dart'; 10 import 'package:analyzer/src/generated/error.dart';
(...skipping 3251 matching lines...) Expand 10 before | Expand all | Expand 10 after
3262 NodeList<VariableDeclaration> vars = 3262 NodeList<VariableDeclaration> vars =
3263 (fieldDecl as FieldDeclaration).fields.variables; 3263 (fieldDecl as FieldDeclaration).fields.variables;
3264 expect(vars, hasLength(1)); 3264 expect(vars, hasLength(1));
3265 expect(vars[0].name.name, "v"); 3265 expect(vars[0].name.name, "v");
3266 } 3266 }
3267 3267
3268 void test_functionExpression_named() { 3268 void test_functionExpression_named() {
3269 parseExpression("m(f() => 0);", [ParserErrorCode.EXPECTED_TOKEN]); 3269 parseExpression("m(f() => 0);", [ParserErrorCode.EXPECTED_TOKEN]);
3270 } 3270 }
3271 3271
3272 void test_importDirectivePartial() { 3272 void test_importDirectivePartial_as() {
3273 CompilationUnit unit = ParserTestCase.parseCompilationUnit( 3273 CompilationUnit unit = ParserTestCase.parseCompilationUnit(
3274 "import 'b.dart' d as b;", 3274 "import 'b.dart' d as b;",
3275 [ParserErrorCode.UNEXPECTED_TOKEN]); 3275 [ParserErrorCode.UNEXPECTED_TOKEN]);
3276 ImportDirective importDirective = unit.childEntities.first; 3276 ImportDirective importDirective = unit.childEntities.first;
3277 expect(importDirective.asKeyword, isNotNull); 3277 expect(importDirective.asKeyword, isNotNull);
3278 expect(unit.directives, hasLength(1)); 3278 expect(unit.directives, hasLength(1));
3279 expect(unit.declarations, hasLength(0)); 3279 expect(unit.declarations, hasLength(0));
3280 } 3280 }
3281 3281
3282 void test_importDirectivePartial_show() {
3283 CompilationUnit unit = ParserTestCase.parseCompilationUnit(
3284 "import 'b.dart' d show foo;",
3285 [ParserErrorCode.UNEXPECTED_TOKEN]);
3286 ImportDirective importDirective = unit.childEntities.first;
3287 expect(importDirective.combinators, hasLength(1));
3288 expect(unit.directives, hasLength(1));
3289 expect(unit.declarations, hasLength(0));
3290 }
3291
3292 void test_importDirectivePartial_hide() {
3293 CompilationUnit unit = ParserTestCase.parseCompilationUnit(
3294 "import 'b.dart' d hide foo;",
3295 [ParserErrorCode.UNEXPECTED_TOKEN]);
3296 ImportDirective importDirective = unit.childEntities.first;
3297 expect(importDirective.combinators, hasLength(1));
3298 expect(unit.directives, hasLength(1));
3299 expect(unit.declarations, hasLength(0));
3300 }
3301
3282 void test_incomplete_conditionalExpression() { 3302 void test_incomplete_conditionalExpression() {
3283 parseExpression("x ? 0", [ 3303 parseExpression("x ? 0", [
3284 ParserErrorCode.EXPECTED_TOKEN, 3304 ParserErrorCode.EXPECTED_TOKEN,
3285 ParserErrorCode.MISSING_IDENTIFIER 3305 ParserErrorCode.MISSING_IDENTIFIER
3286 ]); 3306 ]);
3287 } 3307 }
3288 3308
3289 void test_incomplete_constructorInitializers_empty() { 3309 void test_incomplete_constructorInitializers_empty() {
3290 parse3("parseClassMember", ["C"], "C() : {}", 3310 parse3("parseClassMember", ["C"], "C() : {}",
3291 [ParserErrorCode.MISSING_INITIALIZER]); 3311 [ParserErrorCode.MISSING_INITIALIZER]);
(...skipping 6929 matching lines...) Expand 10 before | Expand all | Expand 10 after
10221 new Scanner(null, new CharSequenceReader(source), listener); 10241 new Scanner(null, new CharSequenceReader(source), listener);
10222 Token tokenStream = scanner.tokenize(); 10242 Token tokenStream = scanner.tokenize();
10223 // 10243 //
10224 // Parse the source. 10244 // Parse the source.
10225 // 10245 //
10226 Parser parser = new Parser(null, listener); 10246 Parser parser = new Parser(null, listener);
10227 return invokeParserMethodImpl( 10247 return invokeParserMethodImpl(
10228 parser, methodName, <Object>[tokenStream], tokenStream) as Token; 10248 parser, methodName, <Object>[tokenStream], tokenStream) as Token;
10229 } 10249 }
10230 } 10250 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/parser.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698