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 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/error.dart'; | 10 import 'package:analyzer/src/generated/error.dart'; |
10 import 'package:analyzer/src/generated/incremental_scanner.dart'; | 11 import 'package:analyzer/src/generated/incremental_scanner.dart'; |
11 import 'package:analyzer/src/generated/parser.dart'; | 12 import 'package:analyzer/src/generated/parser.dart'; |
12 import 'package:analyzer/src/generated/scanner.dart'; | 13 import 'package:analyzer/src/generated/scanner.dart'; |
13 import 'package:analyzer/src/generated/source.dart' show Source; | 14 import 'package:analyzer/src/generated/source.dart' show Source; |
14 import 'package:analyzer/src/generated/testing/ast_factory.dart'; | 15 import 'package:analyzer/src/generated/testing/ast_factory.dart'; |
15 import 'package:analyzer/src/generated/testing/element_factory.dart'; | 16 import 'package:analyzer/src/generated/testing/element_factory.dart'; |
16 import 'package:analyzer/src/generated/testing/token_factory.dart'; | 17 import 'package:analyzer/src/generated/testing/token_factory.dart'; |
17 import 'package:analyzer/src/generated/utilities_dart.dart'; | 18 import 'package:analyzer/src/generated/utilities_dart.dart'; |
18 import 'package:unittest/unittest.dart'; | 19 import 'package:unittest/unittest.dart'; |
(...skipping 2362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2381 Token modifiedTokens = modifiedScanner.tokenize(); | 2382 Token modifiedTokens = modifiedScanner.tokenize(); |
2382 expect(modifiedTokens, isNotNull); | 2383 expect(modifiedTokens, isNotNull); |
2383 Parser modifiedParser = new Parser(source, modifiedListener); | 2384 Parser modifiedParser = new Parser(source, modifiedListener); |
2384 CompilationUnit modifiedUnit = | 2385 CompilationUnit modifiedUnit = |
2385 modifiedParser.parseCompilationUnit(modifiedTokens); | 2386 modifiedParser.parseCompilationUnit(modifiedTokens); |
2386 expect(modifiedUnit, isNotNull); | 2387 expect(modifiedUnit, isNotNull); |
2387 // | 2388 // |
2388 // Incrementally parse the modified contents. | 2389 // Incrementally parse the modified contents. |
2389 // | 2390 // |
2390 GatheringErrorListener incrementalListener = new GatheringErrorListener(); | 2391 GatheringErrorListener incrementalListener = new GatheringErrorListener(); |
2391 IncrementalScanner incrementalScanner = new IncrementalScanner( | 2392 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); |
2392 source, new CharSequenceReader(modifiedContents), incrementalListener); | 2393 IncrementalScanner incrementalScanner = new IncrementalScanner(source, |
| 2394 new CharSequenceReader(modifiedContents), incrementalListener, options); |
2393 Token incrementalTokens = incrementalScanner.rescan( | 2395 Token incrementalTokens = incrementalScanner.rescan( |
2394 originalTokens, replaceStart, removed.length, added.length); | 2396 originalTokens, replaceStart, removed.length, added.length); |
2395 expect(incrementalTokens, isNotNull); | 2397 expect(incrementalTokens, isNotNull); |
2396 IncrementalParser incrementalParser = new IncrementalParser( | 2398 IncrementalParser incrementalParser = new IncrementalParser( |
2397 source, incrementalScanner.tokenMap, incrementalListener); | 2399 source, incrementalScanner.tokenMap, incrementalListener); |
2398 CompilationUnit incrementalUnit = incrementalParser.reparse(originalUnit, | 2400 CompilationUnit incrementalUnit = incrementalParser.reparse(originalUnit, |
2399 incrementalScanner.leftToken, incrementalScanner.rightToken, | 2401 incrementalScanner.leftToken, incrementalScanner.rightToken, |
2400 replaceStart, prefix.length + removed.length); | 2402 replaceStart, prefix.length + removed.length); |
2401 expect(incrementalUnit, isNotNull); | 2403 expect(incrementalUnit, isNotNull); |
2402 // | 2404 // |
(...skipping 4823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7226 parse4("parseFormalParameterList", "(io.File f)"); | 7228 parse4("parseFormalParameterList", "(io.File f)"); |
7227 expect(parameterList.leftParenthesis, isNotNull); | 7229 expect(parameterList.leftParenthesis, isNotNull); |
7228 expect(parameterList.leftDelimiter, isNull); | 7230 expect(parameterList.leftDelimiter, isNull); |
7229 expect(parameterList.parameters, hasLength(1)); | 7231 expect(parameterList.parameters, hasLength(1)); |
7230 expect(parameterList.parameters[0].toSource(), 'io.File f'); | 7232 expect(parameterList.parameters[0].toSource(), 'io.File f'); |
7231 expect(parameterList.rightDelimiter, isNull); | 7233 expect(parameterList.rightDelimiter, isNull); |
7232 expect(parameterList.rightParenthesis, isNotNull); | 7234 expect(parameterList.rightParenthesis, isNotNull); |
7233 } | 7235 } |
7234 | 7236 |
7235 void test_parseFormalParameterList_prefixedType_partial() { | 7237 void test_parseFormalParameterList_prefixedType_partial() { |
7236 FormalParameterList parameterList = | 7238 FormalParameterList parameterList = parse4("parseFormalParameterList", |
7237 parse4("parseFormalParameterList", "(io.)", [ | 7239 "(io.)", [ |
7238 ParserErrorCode.MISSING_IDENTIFIER, | 7240 ParserErrorCode.MISSING_IDENTIFIER, |
7239 ParserErrorCode.MISSING_IDENTIFIER]); | 7241 ParserErrorCode.MISSING_IDENTIFIER |
| 7242 ]); |
7240 expect(parameterList.leftParenthesis, isNotNull); | 7243 expect(parameterList.leftParenthesis, isNotNull); |
7241 expect(parameterList.leftDelimiter, isNull); | 7244 expect(parameterList.leftDelimiter, isNull); |
7242 expect(parameterList.parameters, hasLength(1)); | 7245 expect(parameterList.parameters, hasLength(1)); |
7243 expect(parameterList.parameters[0].toSource(), 'io. '); | 7246 expect(parameterList.parameters[0].toSource(), 'io. '); |
7244 expect(parameterList.rightDelimiter, isNull); | 7247 expect(parameterList.rightDelimiter, isNull); |
7245 expect(parameterList.rightParenthesis, isNotNull); | 7248 expect(parameterList.rightParenthesis, isNotNull); |
7246 } | 7249 } |
7247 | 7250 |
7248 void test_parseFormalParameterList_prefixedType_partial2() { | 7251 void test_parseFormalParameterList_prefixedType_partial2() { |
7249 FormalParameterList parameterList = | 7252 FormalParameterList parameterList = parse4("parseFormalParameterList", |
7250 parse4("parseFormalParameterList", "(io.,a)", [ | 7253 "(io.,a)", [ |
7251 ParserErrorCode.MISSING_IDENTIFIER, | 7254 ParserErrorCode.MISSING_IDENTIFIER, |
7252 ParserErrorCode.MISSING_IDENTIFIER]); | 7255 ParserErrorCode.MISSING_IDENTIFIER |
| 7256 ]); |
7253 expect(parameterList.leftParenthesis, isNotNull); | 7257 expect(parameterList.leftParenthesis, isNotNull); |
7254 expect(parameterList.leftDelimiter, isNull); | 7258 expect(parameterList.leftDelimiter, isNull); |
7255 expect(parameterList.parameters, hasLength(2)); | 7259 expect(parameterList.parameters, hasLength(2)); |
7256 expect(parameterList.parameters[0].toSource(), 'io. '); | 7260 expect(parameterList.parameters[0].toSource(), 'io. '); |
7257 expect(parameterList.parameters[1].toSource(), 'a'); | 7261 expect(parameterList.parameters[1].toSource(), 'a'); |
7258 expect(parameterList.rightDelimiter, isNull); | 7262 expect(parameterList.rightDelimiter, isNull); |
7259 expect(parameterList.rightParenthesis, isNotNull); | 7263 expect(parameterList.rightParenthesis, isNotNull); |
7260 } | 7264 } |
7261 | 7265 |
7262 void test_parseForStatement_each_await() { | 7266 void test_parseForStatement_each_await() { |
(...skipping 2753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10016 new Scanner(null, new CharSequenceReader(source), listener); | 10020 new Scanner(null, new CharSequenceReader(source), listener); |
10017 Token tokenStream = scanner.tokenize(); | 10021 Token tokenStream = scanner.tokenize(); |
10018 // | 10022 // |
10019 // Parse the source. | 10023 // Parse the source. |
10020 // | 10024 // |
10021 Parser parser = new Parser(null, listener); | 10025 Parser parser = new Parser(null, listener); |
10022 return invokeParserMethodImpl( | 10026 return invokeParserMethodImpl( |
10023 parser, methodName, <Object>[tokenStream], tokenStream) as Token; | 10027 parser, methodName, <Object>[tokenStream], tokenStream) as Token; |
10024 } | 10028 } |
10025 } | 10029 } |
OLD | NEW |