-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Add Inline value provider api for debugging #43449
Comments
A few notes from our discussion: Should this command really live in TS core?Pros:
Cons:
Could TS implement a more generic API instead?Instead of offering an Some existing apis that are similar:
Could we implement this with a TS Server plugin?Potentially, and this would also potentially make it easier for the VS Code team to maintain However there is currently no way to add a new command through a plugin. Could we repurpose an existing command instead? |
@connor4312 The TS team is interested in supporting this feature, but understandably would like to avoid maintaining an API whose expected behavior is tied so closely to the debugger This leaves a few options:
The language service plugin seems like it may be the most interesting, although we'd potentially need to do some work on the TS side to support a new command from a plugin |
Allowing plugins to enable new commands should be doable if we can pass |
The evaluatable expression provider is vaguely similar in that it is a debugger behavior that's driven by language semantics. Though VS Code has a built-in provider that has good enough heuristics for C-style language like J/TS. I don't have enough knowledge around the architecture of language servers and services to be able to provide an architectural recommendation. |
@mjbvz you said:
This would be my preferred approach. Most likely this API could be used for solving a similar set of problems that we have for the debug hover (where our current heuristics is not able to resolve variables to the correct scope). The "evaluatable expression provider" is basically a twin to the "Inline values provider" and could solve the problems by using the same language server APIs. |
@mjbvz what is the status of this feature request? |
@weinand We are currently late in the TS 4.3 release so I think this would have be scheduled for TS 4.4, which I believe would start development in May and be released in July @RyanCavanaugh / @DanielRosenwasser It would make more sense for @weinand to talk to someone on the TS team directly instead of going through me. Who would be the best point of contact on the TS team for @weinand to work with on this feature? |
I am also happy to be involved in development here. |
I'd say me and @minestarks, but ideally we'd just have the discussion at the weekly editor sync. |
Happy to work on this. |
Following up on our discussion:
Work items:
@Kingwl Thanks for offering to help! Once we have started writing the plugin itself, check with @connor4312 to see if he could use your help |
That's very helpful! PLUS: I have tried about a plugin to support Inline hints preview. But I realize we need new command support. |
Here's a simple try on the plugin API. And I'm tried integrating with the I have some confuse: Are there any way to communicate with tsserver in another custom extension? rather than the |
@Kingwl The "InlayHints" API is not what should be used for the debugger Inline Values feature. And the implementation of the "InlineValuesProvider" for TypeScript will live in the typescript-language-features extension (because I don't think that there is a way to communicate with tsserver in another extension). |
@Kingwl you can just use this extension as a starting point: |
@weinand Ahhhh yep. I'm not trying about inline value api but the tsserver's custom protocol handler... |
If so, the ts plugin & tsserver 's custom protocol handler will be very limited.(might only useful to the devs for typescript-language-features. As I said, you have to fork your tsserver process. Which means you cannot use the one who has been used by editor. |
@Kingwl I do not understand this:
The "InlineValueProvider" will not be part of the debugger extension but will live in the same language extension that is used by the editor. The whole idea of this effort is to avoid forking the tsserver process but reusing the tsserver that's already running. |
Yep. I know that. Actually I'm not talking about the inlineValueProvider. My point is the ts plugin & tsserver 's extensibility what will be a part of this feature(If i'm correct): If we allows the ts plugin provide their own commands, we should also could use these commands in any extensions rather than the only one builtin extension. |
I am not sure what you mean.. the plugins are suppose to use |
Well. Sorry for the confused. I mean currently If I'd like to extend some whole feature (e.g. Some vscode feature who Unfortunately, seems it's not possible to reuse the tsserver who used by I'm looking forward to there's something like 'a plugin of vscode built-in typescript extension'. Or the built-in extension provide some commands kind of |
We discussed this again within the team. One concern is that it's not clear to us how inline values are leveraged by the editor and debugger, so it's hard for us to evaluate an implementation here. We don't know what kinds of implementation issues we might run into, and what constraints the debugger has. We also feel like the behavior might change over time, so we have some concerns over whether or not we should provide this as a public part of TSServer initially. Let's discuss these again at the next editor sync if you're all open to it. |
Can you forward me an invite? My alias is copeet. @weinand may also be interested. Thanks! |
My mental model for this feature request is still what was summarised by @mjbvz in #43449 (comment): We are not asking for an Inline value API from TypeScript, but instead we (VS Code) want to implement an "Inline value provider" in VS Code's TypeScript extension. This "Inline value provider" will do things like: find all interesting variables in a given source line. But in order to do so, we need access to the TypeScript AST. Since there is no direct TS AST API available, we would like to implement the "Inline value provider" (or some part of it) as a "TS language service plugin" and the VS Code TypeScript extension needs a way to communicate with the "TS language service plugin". With this approach an "Inline value provider" is not a public part of the TSServer, but it is private code of the VS Code TypeScript extension that gets injected into the TSServer at runtime. Any concerns about "how inline values are leveraged by the editor and debugger" or "what constraints the debugger has" are addressed in the TypeScript extension, and not in the TSServer. |
It would be really nice if this issue could be solved by addressing this more general issue about enabling VS Code extensions to call into third party TypeScript extensions. |
From microsoft/vscode#119489
Background
The new inline value api for VS Code lets language extensions tell the debugger which values should be shown directly in a file while debugging. Without this API, VS Code uses a generic method for determining which values to show. This ends up showing many irrelevant values to the user
See microsoft/vscode#119489 for an example of this
Feature Request
We'd like to use the TypeScript server's language smarts to implement the VS Code inline value api so that only relevant values are shown.
Here's a potential shape of the API based on the vscode inline value API
Behavior
Some notes on how the inline value provider should work (copied from @connor4312):
The debugger should handle source maps, so the provider should only have to worry about the requested file
Inline values should only be provided in the current and parent scopes
Declarations and assignments assignments should evaluate the declared or assigned expression,
bar
inbar = foo()
orfoo
infunction foo() {}
Conditional expressions (ternary or
if
statements) should evaluate the conditional and none of its children,!foo && bar
inif (!foo && bar)
Property assignments should be evaluated,
foo()
in{ x: foo() }
Here's a small example of some inline values:
@connor4312 Is handling this on the VS Code side and should be able to answer any questions regarding this API
/cc @weinand
The text was updated successfully, but these errors were encountered: