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

Unified Diff: pkg/analyzer/lib/src/generated/constant.dart

Issue 1539623002: Compute values of elements a unit constant expressions depend on. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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 | pkg/analyzer/lib/src/task/dart.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/constant.dart
diff --git a/pkg/analyzer/lib/src/generated/constant.dart b/pkg/analyzer/lib/src/generated/constant.dart
index b57f9e01d99ba6c8f6c24f01865c5c7d375d4569..d4484cd44eea9e91d2a96c29bc6a16686216aeb5 100644
--- a/pkg/analyzer/lib/src/generated/constant.dart
+++ b/pkg/analyzer/lib/src/generated/constant.dart
@@ -1230,6 +1230,50 @@ class ConstantEvaluator {
/**
* A visitor used to traverse the AST structures of all of the compilation units
+ * being resolved and build the full set of dependencies for all constant
+ * expressions.
+ */
+class ConstantExpressionsDependenciesFinder extends RecursiveAstVisitor {
+ /**
+ * The constants whose values need to be computed.
+ */
+ HashSet<ConstantEvaluationTarget> dependencies =
+ new HashSet<ConstantEvaluationTarget>();
+
+ @override
+ void visitListLiteral(ListLiteral node) {
+ if (node.constKeyword != null) {
+ _find(node);
+ } else {
+ super.visitListLiteral(node);
+ }
+ }
+
+ @override
+ void visitMapLiteral(MapLiteral node) {
+ if (node.constKeyword != null) {
+ _find(node);
+ } else {
+ super.visitMapLiteral(node);
+ }
+ }
+
+ @override
+ void visitSwitchCase(SwitchCase node) {
+ _find(node.expression);
+ node.statements.accept(this);
+ }
+
+ void _find(Expression node) {
+ if (node != null) {
+ ReferenceFinder referenceFinder = new ReferenceFinder(dependencies.add);
+ node.accept(referenceFinder);
+ }
+ }
+}
+
+/**
+ * A visitor used to traverse the AST structures of all of the compilation units
* being resolved and build tables of the constant variables, constant
* constructors, constant constructor invocations, and annotations found in
* those compilation units.
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/task/dart.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698