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

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

Issue 2795433002: Add debugString to scope. (Closed)
Patch Set: Created 3 years, 8 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.scope; 5 library fasta.scope;
6 6
7 import 'builder/builder.dart' show Builder, MixedAccessor; 7 import 'builder/builder.dart' show Builder, MixedAccessor;
8 8
9 import 'errors.dart' show internalError; 9 import 'errors.dart' show internalError;
10 10
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 if (isModifiable) { 157 if (isModifiable) {
158 local[name] = member; 158 local[name] = member;
159 } else { 159 } else {
160 internalError("Can't extend an unmodifiable scope."); 160 internalError("Can't extend an unmodifiable scope.");
161 } 161 }
162 } 162 }
163 163
164 void forEach(f(String name, Builder member)) { 164 void forEach(f(String name, Builder member)) {
165 local.forEach(f); 165 local.forEach(f);
166 } 166 }
167
168 String get debugString {
169 StringBuffer buffer = new StringBuffer();
170 int nestingLevel = writeOn(buffer);
171 for (int i = nestingLevel; i >= 0; i--) {
172 buffer.writeln("${' ' * i}}");
173 }
174 return "$buffer";
175 }
176
177 int writeOn(StringSink sink) {
178 int nestingLevel = (parent?.writeOn(sink) ?? -1) + 1;
179 String indent = " " * nestingLevel;
180 sink.writeln("$indent{");
181 local.forEach((String name, Builder member) {
182 sink.writeln("$indent $name");
183 });
184 setters.forEach((String name, Builder member) {
185 sink.writeln("$indent $name=");
186 });
187 return nestingLevel;
188 }
167 } 189 }
168 190
169 abstract class ProblemBuilder extends Builder { 191 abstract class ProblemBuilder extends Builder {
170 final String name; 192 final String name;
171 193
172 final Builder builder; 194 final Builder builder;
173 195
174 ProblemBuilder(this.name, this.builder, int charOffset, Uri fileUri) 196 ProblemBuilder(this.name, this.builder, int charOffset, Uri fileUri)
175 : super(null, charOffset, fileUri); 197 : super(null, charOffset, fileUri);
176 198
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 236
215 String get message => "Access error: '$name'."; 237 String get message => "Access error: '$name'.";
216 } 238 }
217 239
218 class AmbiguousBuilder extends ProblemBuilder { 240 class AmbiguousBuilder extends ProblemBuilder {
219 AmbiguousBuilder(String name, Builder builder, int charOffset, Uri fileUri) 241 AmbiguousBuilder(String name, Builder builder, int charOffset, Uri fileUri)
220 : super(name, builder, charOffset, fileUri); 242 : super(name, builder, charOffset, fileUri);
221 243
222 String get message => "Duplicated named: '$name'."; 244 String get message => "Duplicated named: '$name'.";
223 } 245 }
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