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

Side by Side Diff: pkg/analyzer/lib/src/generated/parser.dart

Issue 759183002: Fix incremental parsing of import combinators. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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 | « no previous file | pkg/analyzer/test/generated/parser_test.dart » ('j') | 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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.parser; 8 library engine.parser;
9 9
10 import "dart:math" as math; 10 import "dart:math" as math;
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 'parseClassDeclaration_2': new MethodTrampoline( 254 'parseClassDeclaration_2': new MethodTrampoline(
255 2, 255 2,
256 (Parser target, arg0, arg1) => target._parseClassDeclaration(arg0, arg1)), 256 (Parser target, arg0, arg1) => target._parseClassDeclaration(arg0, arg1)),
257 'parseClassMembers_2': new MethodTrampoline( 257 'parseClassMembers_2': new MethodTrampoline(
258 2, 258 2,
259 (Parser target, arg0, arg1) => target._parseClassMembers(arg0, arg1)), 259 (Parser target, arg0, arg1) => target._parseClassMembers(arg0, arg1)),
260 'parseClassTypeAlias_3': new MethodTrampoline( 260 'parseClassTypeAlias_3': new MethodTrampoline(
261 3, 261 3,
262 (Parser target, arg0, arg1, arg2) => 262 (Parser target, arg0, arg1, arg2) =>
263 target._parseClassTypeAlias(arg0, arg1, arg2)), 263 target._parseClassTypeAlias(arg0, arg1, arg2)),
264 'parseCombinator_0': new MethodTrampoline(
265 0,
266 (Parser target) => target.parseCombinator()),
264 'parseCombinators_0': new MethodTrampoline( 267 'parseCombinators_0': new MethodTrampoline(
265 0, 268 0,
266 (Parser target) => target._parseCombinators()), 269 (Parser target) => target._parseCombinators()),
267 'parseCommentAndMetadata_0': new MethodTrampoline( 270 'parseCommentAndMetadata_0': new MethodTrampoline(
268 0, 271 0,
269 (Parser target) => target._parseCommentAndMetadata()), 272 (Parser target) => target._parseCommentAndMetadata()),
270 'parseCommentReference_2': new MethodTrampoline( 273 'parseCommentReference_2': new MethodTrampoline(
271 2, 274 2,
272 (Parser target, arg0, arg1) => target._parseCommentReference(arg0, arg1)), 275 (Parser target, arg0, arg1) => target._parseCommentReference(arg0, arg1)),
273 'parseCommentReferences_1': new MethodTrampoline( 276 'parseCommentReferences_1': new MethodTrampoline(
(...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after
1239 AstNode visitImportDirective(ImportDirective node) { 1242 AstNode visitImportDirective(ImportDirective node) {
1240 if (identical(_oldNode, node.documentationComment)) { 1243 if (identical(_oldNode, node.documentationComment)) {
1241 throw new InsufficientContextException(); 1244 throw new InsufficientContextException();
1242 } else if (node.metadata.contains(_oldNode)) { 1245 } else if (node.metadata.contains(_oldNode)) {
1243 return _parser.parseAnnotation(); 1246 return _parser.parseAnnotation();
1244 } else if (identical(_oldNode, node.uri)) { 1247 } else if (identical(_oldNode, node.uri)) {
1245 return _parser.parseStringLiteral(); 1248 return _parser.parseStringLiteral();
1246 } else if (identical(_oldNode, node.prefix)) { 1249 } else if (identical(_oldNode, node.prefix)) {
1247 return _parser.parseSimpleIdentifier(); 1250 return _parser.parseSimpleIdentifier();
1248 } else if (node.combinators.contains(_oldNode)) { 1251 } else if (node.combinators.contains(_oldNode)) {
1249 throw new IncrementalParseException(); 1252 return _parser.parseCombinator();
Brian Wilkerson 2014/11/26 14:44:38 Does this handle the case where one combinator is
Paul Berry 2014/11/26 16:08:38 Yes, it works correctly. Note: I'm assuming you m
1250 //return parser.parseCombinator();
1251 } 1253 }
1252 return _notAChild(node); 1254 return _notAChild(node);
1253 } 1255 }
1254 1256
1255 @override 1257 @override
1256 AstNode visitIndexExpression(IndexExpression node) { 1258 AstNode visitIndexExpression(IndexExpression node) {
1257 if (identical(_oldNode, node.target)) { 1259 if (identical(_oldNode, node.target)) {
1258 throw new InsufficientContextException(); 1260 throw new InsufficientContextException();
1259 } else if (identical(_oldNode, node.index)) { 1261 } else if (identical(_oldNode, node.index)) {
1260 return _parser.parseExpression2(); 1262 return _parser.parseExpression2();
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
1927 new IncrementalParseDispatcher(parser, oldNode); 1929 new IncrementalParseDispatcher(parser, oldNode);
1928 IncrementalParseStateBuilder contextBuilder = 1930 IncrementalParseStateBuilder contextBuilder =
1929 new IncrementalParseStateBuilder(parser); 1931 new IncrementalParseStateBuilder(parser);
1930 contextBuilder.buildState(oldNode); 1932 contextBuilder.buildState(oldNode);
1931 newNode = parent.accept(dispatcher); 1933 newNode = parent.accept(dispatcher);
1932 // 1934 //
1933 // Validate that the new node can replace the old node. 1935 // Validate that the new node can replace the old node.
1934 // 1936 //
1935 Token mappedToken = _tokenMap.get(oldNode.endToken.next); 1937 Token mappedToken = _tokenMap.get(oldNode.endToken.next);
1936 if (mappedToken == null || 1938 if (mappedToken == null ||
1939 newNode == null ||
1937 mappedToken.offset != newNode.endToken.next.offset || 1940 mappedToken.offset != newNode.endToken.next.offset ||
1938 newNode.offset != oldNode.offset) { 1941 newNode.offset != oldNode.offset) {
1939 advanceToParent = true; 1942 advanceToParent = true;
1940 } 1943 }
1941 } on InsufficientContextException catch (exception) { 1944 } on InsufficientContextException catch (exception) {
1942 advanceToParent = true; 1945 advanceToParent = true;
1943 } catch (exception) { 1946 } catch (exception) {
1944 return null; 1947 return null;
1945 } 1948 }
1946 if (advanceToParent) { 1949 if (advanceToParent) {
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after
2879 type); 2882 type);
2880 } 2883 }
2881 return _parseInitializedIdentifierList( 2884 return _parseInitializedIdentifierList(
2882 commentAndMetadata, 2885 commentAndMetadata,
2883 modifiers.staticKeyword, 2886 modifiers.staticKeyword,
2884 _validateModifiersForField(modifiers), 2887 _validateModifiersForField(modifiers),
2885 type); 2888 type);
2886 } 2889 }
2887 2890
2888 /** 2891 /**
2892 * Parse a single import combinator. If no combinator is found, return
2893 * `null`.
2894 *
2895 * <pre>
2896 * combinator ::=
2897 * 'show' identifier (',' identifier)*
2898 * | 'hide' identifier (',' identifier)*
2899 * </pre>
2900 */
2901 Combinator parseCombinator() {
2902 if (_matchesString(_SHOW) || _matchesString(_HIDE)) {
2903 Token keyword = andAdvance;
2904 List<SimpleIdentifier> names = _parseIdentifierList();
2905 if (keyword.lexeme == _SHOW) {
2906 return new ShowCombinator(keyword, names);
2907 } else {
2908 return new HideCombinator(keyword, names);
2909 }
2910 }
2911 return null;
2912 }
2913
2914 /**
2889 * Parse a compilation unit, starting with the given token. 2915 * Parse a compilation unit, starting with the given token.
2890 * 2916 *
2891 * @param token the first token of the compilation unit 2917 * @param token the first token of the compilation unit
2892 * @return the compilation unit that was parsed 2918 * @return the compilation unit that was parsed
2893 */ 2919 */
2894 CompilationUnit parseCompilationUnit(Token token) { 2920 CompilationUnit parseCompilationUnit(Token token) {
2895 InstrumentationBuilder instrumentation = 2921 InstrumentationBuilder instrumentation =
2896 Instrumentation.builder2("dart.engine.Parser.parseCompilationUnit"); 2922 Instrumentation.builder2("dart.engine.Parser.parseCompilationUnit");
2897 try { 2923 try {
2898 _currentToken = token; 2924 _currentToken = token;
(...skipping 2400 matching lines...) Expand 10 before | Expand all | Expand 10 after
5299 * <pre> 5325 * <pre>
5300 * combinator ::= 5326 * combinator ::=
5301 * 'show' identifier (',' identifier)* 5327 * 'show' identifier (',' identifier)*
5302 * | 'hide' identifier (',' identifier)* 5328 * | 'hide' identifier (',' identifier)*
5303 * </pre> 5329 * </pre>
5304 * 5330 *
5305 * @return the combinators that were parsed 5331 * @return the combinators that were parsed
5306 */ 5332 */
5307 List<Combinator> _parseCombinators() { 5333 List<Combinator> _parseCombinators() {
5308 List<Combinator> combinators = new List<Combinator>(); 5334 List<Combinator> combinators = new List<Combinator>();
5309 while (_matchesString(_SHOW) || _matchesString(_HIDE)) { 5335 while (true) {
5310 Token keyword = _expect(TokenType.IDENTIFIER); 5336 Combinator combinator = parseCombinator();
5311 if (keyword.lexeme == _SHOW) { 5337 if (combinator == null) {
5312 List<SimpleIdentifier> shownNames = _parseIdentifierList(); 5338 break;
5313 combinators.add(new ShowCombinator(keyword, shownNames));
5314 } else {
5315 List<SimpleIdentifier> hiddenNames = _parseIdentifierList();
5316 combinators.add(new HideCombinator(keyword, hiddenNames));
5317 } 5339 }
5340 combinators.add(combinator);
5318 } 5341 }
5319 return combinators; 5342 return combinators;
5320 } 5343 }
5321 5344
5322 /** 5345 /**
5323 * Parse the documentation comment and metadata preceding a declaration. This method allows any 5346 * Parse the documentation comment and metadata preceding a declaration. This method allows any
5324 * number of documentation comments to occur before, after or between the meta data, but only 5347 * number of documentation comments to occur before, after or between the meta data, but only
5325 * returns the last (right-most) documentation comment that is found. 5348 * returns the last (right-most) documentation comment that is found.
5326 * 5349 *
5327 * <pre> 5350 * <pre>
(...skipping 6690 matching lines...) Expand 10 before | Expand all | Expand 10 after
12018 * Copy resolution data from one node to another. 12041 * Copy resolution data from one node to another.
12019 * 12042 *
12020 * @param fromNode the node from which resolution information will be copied 12043 * @param fromNode the node from which resolution information will be copied
12021 * @param toNode the node to which resolution information will be copied 12044 * @param toNode the node to which resolution information will be copied
12022 */ 12045 */
12023 static void copyResolutionData(AstNode fromNode, AstNode toNode) { 12046 static void copyResolutionData(AstNode fromNode, AstNode toNode) {
12024 ResolutionCopier copier = new ResolutionCopier(); 12047 ResolutionCopier copier = new ResolutionCopier();
12025 copier._isEqualNodes(fromNode, toNode); 12048 copier._isEqualNodes(fromNode, toNode);
12026 } 12049 }
12027 } 12050 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/parser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698