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

Unified Diff: pkg/js_ast/lib/src/printer.dart

Issue 1140703006: dart2js: Construct the entire output as a single AST before printing. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Comments Created 5 years, 7 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 | « pkg/js_ast/lib/src/builder.dart ('k') | pkg/js_ast/lib/src/template.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/js_ast/lib/src/printer.dart
diff --git a/pkg/js_ast/lib/src/printer.dart b/pkg/js_ast/lib/src/printer.dart
index 917fcf49b6fe9ac53dc051d4163f8dc22beec2c1..57b35cfae4ce9cf8ae1e9175ffbac7165d61a1f1 100644
--- a/pkg/js_ast/lib/src/printer.dart
+++ b/pkg/js_ast/lib/src/printer.dart
@@ -1156,9 +1156,13 @@ class OrderedSet<T> {
// separate pass because JS vars are lifted to the top of the function.
class VarCollector extends BaseVisitor {
bool nested;
+ bool enableRenaming = true;
final OrderedSet<String> vars;
final OrderedSet<String> params;
+ static final String disableVariableMinificationPattern = "::norenaming::";
+ static final String enableVariableMinificationPattern = "::dorenaming::";
+
VarCollector() : nested = false,
vars = new OrderedSet<String>(),
params = new OrderedSet<String>();
@@ -1195,8 +1199,16 @@ class VarCollector extends BaseVisitor {
void visitThis(This node) {}
+ void visitComment(Comment node) {
+ if (node.comment.contains(disableVariableMinificationPattern)) {
+ enableRenaming = false;
+ } else if (node.comment.contains(enableVariableMinificationPattern)) {
+ enableRenaming = true;
+ }
+ }
+
void visitVariableDeclaration(VariableDeclaration decl) {
- if (decl.allowRename) vars.add(decl.name);
+ if (enableRenaming && decl.allowRename) vars.add(decl.name);
}
}
« no previous file with comments | « pkg/js_ast/lib/src/builder.dart ('k') | pkg/js_ast/lib/src/template.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698