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.length, 1);
|
||||||
expect(scripts[0].uri!, endsWith('get_source_report_test.dart'));
|
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
|
// Full isolate
|
||||||
coverage = await service.getSourceReport(
|
coverage = await service.getSourceReport(
|
||||||
isolateId,
|
isolateId,
|
||||||
|
|||||||
@@ -455,6 +455,8 @@ class TypeRef {
|
|||||||
|
|
||||||
bool get isArray => arrayDepth > 0;
|
bool get isArray => arrayDepth > 0;
|
||||||
|
|
||||||
|
bool get isMap => name == 'Map';
|
||||||
|
|
||||||
bool get isSimple =>
|
bool get isSimple =>
|
||||||
arrayDepth == 0 &&
|
arrayDepth == 0 &&
|
||||||
(name == 'int' ||
|
(name == 'int' ||
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ abstract interface class VmServiceInterface {
|
|||||||
|
|
||||||
/// Invoked by the Dart Development Service (DDS) immediately after it
|
/// Invoked by the Dart Development Service (DDS) immediately after it
|
||||||
/// connects.
|
/// connects.
|
||||||
///
|
///
|
||||||
/// [uri] is a HTTP URI pointing to the connected DDS instance.
|
/// [uri] is a HTTP URI pointing to the connected DDS instance.
|
||||||
///
|
///
|
||||||
/// When invoked, the VM service implementation should enter single-client
|
/// 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) {
|
m.args.where((arg) => !arg.optional).forEach((MethodArg arg) {
|
||||||
if (arg.type.isArray) {
|
if (arg.type.isArray) {
|
||||||
gen.write(
|
gen.write(
|
||||||
"${arg.type.listCreationRef}.from(params${nullCheck()}['${arg.name}'] ?? []), ");
|
"(params${nullCheck()}['${arg.name}'] as List? ?? []).cast(), ");
|
||||||
} else {
|
} else {
|
||||||
gen.write("params${nullCheck()}['${arg.name}'], ");
|
gen.write("params${nullCheck()}['${arg.name}'], ");
|
||||||
}
|
}
|
||||||
@@ -189,9 +189,12 @@ class VmServerConnection {
|
|||||||
var namedArgs = m.args.where((arg) => arg.optional);
|
var namedArgs = m.args.where((arg) => arg.optional);
|
||||||
if (namedArgs.isNotEmpty) {
|
if (namedArgs.isNotEmpty) {
|
||||||
for (var arg in namedArgs) {
|
for (var arg in namedArgs) {
|
||||||
if (arg.name == 'scope') {
|
if (arg.type.isMap) {
|
||||||
gen.writeln(
|
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 {
|
} else {
|
||||||
gen.writeln(
|
gen.writeln(
|
||||||
"${arg.name}: params${nullCheck()}['${arg.name}'], ");
|
"${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
|
## 2.0.1
|
||||||
- Update `package:vm_service` constraint to `>=14.3.0 <16.0.0`.
|
- Update `package:vm_service` constraint to `>=14.3.0 <16.0.0`.
|
||||||
|
|
||||||
|
|||||||
@@ -1477,7 +1477,7 @@ class VmServerConnection {
|
|||||||
params!['isolateId'],
|
params!['isolateId'],
|
||||||
params['targetId'],
|
params['targetId'],
|
||||||
params['selector'],
|
params['selector'],
|
||||||
List<String>.from(params['argumentIds'] ?? []),
|
(params['argumentIds'] as List? ?? []).cast(),
|
||||||
disableBreakpoints: params['disableBreakpoints'],
|
disableBreakpoints: params['disableBreakpoints'],
|
||||||
idZoneId: params['idZoneId'],
|
idZoneId: params['idZoneId'],
|
||||||
);
|
);
|
||||||
@@ -1487,7 +1487,7 @@ class VmServerConnection {
|
|||||||
params!['isolateId'],
|
params!['isolateId'],
|
||||||
params['targetId'],
|
params['targetId'],
|
||||||
params['expression'],
|
params['expression'],
|
||||||
scope: params['scope']?.cast<String, String>(),
|
scope: (params['scope'] as Map?)?.cast(),
|
||||||
disableBreakpoints: params['disableBreakpoints'],
|
disableBreakpoints: params['disableBreakpoints'],
|
||||||
idZoneId: params['idZoneId'],
|
idZoneId: params['idZoneId'],
|
||||||
);
|
);
|
||||||
@@ -1497,7 +1497,7 @@ class VmServerConnection {
|
|||||||
params!['isolateId'],
|
params!['isolateId'],
|
||||||
params['frameIndex'],
|
params['frameIndex'],
|
||||||
params['expression'],
|
params['expression'],
|
||||||
scope: params['scope']?.cast<String, String>(),
|
scope: (params['scope'] as Map?)?.cast(),
|
||||||
disableBreakpoints: params['disableBreakpoints'],
|
disableBreakpoints: params['disableBreakpoints'],
|
||||||
idZoneId: params['idZoneId'],
|
idZoneId: params['idZoneId'],
|
||||||
);
|
);
|
||||||
@@ -1645,14 +1645,15 @@ class VmServerConnection {
|
|||||||
case 'getSourceReport':
|
case 'getSourceReport':
|
||||||
response = await _serviceImplementation.getSourceReport(
|
response = await _serviceImplementation.getSourceReport(
|
||||||
params!['isolateId'],
|
params!['isolateId'],
|
||||||
List<String>.from(params['reports'] ?? []),
|
(params['reports'] as List? ?? []).cast(),
|
||||||
scriptId: params['scriptId'],
|
scriptId: params['scriptId'],
|
||||||
tokenPos: params['tokenPos'],
|
tokenPos: params['tokenPos'],
|
||||||
endTokenPos: params['endTokenPos'],
|
endTokenPos: params['endTokenPos'],
|
||||||
forceCompile: params['forceCompile'],
|
forceCompile: params['forceCompile'],
|
||||||
reportLines: params['reportLines'],
|
reportLines: params['reportLines'],
|
||||||
libraryFilters: params['libraryFilters'],
|
libraryFilters: (params['libraryFilters'] as List?)?.cast(),
|
||||||
librariesAlreadyCompiled: params['librariesAlreadyCompiled'],
|
librariesAlreadyCompiled:
|
||||||
|
(params['librariesAlreadyCompiled'] as List?)?.cast(),
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'getVersion':
|
case 'getVersion':
|
||||||
@@ -1686,14 +1687,14 @@ class VmServerConnection {
|
|||||||
case 'lookupResolvedPackageUris':
|
case 'lookupResolvedPackageUris':
|
||||||
response = await _serviceImplementation.lookupResolvedPackageUris(
|
response = await _serviceImplementation.lookupResolvedPackageUris(
|
||||||
params!['isolateId'],
|
params!['isolateId'],
|
||||||
List<String>.from(params['uris'] ?? []),
|
(params['uris'] as List? ?? []).cast(),
|
||||||
local: params['local'],
|
local: params['local'],
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'lookupPackageUris':
|
case 'lookupPackageUris':
|
||||||
response = await _serviceImplementation.lookupPackageUris(
|
response = await _serviceImplementation.lookupPackageUris(
|
||||||
params!['isolateId'],
|
params!['isolateId'],
|
||||||
List<String>.from(params['uris'] ?? []),
|
(params['uris'] as List? ?? []).cast(),
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'reloadSources':
|
case 'reloadSources':
|
||||||
@@ -1777,7 +1778,7 @@ class VmServerConnection {
|
|||||||
break;
|
break;
|
||||||
case 'setVMTimelineFlags':
|
case 'setVMTimelineFlags':
|
||||||
response = await _serviceImplementation.setVMTimelineFlags(
|
response = await _serviceImplementation.setVMTimelineFlags(
|
||||||
List<String>.from(params!['recordedStreams'] ?? []),
|
(params!['recordedStreams'] as List? ?? []).cast(),
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'streamCancel':
|
case 'streamCancel':
|
||||||
@@ -1797,7 +1798,7 @@ class VmServerConnection {
|
|||||||
case 'streamCpuSamplesWithUserTag':
|
case 'streamCpuSamplesWithUserTag':
|
||||||
// ignore: deprecated_member_use_from_same_package
|
// ignore: deprecated_member_use_from_same_package
|
||||||
response = await _serviceImplementation.streamCpuSamplesWithUserTag(
|
response = await _serviceImplementation.streamCpuSamplesWithUserTag(
|
||||||
List<String>.from(params!['userTags'] ?? []),
|
(params!['userTags'] as List? ?? []).cast(),
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'streamListen':
|
case 'streamListen':
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
name: vm_service_interface
|
name: vm_service_interface
|
||||||
|
|
||||||
version: 2.0.1
|
version: 2.0.2-wip
|
||||||
description: >-
|
description: >-
|
||||||
A library providing an interface to implement the Dart VM service protocol.
|
A library providing an interface to implement the Dart VM service protocol.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user