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

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

Issue 2435013003: Teach analyzer parser to handle native const factories/const constructors. (Closed)
Patch Set: add a test 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
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/non_error_resolver_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 library analyzer.src.generated.parser; 5 library analyzer.src.generated.parser;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import "dart:math" as math; 8 import "dart:math" as math;
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 6234 matching lines...) Expand 10 before | Expand all | Expand 10 after
6245 if (factoryKeyword == null) { 6245 if (factoryKeyword == null) {
6246 _reportErrorForNode( 6246 _reportErrorForNode(
6247 ParserErrorCode.REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR, 6247 ParserErrorCode.REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR,
6248 redirectedConstructor); 6248 redirectedConstructor);
6249 } 6249 }
6250 } else { 6250 } else {
6251 body = 6251 body =
6252 parseFunctionBody(true, ParserErrorCode.MISSING_FUNCTION_BODY, false); 6252 parseFunctionBody(true, ParserErrorCode.MISSING_FUNCTION_BODY, false);
6253 if (constKeyword != null && 6253 if (constKeyword != null &&
6254 factoryKeyword != null && 6254 factoryKeyword != null &&
6255 externalKeyword == null) { 6255 externalKeyword == null &&
6256 body is! NativeFunctionBody) {
6256 _reportErrorForToken(ParserErrorCode.CONST_FACTORY, factoryKeyword); 6257 _reportErrorForToken(ParserErrorCode.CONST_FACTORY, factoryKeyword);
6257 } else if (body is EmptyFunctionBody) { 6258 } else if (body is EmptyFunctionBody) {
6258 if (factoryKeyword != null && 6259 if (factoryKeyword != null &&
6259 externalKeyword == null && 6260 externalKeyword == null &&
6260 _parseFunctionBodies) { 6261 _parseFunctionBodies) {
6261 _reportErrorForToken( 6262 _reportErrorForToken(
6262 ParserErrorCode.FACTORY_WITHOUT_BODY, factoryKeyword); 6263 ParserErrorCode.FACTORY_WITHOUT_BODY, factoryKeyword);
6263 } 6264 }
6264 } else { 6265 } else {
6265 if (constKeyword != null) { 6266 if (constKeyword != null && body is! NativeFunctionBody) {
6266 _reportErrorForNode( 6267 _reportErrorForNode(
6267 ParserErrorCode.CONST_CONSTRUCTOR_WITH_BODY, body); 6268 ParserErrorCode.CONST_CONSTRUCTOR_WITH_BODY, body);
6268 } else if (externalKeyword != null) { 6269 } else if (externalKeyword != null) {
6269 _reportErrorForNode( 6270 _reportErrorForNode(
6270 ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY, body); 6271 ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY, body);
6271 } else if (!bodyAllowed) { 6272 } else if (!bodyAllowed) {
6272 _reportErrorForNode( 6273 _reportErrorForNode(
6273 ParserErrorCode.REDIRECTING_CONSTRUCTOR_WITH_BODY, body); 6274 ParserErrorCode.REDIRECTING_CONSTRUCTOR_WITH_BODY, body);
6274 } 6275 }
6275 } 6276 }
(...skipping 1823 matching lines...) Expand 10 before | Expand all | Expand 10 after
8099 */ 8100 */
8100 Parser_SyntheticKeywordToken(Keyword keyword, int offset) 8101 Parser_SyntheticKeywordToken(Keyword keyword, int offset)
8101 : super(keyword, offset); 8102 : super(keyword, offset);
8102 8103
8103 @override 8104 @override
8104 int get length => 0; 8105 int get length => 0;
8105 8106
8106 @override 8107 @override
8107 Token copy() => new Parser_SyntheticKeywordToken(keyword, offset); 8108 Token copy() => new Parser_SyntheticKeywordToken(keyword, offset);
8108 } 8109 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/non_error_resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698