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

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

Issue 2709753006: Minor fixes to AstBuilder. (Closed)
Patch Set: Created 3 years, 10 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 | no next file » | 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' as analyzer show Token; 10 import 'package:analyzer/dart/ast/token.dart' as analyzer show Token;
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 components[i] = identifier.token; 437 components[i] = identifier.token;
438 } 438 }
439 push(ast.symbolLiteral(toAnalyzerToken(hashToken), components)); 439 push(ast.symbolLiteral(toAnalyzerToken(hashToken), components));
440 } 440 }
441 441
442 void endType(Token beginToken, Token endToken) { 442 void endType(Token beginToken, Token endToken) {
443 debugEvent("Type"); 443 debugEvent("Type");
444 TypeArgumentList arguments = pop(); 444 TypeArgumentList arguments = pop();
445 Identifier name = pop(); 445 Identifier name = pop();
446 // TODO(paulberry,ahe): what if the type doesn't resolve to a class 446 // TODO(paulberry,ahe): what if the type doesn't resolve to a class
447 // element? 447 // element? Try to share code with BodyBuilder.builderToFirstExpression.
448 KernelClassElement cls = name.staticElement; 448 KernelClassElement cls = name.staticElement;
449 if (cls == null) { 449 if (cls == null) {
450 // TODO(paulberry): This is a kludge. Ideally we should already have 450 // TODO(paulberry): This is a kludge. Ideally we should already have
451 // set the static element at the time that handleIdentifier was called. 451 // set the static element at the time that handleIdentifier was called.
452 Builder builder = scope.lookup(name.name, beginToken.charOffset, uri); 452 Builder builder = scope.lookup(name.name, beginToken.charOffset, uri);
453 if (builder == null) { 453 if (builder == null) {
454 internalError("Undefined name: $name"); 454 internalError("Undefined name: $name");
455 } 455 }
456 cls = elementStore[builder]; 456 cls = elementStore[builder];
457 assert(cls != null); 457 assert(cls != null);
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 @override 910 @override
911 void handleQualified(Token period) { 911 void handleQualified(Token period) {
912 SimpleIdentifier identifier = pop(); 912 SimpleIdentifier identifier = pop();
913 if (accumulateIdentifierComponents) { 913 if (accumulateIdentifierComponents) {
914 List<SimpleIdentifier> list = pop(); 914 List<SimpleIdentifier> list = pop();
915 list.add(identifier); 915 list.add(identifier);
916 push(list); 916 push(list);
917 } else { 917 } else {
918 var prefix = pop(); 918 var prefix = pop();
919 if (prefix is SimpleIdentifier) { 919 if (prefix is SimpleIdentifier) {
920 // TODO(paulberry): resolve [identifier]. 920 // TODO(paulberry): resolve [identifier]. Note that BodyBuilder handles
921 // this situation using SendAccessor.
921 push(ast.prefixedIdentifier( 922 push(ast.prefixedIdentifier(
922 prefix, toAnalyzerToken(period), identifier)); 923 prefix, toAnalyzerToken(period), identifier));
923 } else { 924 } else {
924 // TODO(paulberry): implement. 925 // TODO(paulberry): implement.
925 logEvent('Qualified with >1 dot'); 926 logEvent('Qualified with >1 dot');
926 } 927 }
927 } 928 }
928 } 929 }
929 930
930 @override 931 @override
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 } 1028 }
1028 1029
1029 @override 1030 @override
1030 void endMethod(Token getOrSet, Token beginToken, Token endToken) { 1031 void endMethod(Token getOrSet, Token beginToken, Token endToken) {
1031 debugEvent("Method"); 1032 debugEvent("Method");
1032 FunctionBody body = _endFunctionBody(); 1033 FunctionBody body = _endFunctionBody();
1033 ConstructorName redirectedConstructor = null; // TODO(paulberry) 1034 ConstructorName redirectedConstructor = null; // TODO(paulberry)
1034 List<ConstructorInitializer> initializers = null; // TODO(paulberry) 1035 List<ConstructorInitializer> initializers = null; // TODO(paulberry)
1035 Token separator = null; // TODO(paulberry) 1036 Token separator = null; // TODO(paulberry)
1036 FormalParameterList parameters = pop(); 1037 FormalParameterList parameters = pop();
1037 TypeParameterList typeParameters = pop(); 1038 /* TypeParameterList typeParameters = */ pop(); // TODO(paulberry)
1038 var name = pop(); 1039 var name = pop();
1039 analyzer.Token propertyKeyword = toAnalyzerToken(getOrSet); 1040 // TODO(paulberry)
1040 TypeAnnotation returnType = pop(); 1041 // analyzer.Token propertyKeyword = toAnalyzerToken(getOrSet);
1042 /* TypeAnnotation returnType = */ pop(); // TODO(paulberry)
1041 1043
1042 Token externalKeyword = null; 1044 Token externalKeyword = null;
1043 Token constKeyword = null; 1045 Token constKeyword = null;
1044 Token factoryKeyword = null; 1046 Token factoryKeyword = null;
1045 List<Token> modifiers = pop(); 1047 List<Token> modifiers = pop();
1046 for (Token modifier in modifiers) { 1048 for (Token modifier in modifiers) {
1047 String value = modifier.stringValue; 1049 String value = modifier.stringValue;
1048 if (identical('external', value)) { 1050 if (identical('external', value)) {
1049 // TODO(scheglov): Check the order and uniqueness. 1051 // TODO(scheglov): Check the order and uniqueness.
1050 externalKeyword = modifier; 1052 externalKeyword = modifier;
1051 } else if (identical('const', value)) { 1053 } else if (identical('const', value)) {
1052 // TODO(scheglov): Check the order and uniqueness. 1054 // TODO(scheglov): Check the order and uniqueness.
1053 constKeyword = modifier; 1055 constKeyword = modifier;
1054 } else if (identical('factory', value)) { 1056 } else if (identical('factory', value)) {
1055 // TODO(scheglov): Check the order and uniqueness. 1057 // TODO(scheglov): Check the order and uniqueness.
1056 factoryKeyword = modifier; 1058 factoryKeyword = modifier;
1057 } else { 1059 } else {
1058 // TODO(scheglov): Report error. 1060 // TODO(scheglov): Report error.
1059 internalError("Invalid modifier. Report an error."); 1061 internalError("Invalid modifier. Report an error.");
1060 } 1062 }
1061 } 1063 }
1062 1064
1063 List<Annotation> metadata = pop(); 1065 List<Annotation> metadata = pop();
1064 // TODO(paulberry): capture doc comments. See dartbug.com/28851. 1066 // TODO(paulberry): capture doc comments. See dartbug.com/28851.
1065 Comment comment = null; 1067 Comment comment = null;
1066 SimpleIdentifier returnType2; 1068 SimpleIdentifier returnType2;
1067 Token period; 1069 Token period;
1068 SimpleIdentifier name2; 1070 SimpleIdentifier name2;
1069 if (name is SimpleIdentifier) { 1071 if (name is SimpleIdentifier) {
1070 SimpleIdentifier returnType2 = name; 1072 returnType2 = name;
1071 } 1073 }
1072 push(ast.constructorDeclaration( 1074 push(ast.constructorDeclaration(
1073 comment, 1075 comment,
1074 metadata, 1076 metadata,
1075 toAnalyzerToken(externalKeyword), 1077 toAnalyzerToken(externalKeyword),
1076 toAnalyzerToken(constKeyword), 1078 toAnalyzerToken(constKeyword),
1077 toAnalyzerToken(factoryKeyword), 1079 toAnalyzerToken(factoryKeyword),
1078 returnType2, 1080 returnType2,
1079 toAnalyzerToken(period), 1081 toAnalyzerToken(period),
1080 name2, 1082 name2,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 /// [ClassDeclaration] or [ClassTypeAlias] object. 1165 /// [ClassDeclaration] or [ClassTypeAlias] object.
1164 class _MixinApplication { 1166 class _MixinApplication {
1165 final TypeName supertype; 1167 final TypeName supertype;
1166 1168
1167 final Token withKeyword; 1169 final Token withKeyword;
1168 1170
1169 final List<TypeName> mixinTypes; 1171 final List<TypeName> mixinTypes;
1170 1172
1171 _MixinApplication(this.supertype, this.withKeyword, this.mixinTypes); 1173 _MixinApplication(this.supertype, this.withKeyword, this.mixinTypes);
1172 } 1174 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698