Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typing the name of a variable / function will now print its value ins… #48

Merged
merged 1 commit into from
Oct 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/interactive/lib/src/executor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,12 @@ class Executor {
log.info('Phase: Evaluate');
final isolateInfo = await workspaceIsolate.isolateInfo;
final targetId = isolateInfo.rootLib!.id!;
final response = await vm.vmService
Response response = await vm.vmService
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and making it using the original keyword final again

.evaluate(workspaceIsolate.isolateId, targetId, _evaluateCode);

if(response is InstanceRef && response.valueAsString == null) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And please add a test in e2e_test.dart, which is quite simple - just provide some inputs and assert outputs

// InstanceRef.valueAsString only works on primitive values like String, int, double ETC, so for anything else we have to ask the VM to get the toString value
response = await vm.vmService.evaluate(workspaceIsolate.isolateId, response.id!, "this.toString()");
}
Comment on lines +88 to +91
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about putting this inside _handleEvaluateResponse

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about putting this inside _handleEvaluateResponse

I was doing that at first, but then I saw that it would require complicating the function and making it asynchronous. But now I wonder if we can append a .toString() call directly to the end of the autogenerated method to simplify this. That second response we're sending is probably slowing things down a little.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! Feel free to PR that

That second response we're sending is probably slowing things down a little.

btw do you feel it in real usage or is it a theoretical thinking?

_handleEvaluateResponse(response);
}

Expand Down