Skip to content

Support global evaluation in SDK DAPs #4636

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

Closed
DanTup opened this issue Jul 10, 2023 · 2 comments
Closed

Support global evaluation in SDK DAPs #4636

DanTup opened this issue Jul 10, 2023 · 2 comments
Labels
in debugger Relates to the debug adapter or process of launching a debug session is bug
Milestone

Comments

@DanTup
Copy link
Member

DanTup commented Jul 10, 2023

In the old DAPs we supported some basic global evaluation using the root library and the first available isolate. We should support the same in the new SDK DAPs, but ideally use the current open file rather than the root library.

@DanTup DanTup added is bug in debugger Relates to the debug adapter or process of launching a debug session labels Jul 10, 2023
@DanTup DanTup added this to the v3.70.0 milestone Jul 10, 2023
@DanTup DanTup closed this as completed in 7389b2c Jul 11, 2023
copybara-service bot pushed a commit to dart-lang/sdk that referenced this issue Jul 11, 2023
This provides support for basic global evaluation matching the legacy DAPs. The first available thread is used (because there's currently no way for the user to select a thread) and we look up a library from a file URI provided in the `context` field.

In future I hope there's a standard DAP way of getting a file from the client (see microsoft/vscode#134452).

See #52574
See Dart-Code/Dart-Code#4636

Change-Id: I7bfa466001142e7e39ebb270ce65f4746a9affcd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312980
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
@jacob314
Copy link

jacob314 commented Aug 1, 2023

What will it take to support evaluating in the context of the library of the currently open file and/or adding some affordance in the UI to select the library to use?

@DanTup
Copy link
Member Author

DanTup commented Aug 1, 2023

What will it take to support evaluating in the context of the library of the currently open file

That's actually what we do :) The comment above didn't mention it, but we pass through the active file in the context (it's non-standard, but all we have for now):

if (message.command === "evaluate" && message.arguments?.context === "repl") {
const doc = getActiveRealFileEditor()?.document;
if (doc && isDartDocument(doc)) {
message.arguments.context = doc?.uri.toString();
}
}

And then in the debug adapter, we read this and find the relevant library for that script:

https://github.com/dart-lang/sdk/blob/80a6670d5d081bf6542036979791a8f666adfc1d/pkg/dds/lib/src/dap/adapters/dart.dart#L975

There's no UI to allow you to select, it just uses the current file. We could change this, although I don't know how nice the UI would be - but you can always open a specific file if you want to use that library.

What we don't support though is a way to choose the isolate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in debugger Relates to the debug adapter or process of launching a debug session is bug
Projects
None yet
Development

No branches or pull requests

2 participants