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

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

Issue 2439583003: Validate local resolution scope, and compute initial name scope. (Closed)
Patch Set: Created 4 years, 2 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
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 analyzer.test.generated.parser_test; 5 library analyzer.test.generated.parser_test;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/ast/token.dart'; 8 import 'package:analyzer/dart/ast/token.dart';
9 import 'package:analyzer/dart/ast/visitor.dart'; 9 import 'package:analyzer/dart/ast/visitor.dart';
10 import 'package:analyzer/error/error.dart'; 10 import 'package:analyzer/error/error.dart';
11 import 'package:analyzer/error/listener.dart';
11 import 'package:analyzer/src/dart/ast/token.dart'; 12 import 'package:analyzer/src/dart/ast/token.dart';
12 import 'package:analyzer/src/dart/scanner/reader.dart'; 13 import 'package:analyzer/src/dart/scanner/reader.dart';
13 import 'package:analyzer/src/dart/scanner/scanner.dart'; 14 import 'package:analyzer/src/dart/scanner/scanner.dart';
14 import 'package:analyzer/src/generated/parser.dart'; 15 import 'package:analyzer/src/generated/parser.dart';
16 import 'package:analyzer/src/generated/source.dart';
15 import 'package:analyzer/src/generated/testing/ast_factory.dart'; 17 import 'package:analyzer/src/generated/testing/ast_factory.dart';
16 import 'package:analyzer/src/generated/testing/token_factory.dart'; 18 import 'package:analyzer/src/generated/testing/token_factory.dart';
17 import 'package:analyzer/src/generated/utilities_dart.dart'; 19 import 'package:analyzer/src/generated/utilities_dart.dart';
18 import 'package:test/test.dart'; 20 import 'package:test/test.dart';
19 import 'package:test_reflective_loader/test_reflective_loader.dart'; 21 import 'package:test_reflective_loader/test_reflective_loader.dart';
20 22
21 import 'test_support.dart'; 23 import 'test_support.dart';
22 24
23 main() { 25 main() {
24 defineReflectiveSuite(() { 26 defineReflectiveSuite(() {
(...skipping 2955 matching lines...) Expand 10 before | Expand all | Expand 10 after
2980 listener.setLineInfo(new TestSource(), scanner.lineStarts); 2982 listener.setLineInfo(new TestSource(), scanner.lineStarts);
2981 Token token = scanner.tokenize(); 2983 Token token = scanner.tokenize();
2982 Parser parser = new Parser(null, listener); 2984 Parser parser = new Parser(null, listener);
2983 CompilationUnit unit = parser.parseCompilationUnit(token); 2985 CompilationUnit unit = parser.parseCompilationUnit(token);
2984 expect(unit, isNotNull); 2986 expect(unit, isNotNull);
2985 listener.assertErrorsWithCodes(errorCodes); 2987 listener.assertErrorsWithCodes(errorCodes);
2986 return unit; 2988 return unit;
2987 } 2989 }
2988 2990
2989 /** 2991 /**
2992 * Parse the given [code] as a compilation unit.
2993 */
2994 static CompilationUnit parseCompilationUnit2(String code,
2995 {AnalysisErrorListener listener, bool parseGenericMethods: false}) {
2996 listener ??= AnalysisErrorListener.NULL_LISTENER;
2997 Scanner scanner = new Scanner(null, new CharSequenceReader(code), listener);
2998 Token token = scanner.tokenize();
2999 Parser parser = new Parser(null, listener);
3000 parser.parseGenericMethods = parseGenericMethods;
3001 CompilationUnit unit = parser.parseCompilationUnit(token);
3002 unit.lineInfo = new LineInfo(scanner.lineStarts);
3003 return unit;
3004 }
3005
3006 /**
2990 * Parse the given [source] as a statement. The [errorCodes] are the error 3007 * Parse the given [source] as a statement. The [errorCodes] are the error
2991 * codes of the errors that are expected to be found. If 3008 * codes of the errors that are expected to be found. If
2992 * [enableLazyAssignmentOperators] is `true`, then lazy assignment operators 3009 * [enableLazyAssignmentOperators] is `true`, then lazy assignment operators
2993 * should be enabled. 3010 * should be enabled.
2994 */ 3011 */
2995 static Statement parseStatement(String source, 3012 static Statement parseStatement(String source,
2996 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST, 3013 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST,
2997 bool enableLazyAssignmentOperators]) { 3014 bool enableLazyAssignmentOperators]) {
2998 GatheringErrorListener listener = new GatheringErrorListener(); 3015 GatheringErrorListener listener = new GatheringErrorListener();
2999 Scanner scanner = 3016 Scanner scanner =
(...skipping 10434 matching lines...) Expand 10 before | Expand all | Expand 10 after
13434 CompilationUnit _parseDirectives(String source, 13451 CompilationUnit _parseDirectives(String source,
13435 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) { 13452 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) {
13436 createParser(source); 13453 createParser(source);
13437 CompilationUnit unit = parser.parseDirectives2(); 13454 CompilationUnit unit = parser.parseDirectives2();
13438 expect(unit, isNotNull); 13455 expect(unit, isNotNull);
13439 expect(unit.declarations, hasLength(0)); 13456 expect(unit.declarations, hasLength(0));
13440 listener.assertErrorsWithCodes(errorCodes); 13457 listener.assertErrorsWithCodes(errorCodes);
13441 return unit; 13458 return unit;
13442 } 13459 }
13443 } 13460 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698