process function
Future<void>
process(
- VmService vmService,
- Isolate isolate,
- String input
)
Implementation
Future<void> process(VmService vmService, Isolate isolate, String input) async {
try {
if (input.startsWith('print(')) {
await vmService.evaluate(isolateId, isolate.rootLib?.id ?? '', input);
} else if (input.startsWith('reload()')) {
reload();
} else {
if (isStatement(input)) {
// check for possible errors in newly added input
final possibleError = await validator(input);
if (possibleError != null) {
print(possibleError);
} else {
vmService.reloadSources(isolateId);
print('reloaded');
}
} else if (isExpression(input)) {
final result = await vmService.evaluate(
isolateId, isolate.rootLib?.id ?? '', input);
if (result is InstanceRef) {
final value = result.valueAsString;
if (value != null) {
print(value);
}
} else if (result is ErrorRef) {
print('error: $result');
} else {
print('unknown error');
}
} else {
print('not recognised: $input');
}
}
} on Exception catch (errorRef) {
print(errorRef);
}
}