-
Notifications
You must be signed in to change notification settings - Fork 29.4k
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
Support global evaluation that requires a file for context #134452
Comments
@DanTup before trying to make a proposal for this feature, I need a better understanding of the envisioned scenarios that you want to address. I tried to make VS Code call the DAP What do you think should happen in this case? Allowing the user to select a file (to provide the eval context) would be possible, but sounds a bit specific. Above you mentioned that a "library" could be a context too. Allowing the user to select a library is even more specific to Dart. Just adding an optional Are you aware of more scenarios where VS Code (or any client in general) uses a "global eval"? |
I think @jacob314's original idea was that the DA could provide a list of arbitrary contexts that the user could select from (although I think generally a file is the most likely one).
I suspect that would probably work fine, and we'd probably just grab the active editor and use that (although it's not completely obvious to the user these things are linked, I think it would generally behave as they are just expecting). However, I'm not aware of a way we can use middleware to alter this request - is it possible? If not, I think supporting middleware for DAP would be a good generic solution to this without getting into the specifics of Dart.
I'm not - it was specifically the debug console users want to use here. For something like a Flutter app, the app is long-running and the user may work without execution pausing (for example they may make changes to the widgets in their code and hot-reload-on-save). They might want to evaluate some expressions in the context of the file they're editing without needing to hit a breakpoint or something (of course, they will be limited in what they can evaluate). |
@DanTup you asked:
Yes, in your extension you could register a |
If we do not want to take the
I prefer option 2 because I think option 1 is a bit of an overkill for a rare use case for which the If option 2 is not sufficient, we can easily add the |
@weinand this all sounds reasonable to me. Could/would the source file being passed in Looking at Dart's VM service docs again, I see we may also need to supply an isolate (thread) for the evaluation. I think we can just infer this for most cases (many apps probably only have one isolate), though might be something to consider allowing the user some control over in future. I'll chat with @jacob314 to make sure I fully understand how this works though (he's OOO atm, so won't be imminent) - though I don't think it's required to do the above. |
@weinand correct, the REPL Input and the Breakpoint widget input tie their syntax colouring to the active editor. The REPL tree does not use syntax colouring, thus the tree colouring itself does not depend on the active editor, only the REPL input. |
@DanTup I don't think that it is necessary to introduce an additional "context" object because the If Dart would need additional flexibility to pass an isolate (thread) for the evaluation, then this thread cannot be passed by the client (VS Code). It can only come from a Dart specific extension. For this we would need the |
Ah yes sorry, I had misread that you were adding the source as a
Understood. I think for now I could just handle it in the debug adapter (the original DAP does this, just picking the first isolate). If we need to allow selecting it we might need to come up with something else. I think Jacob's original idea might have been that the DA could provide some arbitrary list that could be shown next to the evaluation input box (eg. Dart could populate it with isolates, but the implementation could be generic) that would be passed back. I'm not sure how often there will be more than one relevant isolate though, so it's probably worth getting his input before trying to come up with a solution for that. |
@jacob314 it would be great if you could provide feedback for this proposal so that we can finalise this in January. |
@weinand Jacob is currently OOO (and I believe will be for the rest of Dec) |
@weinand I discussed with Jacob, and it sounds like selecting the thread in the DA will work for most common cases, but won't cover them all. It would definitely be better to handle those cases we can using the proposal above than not, so if supporting the remaining cases is more complex, I'd vote for doing the above initially. To support all cases correctly, we do need a threadId. If that's something other languages may also use for global evaluation, perhaps VS code could specifically allow selecting a thread? If not, allowing us to provide some arbitrary list (which in our case would be the list of threads) that the user can select would also work - although I'm not sure how this could be presented nicely in the UI. |
@DanTup thanks for the feedback - I'll continue with this request tomorrow. |
@DanTup @jacob314 how exactly would the user experience with a thread (or context) picker look like? E.g. like the following?
Pros and cons of this approach:
An alternative approach is to let the extension implement the context picker (instead of the DA).
Pros and cons of this approach:
My minimalistic proposal:
|
@weinand that sounds reasonable to us for now. Initially we'll just infer the isolate (as the current legacy DAP does) and then later extend it with a pick-list or something. It definitely would be nice to have something in the DAP spec rather than custom extension code (since we're trying to make the DAP more reusable by other editors), but perhaps it would be better to discuss that more when we have a working implementation via the extension (and also can see whether there are other languages that might have similar needs to try and keep things fairly general). Thanks! |
Is this something you're still considering? I'm passing a (we're also still interested in something like the |
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 <[email protected]> Reviewed-by: Ben Konyi <[email protected]>
Currently when evaluating expressions but not stopped at a breakpoint, no context is provided to the debug adapter. In the case of Dart, global evaluation can only be run in the context of a library/file.
It would be useful to have a way for the user to select a file, source, or perhaps some arbitrary context from a set provided by the DA that can be sent with global evaluation requests.
@isidorn @weinand @jacob314
The text was updated successfully, but these errors were encountered: