Commit 99315cb
[analyzer] Add DartObject.toRecordValue()
The `DartObject` class in the analyzer represents a known constant
value. It has methods that convert that representation into a more
specific one (e.g. `toListValue()` that returns a list of
`DartObject`).
While constant records can be represented as `DartObject`, there's no
method to directly extract the positional and named fields from that
instance. Users could extract the shape from the record type and then
call `getField`, but that is an error-prone process.
So, this adds `toRecordValue()`, which returns a list for positional
and a map for named parameters when called on a `DartObject`
representing a record.
TEST=pkg/analyzer/test/src/dart/constant/value_test.dart
Change-Id: I56f3e877ea78ab0f3ccfb7ac73ffda80ee4fe846
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/394860
Reviewed-by: Brian Wilkerson <[email protected]>
Commit-Queue: Brian Wilkerson <[email protected]>
Reviewed-by: Samuel Rawlins <[email protected]>1 parent 3bc27ff commit 99315cb
File tree
3 files changed
+37
-0
lines changed- pkg/analyzer
- lib
- dart/constant
- src/dart/constant
- test/src/dart/constant
3 files changed
+37
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
124 | 132 | | |
125 | 133 | | |
126 | 134 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
924 | 924 | | |
925 | 925 | | |
926 | 926 | | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
927 | 937 | | |
928 | 938 | | |
929 | 939 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1928 | 1928 | | |
1929 | 1929 | | |
1930 | 1930 | | |
| 1931 | + | |
| 1932 | + | |
| 1933 | + | |
| 1934 | + | |
| 1935 | + | |
| 1936 | + | |
| 1937 | + | |
| 1938 | + | |
| 1939 | + | |
| 1940 | + | |
| 1941 | + | |
| 1942 | + | |
| 1943 | + | |
| 1944 | + | |
| 1945 | + | |
| 1946 | + | |
| 1947 | + | |
| 1948 | + | |
| 1949 | + | |
1931 | 1950 | | |
1932 | 1951 | | |
1933 | 1952 | | |
| |||
0 commit comments