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

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

Issue 2691523002: Ensure locations are always provided, but don't store them yet. (Closed)
Patch Set: Address comments. 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 | pkg/front_end/lib/src/fasta/analyzer/element_store.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:front_end/src/fasta/scanner/token.dart' show 7 import 'package:front_end/src/fasta/scanner/token.dart' show
8 BeginGroupToken, 8 BeginGroupToken,
9 Token; 9 Token;
10 10
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 final Builder member; 60 final Builder member;
61 61
62 final ElementStore elementStore; 62 final ElementStore elementStore;
63 63
64 bool isFirstIdentifier = false; 64 bool isFirstIdentifier = false;
65 65
66 AstBuilder(this.library, this.member, this.elementStore, Scope scope) 66 AstBuilder(this.library, this.member, this.elementStore, Scope scope)
67 : super(scope); 67 : super(scope);
68 68
69 Uri get uri => library.uri; 69 Uri get uri => library.fileUri ?? library.uri;
70 70
71 createJumpTarget(JumpTargetKind kind) { 71 createJumpTarget(JumpTargetKind kind, int charOffset) {
72 // TODO(ahe): Implement jump targets. 72 // TODO(ahe): Implement jump targets.
73 return null; 73 return null;
74 } 74 }
75 75
76 void beginLiteralString(Token token) { 76 void beginLiteralString(Token token) {
77 debugEvent("beginLiteralString"); 77 debugEvent("beginLiteralString");
78 push(token); 78 push(token);
79 } 79 }
80 80
81 void handleStringPart(Token token) { 81 void handleStringPart(Token token) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 135
136 void beginExpression(Token token) { 136 void beginExpression(Token token) {
137 isFirstIdentifier = true; 137 isFirstIdentifier = true;
138 } 138 }
139 139
140 void handleIdentifier(Token token) { 140 void handleIdentifier(Token token) {
141 debugEvent("handleIdentifier"); 141 debugEvent("handleIdentifier");
142 String name = token.value; 142 String name = token.value;
143 SimpleIdentifier identifier = ast.simpleIdentifier(toAnalyzerToken(token)); 143 SimpleIdentifier identifier = ast.simpleIdentifier(toAnalyzerToken(token));
144 if (isFirstIdentifier) { 144 if (isFirstIdentifier) {
145 Builder builder = scope.lookup(name); 145 Builder builder = scope.lookup(name, token.charOffset, uri);
146 if (builder != null) { 146 if (builder != null) {
147 Element element = elementStore[builder]; 147 Element element = elementStore[builder];
148 assert(element != null); 148 assert(element != null);
149 identifier.staticElement = element; 149 identifier.staticElement = element;
150 } 150 }
151 } 151 }
152 push(identifier); 152 push(identifier);
153 isFirstIdentifier = false; 153 isFirstIdentifier = false;
154 } 154 }
155 155
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 SimpleIdentifier name = pop(); 445 SimpleIdentifier name = pop();
446 KernelClassElement cls = name.staticElement; 446 KernelClassElement cls = name.staticElement;
447 if (cls == null) { 447 if (cls == null) {
448 Builder builder = scope.lookup(name.name); 448 Builder builder = scope.lookup(name.name, beginToken.charOffset, uri);
449 if (builder == null) { 449 if (builder == null) {
450 internalError("Undefined name: $name"); 450 internalError("Undefined name: $name");
451 } 451 }
452 // TODO(paulberry,ahe): what if the type doesn't resolve to a class 452 // TODO(paulberry,ahe): what if the type doesn't resolve to a class
453 // element? 453 // element?
454 cls = elementStore[builder]; 454 cls = elementStore[builder];
455 assert(cls != null); 455 assert(cls != null);
456 name.staticElement = cls; 456 name.staticElement = cls;
457 } 457 }
458 push(ast.typeName(name, arguments)..type = cls.rawType); 458 push(ast.typeName(name, arguments)..type = cls.rawType);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 debugEvent("Modifier"); 588 debugEvent("Modifier");
589 // TODO(ahe): Don't ignore modifiers. 589 // TODO(ahe): Don't ignore modifiers.
590 } 590 }
591 591
592 void handleModifiers(int count) { 592 void handleModifiers(int count) {
593 debugEvent("Modifiers"); 593 debugEvent("Modifiers");
594 // TODO(ahe): Don't ignore modifiers. 594 // TODO(ahe): Don't ignore modifiers.
595 push(NullValue.Modifiers); 595 push(NullValue.Modifiers);
596 } 596 }
597 } 597 }
OLDNEW
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/analyzer/element_store.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698