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

Unified Diff: pkg/front_end/lib/src/fasta/scope.dart

Issue 2795433002: Add debugString to scope. (Closed)
Patch Set: Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/src/fasta/scope.dart
diff --git a/pkg/front_end/lib/src/fasta/scope.dart b/pkg/front_end/lib/src/fasta/scope.dart
index c1b884cb0225388dd854264c7585cc3cdf207aad..c477ba95b303735a04e833cdc9f809eb24970cf6 100644
--- a/pkg/front_end/lib/src/fasta/scope.dart
+++ b/pkg/front_end/lib/src/fasta/scope.dart
@@ -164,6 +164,28 @@ class Scope {
void forEach(f(String name, Builder member)) {
local.forEach(f);
}
+
+ String get debugString {
+ StringBuffer buffer = new StringBuffer();
+ int nestingLevel = writeOn(buffer);
+ for (int i = nestingLevel; i >= 0; i--) {
+ buffer.writeln("${' ' * i}}");
+ }
+ return "$buffer";
+ }
+
+ int writeOn(StringSink sink) {
+ int nestingLevel = (parent?.writeOn(sink) ?? -1) + 1;
+ String indent = " " * nestingLevel;
+ sink.writeln("$indent{");
+ local.forEach((String name, Builder member) {
+ sink.writeln("$indent $name");
+ });
+ setters.forEach((String name, Builder member) {
+ sink.writeln("$indent $name=");
+ });
+ return nestingLevel;
+ }
}
abstract class ProblemBuilder extends Builder {
« 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