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

Side by Side Diff: pkg/front_end/lib/src/fasta/source/source_library_builder.dart

Issue 2689793002: Track names in DeclarationBuilder. (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 | « pkg/front_end/lib/src/fasta/source/outline_builder.dart ('k') | 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.source_library_builder; 5 library fasta.source_library_builder;
6 6
7 import 'package:kernel/ast.dart' show 7 import 'package:kernel/ast.dart' show
8 AsyncMarker, 8 AsyncMarker,
9 ProcedureKind; 9 ProcedureKind;
10 10
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 T addVoidType(int charOffset); 105 T addVoidType(int charOffset);
106 106
107 ConstructorReferenceBuilder addConstructorReference( 107 ConstructorReferenceBuilder addConstructorReference(
108 String name, List<T> typeArguments, String suffix, int charOffset) { 108 String name, List<T> typeArguments, String suffix, int charOffset) {
109 ConstructorReferenceBuilder ref = new ConstructorReferenceBuilder(name, 109 ConstructorReferenceBuilder ref = new ConstructorReferenceBuilder(name,
110 typeArguments, suffix, this, charOffset); 110 typeArguments, suffix, this, charOffset);
111 constructorReferences.add(ref); 111 constructorReferences.add(ref);
112 return ref; 112 return ref;
113 } 113 }
114 114
115 void beginNestedDeclaration({bool hasMembers}) { 115 void beginNestedDeclaration(String name, {bool hasMembers}) {
116 currentDeclaration = 116 currentDeclaration =
117 new DeclarationBuilder(<String, MemberBuilder>{}, currentDeclaration); 117 new DeclarationBuilder(<String, MemberBuilder>{}, name, currentDeclarati on);
118 } 118 }
119 119
120 DeclarationBuilder<T> endNestedDeclaration() { 120 DeclarationBuilder<T> endNestedDeclaration() {
121 DeclarationBuilder<T> previous = currentDeclaration; 121 DeclarationBuilder<T> previous = currentDeclaration;
122 currentDeclaration = currentDeclaration.parent; 122 currentDeclaration = currentDeclaration.parent;
123 return previous; 123 return previous;
124 } 124 }
125 125
126 Uri resolve(String path) => uri.resolve(path); 126 Uri resolve(String path) => uri.resolve(path);
127 127
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 for (String name in names) { 172 for (String name in names) {
173 // TODO(ahe): Get charOffset of name. 173 // TODO(ahe): Get charOffset of name.
174 addField(metadata, modifiers, type, name, -1); 174 addField(metadata, modifiers, type, name, -1);
175 } 175 }
176 } 176 }
177 177
178 void addProcedure(List<MetadataBuilder> metadata, 178 void addProcedure(List<MetadataBuilder> metadata,
179 int modifiers, T returnType, String name, 179 int modifiers, T returnType, String name,
180 List<TypeVariableBuilder> typeVariables, 180 List<TypeVariableBuilder> typeVariables,
181 List<FormalParameterBuilder> formals, AsyncMarker asyncModifier, 181 List<FormalParameterBuilder> formals, AsyncMarker asyncModifier,
182 ProcedureKind kind, int charOffset); 182 ProcedureKind kind, int charOffset, {bool isTopLevel});
183 183
184 void addEnum(List<MetadataBuilder> metadata, String name, 184 void addEnum(List<MetadataBuilder> metadata, String name,
185 List<String> constants, int charOffset); 185 List<String> constants, int charOffset);
186 186
187 void addFunctionTypeAlias(List<MetadataBuilder> metadata, 187 void addFunctionTypeAlias(List<MetadataBuilder> metadata,
188 T returnType, String name, 188 T returnType, String name,
189 List<TypeVariableBuilder> typeVariables, 189 List<TypeVariableBuilder> typeVariables,
190 List<FormalParameterBuilder> formals, int charOffset); 190 List<FormalParameterBuilder> formals, int charOffset);
191 191
192 void addFactoryMethod(List<MetadataBuilder> metadata, 192 void addFactoryMethod(List<MetadataBuilder> metadata,
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 363
364 /// Unlike [Scope], this scope is used during construction of builders to 364 /// Unlike [Scope], this scope is used during construction of builders to
365 /// ensure types and members are added to and resolved in the correct location. 365 /// ensure types and members are added to and resolved in the correct location.
366 class DeclarationBuilder<T extends TypeBuilder> { 366 class DeclarationBuilder<T extends TypeBuilder> {
367 final DeclarationBuilder<T> parent; 367 final DeclarationBuilder<T> parent;
368 368
369 final Map<String, Builder> members; 369 final Map<String, Builder> members;
370 370
371 final List<T> types = <T>[]; 371 final List<T> types = <T>[];
372 372
373 DeclarationBuilder(this.members, [this.parent]); 373 final String name;
374
375 DeclarationBuilder(this.members, this.name, [this.parent]);
374 376
375 void addMember(String name, MemberBuilder builder) { 377 void addMember(String name, MemberBuilder builder) {
376 if (members == null) { 378 if (members == null) {
377 parent.addMember(name, builder); 379 parent.addMember(name, builder);
378 } else { 380 } else {
379 members[name] = builder; 381 members[name] = builder;
380 } 382 }
381 } 383 }
382 384
383 MemberBuilder lookupMember(String name) { 385 MemberBuilder lookupMember(String name) {
(...skipping 29 matching lines...) Expand all
413 // parent declaration. 415 // parent declaration.
414 parent.addType(type); 416 parent.addType(type);
415 } else { 417 } else {
416 type.bind(builder); 418 type.bind(builder);
417 } 419 }
418 } 420 }
419 } 421 }
420 types.clear(); 422 types.clear();
421 } 423 }
422 } 424 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/source/outline_builder.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698