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

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

Issue 2772943002: store constructor and arguments for constant values (Closed)
Patch Set: clean up import 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
Index: pkg/analyzer/lib/src/dart/constant/value.dart
diff --git a/pkg/analyzer/lib/src/dart/constant/value.dart b/pkg/analyzer/lib/src/dart/constant/value.dart
index a927df61a25e54153166a5a6ec2f78c9bf38275f..686776dd3fedb6631a5fe78ec95fadaa43b40ca4 100644
--- a/pkg/analyzer/lib/src/dart/constant/value.dart
+++ b/pkg/analyzer/lib/src/dart/constant/value.dart
@@ -375,6 +375,36 @@ class DartObjectImpl implements DartObject {
return null;
}
+ /// Gets the constructor that was called to create this value, if this is a
+ /// const constructor invocation. Otherwise returns null.
+ ConstructorElement getConstructor() {
+ InstanceState state = _state;
+ if (state is GenericState) {
+ return state.constructor;
+ }
+ return null;
+ }
+
+ /// Gets the arguments that were passed to create this value, if this is a
+ /// const constructor invocation. Otherwise returns null.
+ List<DartObject> getPositionalArguments() {
+ InstanceState state = _state;
+ if (state is GenericState) {
+ return state.positionalArguments;
+ }
+ return null;
+ }
+
+ /// Gets the named arguments that were passed to create this value, if this is
+ /// a const constructor invocation. Otherwise returns null.
+ Map<String, DartObject> getNamedArguments() {
+ InstanceState state = _state;
+ if (state is GenericState) {
+ return state.namedArguments;
+ }
+ return null;
+ }
+
/**
* Return the result of invoking the '&gt;' operator on this object with the
* [rightOperand]. The [typeProvider] is the type provider used to find known
@@ -1322,10 +1352,26 @@ class GenericState extends InstanceState {
final HashMap<String, DartObjectImpl> _fieldMap;
/**
+ * The constructor that was invoked to generate this instance.
+ */
+ final ConstructorElement constructor;
+
+ /**
+ * The positional arguments passed to the constructor to create this instance.
+ */
+ final List<DartObject> positionalArguments;
+
+ /**
+ * The named arguments passed to the constructor to create this instance.
+ */
+ final Map<String, DartObject> namedArguments;
+
+ /**
* Initialize a newly created state to represent a newly created object. The
* [fieldMap] contains the values of the fields of the instance.
*/
- GenericState(this._fieldMap);
+ GenericState(this._fieldMap,
+ {this.constructor, this.positionalArguments, this.namedArguments});
@override
HashMap<String, DartObjectImpl> get fields => _fieldMap;

Powered by Google App Engine
This is Rietveld 408576698