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

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

Issue 2746013003: [fasta] Add and correct even more offsets (Closed)
Patch Set: Created 3 years, 9 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
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' as analyzer show Token; 10 import 'package:analyzer/dart/ast/token.dart' as analyzer show Token;
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 TypeAnnotation returnType = pop(); 614 TypeAnnotation returnType = pop();
615 push(ast.genericFunctionType(returnType, toAnalyzerToken(functionToken), 615 push(ast.genericFunctionType(returnType, toAnalyzerToken(functionToken),
616 typeParameters, parameters)); 616 typeParameters, parameters));
617 } 617 }
618 618
619 void handleFormalParameterWithoutValue(Token token) { 619 void handleFormalParameterWithoutValue(Token token) {
620 debugEvent("FormalParameterWithoutValue"); 620 debugEvent("FormalParameterWithoutValue");
621 push(NullValue.ParameterDefaultValue); 621 push(NullValue.ParameterDefaultValue);
622 } 622 }
623 623
624 void endFormalParameter( 624 void endFormalParameter(Token covariantKeyword, Token thisKeyword,
625 Token covariantKeyword, Token thisKeyword, FormalParameterType kind) { 625 Token nameToken, FormalParameterType kind) {
626 debugEvent("FormalParameter"); 626 debugEvent("FormalParameter");
627 _ParameterDefaultValue defaultValue = pop(); 627 _ParameterDefaultValue defaultValue = pop();
628 628
629 AstNode nameOrFunctionTypedParameter = pop(); 629 AstNode nameOrFunctionTypedParameter = pop();
630 630
631 FormalParameter node; 631 FormalParameter node;
632 SimpleIdentifier name; 632 SimpleIdentifier name;
633 if (nameOrFunctionTypedParameter is FormalParameter) { 633 if (nameOrFunctionTypedParameter is FormalParameter) {
634 node = nameOrFunctionTypedParameter; 634 node = nameOrFunctionTypedParameter;
635 name = nameOrFunctionTypedParameter.identifier; 635 name = nameOrFunctionTypedParameter.identifier;
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 840
841 void handleModifiers(int count) { 841 void handleModifiers(int count) {
842 debugEvent("Modifiers"); 842 debugEvent("Modifiers");
843 if (count == 0) { 843 if (count == 0) {
844 push(NullValue.Modifiers); 844 push(NullValue.Modifiers);
845 } else { 845 } else {
846 push(new _Modifiers(popList(count))); 846 push(new _Modifiers(popList(count)));
847 } 847 }
848 } 848 }
849 849
850 void endTopLevelMethod(Token beginToken, Token getOrSet, Token endToken) { 850 void endTopLevelMethod(Token beginToken, Token getOrSet,
851 Token formalParametersToken, Token endToken) {
851 // TODO(paulberry): set up scopes properly to resolve parameters and type 852 // TODO(paulberry): set up scopes properly to resolve parameters and type
852 // variables. 853 // variables.
853 debugEvent("TopLevelMethod"); 854 debugEvent("TopLevelMethod");
854 FunctionBody body = pop(); 855 FunctionBody body = pop();
855 FormalParameterList parameters = pop(); 856 FormalParameterList parameters = pop();
856 TypeParameterList typeParameters = pop(); 857 TypeParameterList typeParameters = pop();
857 SimpleIdentifier name = pop(); 858 SimpleIdentifier name = pop();
858 analyzer.Token propertyKeyword = toAnalyzerToken(getOrSet); 859 analyzer.Token propertyKeyword = toAnalyzerToken(getOrSet);
859 TypeAnnotation returnType = pop(); 860 TypeAnnotation returnType = pop();
860 _Modifiers modifiers = pop(); 861 _Modifiers modifiers = pop();
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 StringLiteral uri = null; // TODO(paulberry) 1158 StringLiteral uri = null; // TODO(paulberry)
1158 // TODO(paulberry,ahe): seems hacky. It would be nice if the parser passed 1159 // TODO(paulberry,ahe): seems hacky. It would be nice if the parser passed
1159 // in a reference to the "of" keyword. 1160 // in a reference to the "of" keyword.
1160 var ofKeyword = partKeyword.next; 1161 var ofKeyword = partKeyword.next;
1161 List<Annotation> metadata = pop(); 1162 List<Annotation> metadata = pop();
1162 Comment comment = pop(); 1163 Comment comment = pop();
1163 push(ast.partOfDirective(comment, metadata, toAnalyzerToken(partKeyword), 1164 push(ast.partOfDirective(comment, metadata, toAnalyzerToken(partKeyword),
1164 toAnalyzerToken(ofKeyword), uri, name, toAnalyzerToken(semicolon))); 1165 toAnalyzerToken(ofKeyword), uri, name, toAnalyzerToken(semicolon)));
1165 } 1166 }
1166 1167
1167 void endUnnamedFunction(Token token) { 1168 void endUnnamedFunction(Token beginToken, Token token) {
1168 // TODO(paulberry): set up scopes properly to resolve parameters and type 1169 // TODO(paulberry): set up scopes properly to resolve parameters and type
1169 // variables. Note that this is tricky due to the handling of initializers 1170 // variables. Note that this is tricky due to the handling of initializers
1170 // in constructors, so the logic should be shared with BodyBuilder as much 1171 // in constructors, so the logic should be shared with BodyBuilder as much
1171 // as possible. 1172 // as possible.
1172 debugEvent("UnnamedFunction"); 1173 debugEvent("UnnamedFunction");
1173 FunctionBody body = pop(); 1174 FunctionBody body = pop();
1174 FormalParameterList parameters = pop(); 1175 FormalParameterList parameters = pop();
1175 TypeParameterList typeParameters = pop(); 1176 TypeParameterList typeParameters = pop();
1176 push(ast.functionExpression(typeParameters, parameters, body)); 1177 push(ast.functionExpression(typeParameters, parameters, body));
1177 } 1178 }
1178 1179
1179 @override 1180 @override
1180 void handleNoFieldInitializer(Token token) { 1181 void handleNoFieldInitializer(Token token) {
1181 debugEvent("NoFieldInitializer"); 1182 debugEvent("NoFieldInitializer");
1182 SimpleIdentifier name = pop(); 1183 SimpleIdentifier name = pop();
1183 push(ast.variableDeclaration(name, null, null)); 1184 push(ast.variableDeclaration(name, null, null));
1184 } 1185 }
1185 1186
1186 @override 1187 @override
1187 void endFactoryMethod( 1188 void endFactoryMethod(Token beginToken, Token factoryKeyword,
1188 Token beginToken, Token factoryKeyword, Token semicolon) { 1189 Token formalParametersToken, Token semicolon) {
1189 debugEvent("FactoryMethod"); 1190 debugEvent("FactoryMethod");
1190 1191
1191 FunctionBody body; 1192 FunctionBody body;
1192 Token separator; 1193 Token separator;
1193 ConstructorName redirectedConstructor; 1194 ConstructorName redirectedConstructor;
1194 Object bodyObject = pop(); 1195 Object bodyObject = pop();
1195 if (bodyObject is FunctionBody) { 1196 if (bodyObject is FunctionBody) {
1196 body = bodyObject; 1197 body = bodyObject;
1197 } else if (bodyObject is _RedirectingFactoryBody) { 1198 } else if (bodyObject is _RedirectingFactoryBody) {
1198 separator = bodyObject.equalToken; 1199 separator = bodyObject.equalToken;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 1264
1264 @override 1265 @override
1265 void endTypeVariables(int count, Token beginToken, Token endToken) { 1266 void endTypeVariables(int count, Token beginToken, Token endToken) {
1266 debugEvent("TypeVariables"); 1267 debugEvent("TypeVariables");
1267 List<TypeParameter> typeParameters = popList(count); 1268 List<TypeParameter> typeParameters = popList(count);
1268 push(ast.typeParameterList(toAnalyzerToken(beginToken), typeParameters, 1269 push(ast.typeParameterList(toAnalyzerToken(beginToken), typeParameters,
1269 toAnalyzerToken(endToken))); 1270 toAnalyzerToken(endToken)));
1270 } 1271 }
1271 1272
1272 @override 1273 @override
1273 void endMethod(Token getOrSet, Token beginToken, Token endToken) { 1274 void endMethod(Token getOrSet, Token beginToken, Token formalParametersToken,
1275 Token endToken) {
1274 debugEvent("Method"); 1276 debugEvent("Method");
1275 FunctionBody body = pop(); 1277 FunctionBody body = pop();
1276 ConstructorName redirectedConstructor = null; // TODO(paulberry) 1278 ConstructorName redirectedConstructor = null; // TODO(paulberry)
1277 List<ConstructorInitializer> initializers = null; // TODO(paulberry) 1279 List<ConstructorInitializer> initializers = null; // TODO(paulberry)
1278 Token separator = null; // TODO(paulberry) 1280 Token separator = null; // TODO(paulberry)
1279 FormalParameterList parameters = pop(); 1281 FormalParameterList parameters = pop();
1280 TypeParameterList typeParameters = pop(); // TODO(paulberry) 1282 TypeParameterList typeParameters = pop(); // TODO(paulberry)
1281 var name = pop(); 1283 var name = pop();
1282 TypeAnnotation returnType = pop(); // TODO(paulberry) 1284 TypeAnnotation returnType = pop(); // TODO(paulberry)
1283 _Modifiers modifiers = pop(); 1285 _Modifiers modifiers = pop();
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
1575 } else if (identical('static', s)) { 1577 } else if (identical('static', s)) {
1576 staticKeyword = token; 1578 staticKeyword = token;
1577 } else if (identical('var', s)) { 1579 } else if (identical('var', s)) {
1578 finalConstOrVarKeyword = token; 1580 finalConstOrVarKeyword = token;
1579 } else { 1581 } else {
1580 internalError('Unhandled modifier: $s'); 1582 internalError('Unhandled modifier: $s');
1581 } 1583 }
1582 } 1584 }
1583 } 1585 }
1584 } 1586 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698