Fix casting of List<String> parameters in VM service generator.
Also updates special cased handling of the `scope` parameter to instead work for any Map typed parameter. Simplified things in general here by casting values to the correct collection type and then relying on `.cast()` to fill in the proper generic types instead of explicitly filling them in. Change-Id: I7fef91105ca73ee9726780abd76e92817a9e46c0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/504780 Commit-Queue: Jake Macdonald <jakemac@google.com> Auto-Submit: Jake Macdonald <jakemac@google.com> Reviewed-by: Ben Konyi <bkonyi@google.com>
This commit is contained in:
committed by
dart-scoped@luci-project-accounts.iam.gserviceaccount.com
parent
b2911c0bf1
commit
82a952f14a
@@ -144,6 +144,19 @@ final tests = <IsolateTest>[
|
||||
expect(scripts.length, 1);
|
||||
expect(scripts[0].uri!, endsWith('get_source_report_test.dart'));
|
||||
|
||||
// With `libraryFilters` and `librariesAlreadyCompiled`
|
||||
coverage = await service.getSourceReport(
|
||||
isolateId,
|
||||
[SourceReportKind.kCoverage],
|
||||
scriptId: scriptId,
|
||||
tokenPos: func.location!.tokenPos!,
|
||||
endTokenPos: func.location!.endTokenPos!,
|
||||
libraryFilters: [scripts[0].uri!],
|
||||
librariesAlreadyCompiled: [scripts[0].uri!],
|
||||
);
|
||||
scripts = coverage.scripts!;
|
||||
expect(scripts[0].uri!, endsWith('get_source_report_test.dart'));
|
||||
|
||||
// Full isolate
|
||||
coverage = await service.getSourceReport(
|
||||
isolateId,
|
||||
|
||||
@@ -455,6 +455,8 @@ class TypeRef {
|
||||
|
||||
bool get isArray => arrayDepth > 0;
|
||||
|
||||
bool get isMap => name == 'Map';
|
||||
|
||||
bool get isSimple =>
|
||||
arrayDepth == 0 &&
|
||||
(name == 'int' ||
|
||||
|
||||
@@ -45,7 +45,7 @@ abstract interface class VmServiceInterface {
|
||||
|
||||
/// Invoked by the Dart Development Service (DDS) immediately after it
|
||||
/// connects.
|
||||
///
|
||||
///
|
||||
/// [uri] is a HTTP URI pointing to the connected DDS instance.
|
||||
///
|
||||
/// When invoked, the VM service implementation should enter single-client
|
||||
@@ -180,7 +180,7 @@ class VmServerConnection {
|
||||
m.args.where((arg) => !arg.optional).forEach((MethodArg arg) {
|
||||
if (arg.type.isArray) {
|
||||
gen.write(
|
||||
"${arg.type.listCreationRef}.from(params${nullCheck()}['${arg.name}'] ?? []), ");
|
||||
"(params${nullCheck()}['${arg.name}'] as List? ?? []).cast(), ");
|
||||
} else {
|
||||
gen.write("params${nullCheck()}['${arg.name}'], ");
|
||||
}
|
||||
@@ -189,9 +189,12 @@ class VmServerConnection {
|
||||
var namedArgs = m.args.where((arg) => arg.optional);
|
||||
if (namedArgs.isNotEmpty) {
|
||||
for (var arg in namedArgs) {
|
||||
if (arg.name == 'scope') {
|
||||
if (arg.type.isMap) {
|
||||
gen.writeln(
|
||||
"${arg.name}: params${nullCheck()}['${arg.name}']?.cast<String, String>(), ");
|
||||
"${arg.name}: (params${nullCheck()}['${arg.name}'] as Map?)?.cast(), ");
|
||||
} else if (arg.type.isArray) {
|
||||
gen.writeln(
|
||||
"${arg.name}: (params${nullCheck()}['${arg.name}'] as List?)?.cast(), ");
|
||||
} else {
|
||||
gen.writeln(
|
||||
"${arg.name}: params${nullCheck()}['${arg.name}'], ");
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
## 2.0.2-wip
|
||||
- Bug fix for `List<String>` parameters to do proper deep casting.
|
||||
|
||||
## 2.0.1
|
||||
- Update `package:vm_service` constraint to `>=14.3.0 <16.0.0`.
|
||||
|
||||
|
||||
@@ -1477,7 +1477,7 @@ class VmServerConnection {
|
||||
params!['isolateId'],
|
||||
params['targetId'],
|
||||
params['selector'],
|
||||
List<String>.from(params['argumentIds'] ?? []),
|
||||
(params['argumentIds'] as List? ?? []).cast(),
|
||||
disableBreakpoints: params['disableBreakpoints'],
|
||||
idZoneId: params['idZoneId'],
|
||||
);
|
||||
@@ -1487,7 +1487,7 @@ class VmServerConnection {
|
||||
params!['isolateId'],
|
||||
params['targetId'],
|
||||
params['expression'],
|
||||
scope: params['scope']?.cast<String, String>(),
|
||||
scope: (params['scope'] as Map?)?.cast(),
|
||||
disableBreakpoints: params['disableBreakpoints'],
|
||||
idZoneId: params['idZoneId'],
|
||||
);
|
||||
@@ -1497,7 +1497,7 @@ class VmServerConnection {
|
||||
params!['isolateId'],
|
||||
params['frameIndex'],
|
||||
params['expression'],
|
||||
scope: params['scope']?.cast<String, String>(),
|
||||
scope: (params['scope'] as Map?)?.cast(),
|
||||
disableBreakpoints: params['disableBreakpoints'],
|
||||
idZoneId: params['idZoneId'],
|
||||
);
|
||||
@@ -1645,14 +1645,15 @@ class VmServerConnection {
|
||||
case 'getSourceReport':
|
||||
response = await _serviceImplementation.getSourceReport(
|
||||
params!['isolateId'],
|
||||
List<String>.from(params['reports'] ?? []),
|
||||
(params['reports'] as List? ?? []).cast(),
|
||||
scriptId: params['scriptId'],
|
||||
tokenPos: params['tokenPos'],
|
||||
endTokenPos: params['endTokenPos'],
|
||||
forceCompile: params['forceCompile'],
|
||||
reportLines: params['reportLines'],
|
||||
libraryFilters: params['libraryFilters'],
|
||||
librariesAlreadyCompiled: params['librariesAlreadyCompiled'],
|
||||
libraryFilters: (params['libraryFilters'] as List?)?.cast(),
|
||||
librariesAlreadyCompiled:
|
||||
(params['librariesAlreadyCompiled'] as List?)?.cast(),
|
||||
);
|
||||
break;
|
||||
case 'getVersion':
|
||||
@@ -1686,14 +1687,14 @@ class VmServerConnection {
|
||||
case 'lookupResolvedPackageUris':
|
||||
response = await _serviceImplementation.lookupResolvedPackageUris(
|
||||
params!['isolateId'],
|
||||
List<String>.from(params['uris'] ?? []),
|
||||
(params['uris'] as List? ?? []).cast(),
|
||||
local: params['local'],
|
||||
);
|
||||
break;
|
||||
case 'lookupPackageUris':
|
||||
response = await _serviceImplementation.lookupPackageUris(
|
||||
params!['isolateId'],
|
||||
List<String>.from(params['uris'] ?? []),
|
||||
(params['uris'] as List? ?? []).cast(),
|
||||
);
|
||||
break;
|
||||
case 'reloadSources':
|
||||
@@ -1777,7 +1778,7 @@ class VmServerConnection {
|
||||
break;
|
||||
case 'setVMTimelineFlags':
|
||||
response = await _serviceImplementation.setVMTimelineFlags(
|
||||
List<String>.from(params!['recordedStreams'] ?? []),
|
||||
(params!['recordedStreams'] as List? ?? []).cast(),
|
||||
);
|
||||
break;
|
||||
case 'streamCancel':
|
||||
@@ -1797,7 +1798,7 @@ class VmServerConnection {
|
||||
case 'streamCpuSamplesWithUserTag':
|
||||
// ignore: deprecated_member_use_from_same_package
|
||||
response = await _serviceImplementation.streamCpuSamplesWithUserTag(
|
||||
List<String>.from(params!['userTags'] ?? []),
|
||||
(params!['userTags'] as List? ?? []).cast(),
|
||||
);
|
||||
break;
|
||||
case 'streamListen':
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
name: vm_service_interface
|
||||
|
||||
version: 2.0.1
|
||||
version: 2.0.2-wip
|
||||
description: >-
|
||||
A library providing an interface to implement the Dart VM service protocol.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user