| 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/error.dart'; | 9 import 'package:analyzer/src/generated/error.dart'; |
| 10 import 'package:analyzer/src/generated/incremental_scanner.dart'; | 10 import 'package:analyzer/src/generated/incremental_scanner.dart'; |
| (...skipping 3006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3017 } | 3017 } |
| 3018 | 3018 |
| 3019 /** | 3019 /** |
| 3020 * Create a parser. | 3020 * Create a parser. |
| 3021 * | 3021 * |
| 3022 * @param listener the listener to be passed to the parser | 3022 * @param listener the listener to be passed to the parser |
| 3023 * @return the parser that was created | 3023 * @return the parser that was created |
| 3024 */ | 3024 */ |
| 3025 static Parser createParser(GatheringErrorListener listener) { | 3025 static Parser createParser(GatheringErrorListener listener) { |
| 3026 Parser parser = new Parser(null, listener); | 3026 Parser parser = new Parser(null, listener); |
| 3027 parser.parseAsync = true; | |
| 3028 parser.parseDeferredLibraries = true; | 3027 parser.parseDeferredLibraries = true; |
| 3029 parser.parseEnum = true; | 3028 parser.parseEnum = true; |
| 3030 return parser; | 3029 return parser; |
| 3031 } | 3030 } |
| 3032 | 3031 |
| 3033 /** | 3032 /** |
| 3034 * Invoke a method in [Parser]. The method is assumed to have the given number
and type of | 3033 * Invoke a method in [Parser]. The method is assumed to have the given number
and type of |
| 3035 * parameters and will be invoked with the given arguments. | 3034 * parameters and will be invoked with the given arguments. |
| 3036 * | 3035 * |
| 3037 * The given source is scanned and the parser is initialized to start with the
first token in the | 3036 * The given source is scanned and the parser is initialized to start with the
first token in the |
| (...skipping 16 matching lines...) Expand all Loading... |
| 3054 Scanner scanner = | 3053 Scanner scanner = |
| 3055 new Scanner(null, new CharSequenceReader(source), listener); | 3054 new Scanner(null, new CharSequenceReader(source), listener); |
| 3056 Token tokenStream = scanner.tokenize(); | 3055 Token tokenStream = scanner.tokenize(); |
| 3057 listener.setLineInfo(new TestSource(), scanner.lineStarts); | 3056 listener.setLineInfo(new TestSource(), scanner.lineStarts); |
| 3058 // | 3057 // |
| 3059 // Parse the source. | 3058 // Parse the source. |
| 3060 // | 3059 // |
| 3061 Parser parser = createParser(listener); | 3060 Parser parser = createParser(listener); |
| 3062 parser.parseFunctionBodies = parseFunctionBodies; | 3061 parser.parseFunctionBodies = parseFunctionBodies; |
| 3063 parser.parseDeferredLibraries = true; | 3062 parser.parseDeferredLibraries = true; |
| 3064 parser.parseAsync = true; | |
| 3065 Object result = | 3063 Object result = |
| 3066 invokeParserMethodImpl(parser, methodName, objects, tokenStream); | 3064 invokeParserMethodImpl(parser, methodName, objects, tokenStream); |
| 3067 // | 3065 // |
| 3068 // Partially test the results. | 3066 // Partially test the results. |
| 3069 // | 3067 // |
| 3070 if (!listener.hasErrors) { | 3068 if (!listener.hasErrors) { |
| 3071 expect(result, isNotNull); | 3069 expect(result, isNotNull); |
| 3072 } | 3070 } |
| 3073 return result; | 3071 return result; |
| 3074 } | 3072 } |
| (...skipping 7912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10987 // Parse the source. | 10985 // Parse the source. |
| 10988 // | 10986 // |
| 10989 Parser parser = new Parser(null, listener); | 10987 Parser parser = new Parser(null, listener); |
| 10990 return invokeParserMethodImpl( | 10988 return invokeParserMethodImpl( |
| 10991 parser, | 10989 parser, |
| 10992 methodName, | 10990 methodName, |
| 10993 <Object>[tokenStream], | 10991 <Object>[tokenStream], |
| 10994 tokenStream) as Token; | 10992 tokenStream) as Token; |
| 10995 } | 10993 } |
| 10996 } | 10994 } |
| OLD | NEW |