How to add elements to Outline panel in custom extension?

被刻印的时光 ゝ 提交于 2019-12-13 12:32:23

问题


I have a VS Code extension for ST language support. Right now it provides only syntax highlights and some snippets. I wanted to create a tree structure of the document showing programs, functions and their parameters in the Outline panel. But I cannot find an example of how to do that.

Can you refer me to the right direction but not to LSP as it is too complicated for now I want to make it programmatically.


回答1:


The outline view is populated by a DocumentSymbolProvider (see also: registerDocumentSymbolProvider()). In the language server protocol, this corresponds to the textDocument/documentSymbol request.

All in all, it currently provides the data for all of these:

  • Outline view
  • Breadcrumbs
  • Go to Symbol in File

You can find an example implementation of one here, though you'll want it to return DocumentSymbol rather than SymbolInformation instances. Only the former supports the hierarchy needed for the outline view via it's children property.



来源:https://stackoverflow.com/questions/57131265/how-to-add-elements-to-outline-panel-in-custom-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!