-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
Unexpected return type of vscode.executeFormatDocumentProvider
and vscode.executeDocumentSymbolProvider
#769
Comments
Another example is |
@lukehoban @ironcladlou I know @jrieken is working on a solution for this. Extensions should never get to see the 1-based format (that is the format that reaches the main process). For now, please don't write code depending / working around these wrong return values as we plan to fix them. |
Are you implying these commands should be "private" or unstable? What is the supported API to get the symbols for a document by URI? |
@ironcladlou I think the supported way would be to factor out the symbol collection code from the |
My understanding is that multiple providers can be registered for a given document selector; Code then merges the results to feed the rest of the IDE (via private APIs?) Seems to me that extensions would benefit from exported API access to the merged/processed symbols the IDE already collected from all extensions. I also wouldn't be surprised if the processed provider results were also cached internally, etc for performance, stuff we wouldn't want to duplicate. Coupling the vscode-go functionality to its own single provider's implementation would probably work, but seems a little less than ideal based on the above. Thoughts? |
Good point. I was more commenting on what should be done for |
I think there are valid use-cases for both scenarios, using commands and using extension api. For instance, the command-approach you can use to make UI extensions, like hover-information showing in the status bar: 1. listen to selection changes, 2. run command vscode.executeHoverProvider, 3. update status bar. Since by using the commands you don't decide which provider actually produces the data and since the commands and data types are defined by us you might need more. Think of a special code action that requires a syntax tree etc. To enable that an extension should export special APIs that are then consumed by dependent extensions. Wrt the commands we have pushed many changes to master which should make them accept and return the correct data types. Still, we have no figured out yet what the best way of documenting them is. We will track that in #913 |
@jrieken BTW - per microsoft/vscode-go#176, it appears that all calls to For the particular problem that was causing in the Go extension, we've changed the code to avoid using this command and just call Go's symbol provider directly, which is likely more correct in this case. |
@lukehoban We now check that calling the 'API commands' happens with the spec'd arguments, that would be |
It's nice that the implementations of
FormatDocumentProvider
andDocumentSymbolProvider
can be used viaexecuteCommand
. However, the return types are undocumented and subtely different from what the implementation side produces.executeCommand
on these commands? Or should they factor out their implementation and use the implementation code directly?For
FormatDocumentProvider
for example, I provide aTextEdit[]
which is:but
executeCommand("vscode.executeFormatDocumentProvider", ...)
receives this as:The combination of completely different shape plus the 1-based numbering makes this data difficult to work with.
Similarly different results are returned from others similar commands.
The text was updated successfully, but these errors were encountered: