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

Side by Side Diff: pkg/front_end/lib/src/fasta/kernel/body_builder.dart

Issue 2711463005: Add contextual information about identifiers to the parser listener API. (Closed)
Patch Set: Fix broken import 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
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.body_builder; 5 library fasta.body_builder;
6 6
7 import 'package:front_end/src/fasta/parser/parser.dart' show 7 import 'package:front_end/src/fasta/parser/parser.dart' show
8 FormalParameterType, 8 FormalParameterType,
9 optional; 9 optional;
10 10
11 import 'package:front_end/src/fasta/parser/error_kind.dart' show 11 import 'package:front_end/src/fasta/parser/error_kind.dart' show
12 ErrorKind; 12 ErrorKind;
13 13
14 import 'package:front_end/src/fasta/parser/identifier_context.dart' show Identif ierContext;
15
14 import 'package:kernel/ast.dart'; 16 import 'package:kernel/ast.dart';
15 17
16 import 'package:kernel/clone.dart' show 18 import 'package:kernel/clone.dart' show
17 CloneVisitor; 19 CloneVisitor;
18 20
19 import 'package:kernel/transformations/flags.dart' show 21 import 'package:kernel/transformations/flags.dart' show
20 TransformerFlag; 22 TransformerFlag;
21 23
22 import 'package:kernel/class_hierarchy.dart' show 24 import 'package:kernel/class_hierarchy.dart' show
23 ClassHierarchy; 25 ClassHierarchy;
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 } 711 }
710 712
711 Builder computeSetter( 713 Builder computeSetter(
712 Builder builder, Scope scope, String name, int charOffset) { 714 Builder builder, Scope scope, String name, int charOffset) {
713 if (builder.isSetter) return builder; 715 if (builder.isSetter) return builder;
714 if (builder.isGetter) return scope.lookupSetter(name, charOffset, uri); 716 if (builder.isGetter) return scope.lookupSetter(name, charOffset, uri);
715 return builder.isField ? (builder.isFinal ? null : builder) : null; 717 return builder.isField ? (builder.isFinal ? null : builder) : null;
716 } 718 }
717 719
718 @override 720 @override
719 void handleIdentifier(Token token) { 721 void handleIdentifier(Token token, IdentifierContext context) {
720 debugEvent("handleIdentifier"); 722 debugEvent("handleIdentifier");
721 String name = token.value; 723 String name = token.value;
722 if (isFirstIdentifier) { 724 if (isFirstIdentifier) {
723 assert(!inInitializer || this.scope == enclosingScope || 725 assert(!inInitializer || this.scope == enclosingScope ||
724 this.scope.parent == enclosingScope); 726 this.scope.parent == enclosingScope);
725 // This deals with this kind of initializer: `C(a) : a = a;` 727 // This deals with this kind of initializer: `C(a) : a = a;`
726 Scope scope = inInitializer ? enclosingScope : this.scope; 728 Scope scope = inInitializer ? enclosingScope : this.scope;
727 Builder builder = scope.lookup(name, token.charOffset, uri); 729 Builder builder = scope.lookup(name, token.charOffset, uri);
728 push(builderToFirstExpression(builder, name, token.charOffset)); 730 push(builderToFirstExpression(builder, name, token.charOffset));
729 } else { 731 } else {
(...skipping 1966 matching lines...) Expand 10 before | Expand all | Expand 10 after
2696 } else if (node is TypeDeclarationBuilder) { 2698 } else if (node is TypeDeclarationBuilder) {
2697 return node.name; 2699 return node.name;
2698 } else if (node is PrefixBuilder) { 2700 } else if (node is PrefixBuilder) {
2699 return node.name; 2701 return node.name;
2700 } else if (node is ThisPropertyAccessor) { 2702 } else if (node is ThisPropertyAccessor) {
2701 return node.name.name; 2703 return node.name.name;
2702 } else { 2704 } else {
2703 return internalError("Unhandled: ${node.runtimeType}"); 2705 return internalError("Unhandled: ${node.runtimeType}");
2704 } 2706 }
2705 } 2707 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698