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

Side by Side Diff: pkg/analyzer/lib/src/fasta/ast_builder.dart

Issue 3005973002: Fix and triage more tests (Closed)
Patch Set: address comments Created 3 years, 3 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/parser_fasta_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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 fasta.analyzer.ast_builder; 5 library fasta.analyzer.ast_builder;
6 6
7 import 'package:analyzer/analyzer.dart'; 7 import 'package:analyzer/analyzer.dart';
8 import 'package:analyzer/dart/ast/ast_factory.dart' show AstFactory; 8 import 'package:analyzer/dart/ast/ast_factory.dart' show AstFactory;
9 import 'package:analyzer/dart/ast/standard_ast_factory.dart' as standard; 9 import 'package:analyzer/dart/ast/standard_ast_factory.dart' as standard;
10 import 'package:analyzer/dart/ast/token.dart' show Token, TokenType; 10 import 'package:analyzer/dart/ast/token.dart' show Token, TokenType;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 /// in class, method, and function declarations. 64 /// in class, method, and function declarations.
65 /// 65 ///
66 /// This is being replaced by the @native(...) annotation. 66 /// This is being replaced by the @native(...) annotation.
67 // 67 //
68 // TODO(danrubel) Move this flag to a better location 68 // TODO(danrubel) Move this flag to a better location
69 // and should only be true if either: 69 // and should only be true if either:
70 // * The current library is a platform library 70 // * The current library is a platform library
71 // * The current library has an import that uses the scheme "dart-ext". 71 // * The current library has an import that uses the scheme "dart-ext".
72 bool allowNativeClause = false; 72 bool allowNativeClause = false;
73 73
74 /// A flag indicating whether an exception should be thrown when an error is
75 /// reported for which we have no mapping into an analyzer error.
76 //
77 // TODO(brianwilkerson) Remove this flag after failing tests have been triaged .
78 bool throwOnMissingErrorMapping = true;
79
74 AstBuilder(this.errorReporter, this.library, this.member, Scope scope, 80 AstBuilder(this.errorReporter, this.library, this.member, Scope scope,
75 this.isFullAst, 81 this.isFullAst,
76 [Uri uri]) 82 [Uri uri])
77 : uri = uri ?? library.fileUri, 83 : uri = uri ?? library.fileUri,
78 super(scope); 84 super(scope);
79 85
80 createJumpTarget(JumpTargetKind kind, int charOffset) { 86 createJumpTarget(JumpTargetKind kind, int charOffset) {
81 // TODO(ahe): Implement jump targets. 87 // TODO(ahe): Implement jump targets.
82 return null; 88 return null;
83 } 89 }
(...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 String lexeme = token.lexeme; 1080 String lexeme = token.lexeme;
1075 if (identical('async', lexeme) || identical('yield', lexeme)) { 1081 if (identical('async', lexeme) || identical('yield', lexeme)) {
1076 errorReporter?.reportErrorForOffset( 1082 errorReporter?.reportErrorForOffset(
1077 ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER, 1083 ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER,
1078 token.charOffset, 1084 token.charOffset,
1079 token.charCount); 1085 token.charCount);
1080 push(ast.simpleIdentifier(token)); 1086 push(ast.simpleIdentifier(token));
1081 return token; 1087 return token;
1082 } 1088 }
1083 } 1089 }
1084 return super.handleUnrecoverableError(token, message); 1090 if (throwOnMissingErrorMapping) {
1091 throw new UnimplementedError('Failed to map $message at $token');
1092 }
1085 } 1093 }
1086 1094
1087 void handleUnaryPrefixExpression(Token token) { 1095 void handleUnaryPrefixExpression(Token token) {
1088 debugEvent("UnaryPrefixExpression"); 1096 debugEvent("UnaryPrefixExpression");
1089 push(ast.prefixExpression(token, pop())); 1097 push(ast.prefixExpression(token, pop()));
1090 } 1098 }
1091 1099
1092 void handleUnaryPrefixAssignmentExpression(Token token) { 1100 void handleUnaryPrefixAssignmentExpression(Token token) {
1093 debugEvent("UnaryPrefixAssignmentExpression"); 1101 debugEvent("UnaryPrefixAssignmentExpression");
1094 push(ast.prefixExpression(token, pop())); 1102 push(ast.prefixExpression(token, pop()));
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after
1949 errorReporter?.reportErrorForOffset( 1957 errorReporter?.reportErrorForOffset(
1950 ParserErrorCode.EXPECTED_TOKEN, charOffset, text.length, [text]); 1958 ParserErrorCode.EXPECTED_TOKEN, charOffset, text.length, [text]);
1951 } else { 1959 } else {
1952 errorReporter?.reportErrorForOffset(ParserErrorCode.UNEXPECTED_TOKEN, 1960 errorReporter?.reportErrorForOffset(ParserErrorCode.UNEXPECTED_TOKEN,
1953 charOffset, text.length, [text]); 1961 charOffset, text.length, [text]);
1954 } 1962 }
1955 return; 1963 return;
1956 default: 1964 default:
1957 // fall through 1965 // fall through
1958 } 1966 }
1959 library.addCompileTimeError(message, charOffset, uri); 1967 if (throwOnMissingErrorMapping) {
1968 throw new UnimplementedError('Failed to map $message at $charOffset');
1969 }
1960 } 1970 }
1961 1971
1962 /// A marker method used to mark locations where a token is being located in 1972 /// A marker method used to mark locations where a token is being located in
1963 /// an unsafe way. In all such cases the parser needs to be fixed to pass in 1973 /// an unsafe way. In all such cases the parser needs to be fixed to pass in
1964 /// the token. 1974 /// the token.
1965 Token unsafeToken(Token token, TokenType tokenType) { 1975 Token unsafeToken(Token token, TokenType tokenType) {
1966 // TODO(brianwilkerson) Eliminate the need for this method. 1976 // TODO(brianwilkerson) Eliminate the need for this method.
1967 return token.type == tokenType ? token : null; 1977 return token.type == tokenType ? token : null;
1968 } 1978 }
1969 } 1979 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
2066 } else if (identical('var', s)) { 2076 } else if (identical('var', s)) {
2067 finalConstOrVarKeyword = token; 2077 finalConstOrVarKeyword = token;
2068 } else if (identical('covariant', s)) { 2078 } else if (identical('covariant', s)) {
2069 covariantKeyword = token; 2079 covariantKeyword = token;
2070 } else { 2080 } else {
2071 unhandled("$s", "modifier", token.charOffset, null); 2081 unhandled("$s", "modifier", token.charOffset, null);
2072 } 2082 }
2073 } 2083 }
2074 } 2084 }
2075 } 2085 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/parser_fasta_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698