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

Unified Diff: pkg/analyzer2dart/lib/src/tree_shaker.dart

Issue 652613004: Add tree shaker support for setters and field writes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 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
Index: pkg/analyzer2dart/lib/src/tree_shaker.dart
diff --git a/pkg/analyzer2dart/lib/src/tree_shaker.dart b/pkg/analyzer2dart/lib/src/tree_shaker.dart
index bdf94c5809b26c0b03d3a481821d25968724f4a8..6b55396cfa6171e23bbb2eabfa3d020e78f434d2 100644
--- a/pkg/analyzer2dart/lib/src/tree_shaker.dart
+++ b/pkg/analyzer2dart/lib/src/tree_shaker.dart
@@ -137,6 +137,19 @@ class LocalReachabilityComputer {
}
}
}
+ } else if (selector.kind == SelectorKind.SETTER) {
+ for (PropertyAccessorElement accessor in classElement.accessors) {
+ // accessor.name uses the convention that setter names end in '='.
+ if (accessor.isSetter && '${selector.name}=' == accessor.name) {
scheglov 2014/10/21 14:58:21 We could probably make it slightly faster by compu
Paul Berry 2014/10/21 15:14:04 Done.
+ if (accessor.isSynthetic) {
+ // This accessor is implied by the corresponding field declaration.
+ // TODO(paulberry): should we distinguish reads and writes?
+ fields.add(accessor.variable);
+ } else {
+ accessors.add(accessor);
+ }
+ }
+ }
}
}
}
@@ -294,8 +307,10 @@ class TreeShakingVisitor extends SemanticVisitor {
new Selector.getter(semantics.identifier.name, null));
}
if (semantics.isWrite) {
- // TODO(paulberry): implement.
- return giveUp(node, '_handlePropertyAccess of ${semantics}.');
+ // Selector.setter constructor uses the convention that setter names
+ // don't end in '='.
+ analysis.invokes.add(
+ new Selector.setter(semantics.identifier.name, null));
}
}
« no previous file with comments | « no previous file | pkg/analyzer2dart/test/tree_shaker_test.dart » ('j') | pkg/analyzer2dart/test/tree_shaker_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698