Description
I want to replace vscode-go's existing DocumentSymbolsProvider
with gopls
.
The extension currently uses the go-outline
tool to extract the document symbol information
and uses it for various purposes (creating codelenses, generate test functions, call other tools, etc).
Even though I think most of them will be eventually replaced with gopls
and the extension itself
does not have to retrieve the information directly, I still think it's useful for the extension to access
the info, and possibly relay the info to other extensions (e.g. golang/vscode-go#404)
Looking into gopls
's responses and implementation, it looks like the response currently
includes functions and variables declarations.
The existing vscode-go provider provides imported package names. The names are used
when checking the file depends on a package of interest - e.g. whether the test file imports
a popular test framework?
Not sure how the LSP's symbol kinds map to Go's type. For reference -
he following is the currently used mapping by vscode-go's existing symbol provider.
const goKindToCodeKind: { [key: string]: vscode.SymbolKind } = {
package: vscode.SymbolKind.Package,
import: vscode.SymbolKind.Namespace,
variable: vscode.SymbolKind.Variable,
constant: vscode.SymbolKind.Constant,
type: vscode.SymbolKind.TypeParameter,
function: vscode.SymbolKind.Function,
struct: vscode.SymbolKind.Struct,
interface: vscode.SymbolKind.Interface
};