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

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

Issue 1062343002: improve parser recovery for import directives (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
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() {
Brian Wilkerson 2015/04/07 23:09:14 Seems more common cases would be both "import 'b
danrubel 2015/04/08 15:39:22 Good point. I'll add tests for those situations.
3273 CompilationUnit unit = ParserTestCase.parseCompilationUnit(
3274 "import 'b.dart' d as b;",
3275 [ParserErrorCode.UNEXPECTED_TOKEN]);
3276 ImportDirective importDirective = unit.childEntities.first;
3277 expect(importDirective.asKeyword, isNotNull);
3278 expect(unit.directives, hasLength(1));
3279 expect(unit.declarations, hasLength(0));
3280 }
3281
3272 void test_incomplete_conditionalExpression() { 3282 void test_incomplete_conditionalExpression() {
3273 parseExpression("x ? 0", [ 3283 parseExpression("x ? 0", [
3274 ParserErrorCode.EXPECTED_TOKEN, 3284 ParserErrorCode.EXPECTED_TOKEN,
3275 ParserErrorCode.MISSING_IDENTIFIER 3285 ParserErrorCode.MISSING_IDENTIFIER
3276 ]); 3286 ]);
3277 } 3287 }
3278 3288
3279 void test_incomplete_constructorInitializers_empty() { 3289 void test_incomplete_constructorInitializers_empty() {
3280 parse3("parseClassMember", ["C"], "C() : {}", 3290 parse3("parseClassMember", ["C"], "C() : {}",
3281 [ParserErrorCode.MISSING_INITIALIZER]); 3291 [ParserErrorCode.MISSING_INITIALIZER]);
(...skipping 6929 matching lines...) Expand 10 before | Expand all | Expand 10 after
10211 new Scanner(null, new CharSequenceReader(source), listener); 10221 new Scanner(null, new CharSequenceReader(source), listener);
10212 Token tokenStream = scanner.tokenize(); 10222 Token tokenStream = scanner.tokenize();
10213 // 10223 //
10214 // Parse the source. 10224 // Parse the source.
10215 // 10225 //
10216 Parser parser = new Parser(null, listener); 10226 Parser parser = new Parser(null, listener);
10217 return invokeParserMethodImpl( 10227 return invokeParserMethodImpl(
10218 parser, methodName, <Object>[tokenStream], tokenStream) as Token; 10228 parser, methodName, <Object>[tokenStream], tokenStream) as Token;
10219 } 10229 }
10220 } 10230 }
OLDNEW
« pkg/analyzer/lib/src/generated/parser.dart ('K') | « 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