Comments (6)
This is a Code feature which is not yet enabled in the Go plugin.
The interface that needs to be implemented is this one:
/**
* The workspace symbol provider interface defines the contract between extensions and
* the [symbol search](https://code.visualstudio.com/docs/editor/editingevolved#_open-symbol-by-name)-feature.
*/
export interface WorkspaceSymbolProvider {
/**
* Project-wide search for a symbol matching the given query string. It is up to the provider
* how to search given the query string, like substring, indexOf etc.
*
* @param query A non-empty query string.
* @param token A cancellation token.
* @return An array of document highlights or a thenable that resolves to such. The lack of a result can be
* signaled by returning `undefined`, `null`, or an empty array.
*/
provideWorkspaceSymbols(query: string, token: CancellationToken): SymbolInformation[] | Thenable<SymbolInformation[]>;
}
I'm sure that one of the Go tools can provide the information needed for this.
from vscode-go.
use @main
not #main
from vscode-go.
@shesuyo Yes - the @main
syntax uses the DocumentSymbolProivder
which finds symbols in the currently active document. The WorkspaceSymbolProvider
would make it possible to search symbols across the entire workspace.
from vscode-go.
Alan Donovan said with respect to this:
basically, if you want accurate type information for all symbols, you need to run the Go type checker, go/types (or the frontend of an existing Go compiler); anything else is at best a heuristic. The type checker can take input two ways: from source and from compiler export data. To load, parse, and type-check an entire program from source, you can use the golang.org/x/tools/go/loader package, but beware that for the next few months it will continue to use the similar but older golang.org/x/tools/go/types package instead of the standard type checker. If all you need is package-level symbols, the type checker can be run in a mode in which, for speed, it does not analyze function bodies. To load symbols from binary export data, you can use the go/importer package (or the older and slightly different versions in the x/tools repo).
Two caveats: First, files that import "C" are strictly speaking not Go source code as they require cgo preprocessing. The loader package does this, and go/types ingests the output of this preprocessing step. Second, some files are included in the build only on certain platforms or architectures, either because they contain //+build tags or because they have a file name like foo_linux.go, for example. All existing analysis tools essentially pick a single configuration (e.g. amd64 linux) and pretend the other files don't exist; this is a definite weak spot. An IDE may have to do better than this, but modifying go/types to type-check all configurations at once would be "non-trivial".
from vscode-go.
I realized that with my work on godef I have a mostly working implementation of this, so working this further :)
from vscode-go.
@newhook Great!
from vscode-go.
Related Issues (20)
- go.formatFlags not working with gofmt -s (simplify) HOT 5
- Couldn't start client gopls HOT 5
- Unable to run Go in VS Code - command not found HOT 4
- Adding a module using `go get` from outside vscode is not recognized until go.mod is reopened HOT 5
- Can not use VS code for GO: Installing github.com/go-delve/delve/cmd/dlv FAILED HOT 5
- Disable real-time syntax error highlighting with gopls HOT 1
- Problem in mouse hover tooltip HOT 3
- Automatically Infer Path Mapping for Remote Debugging
- // .*DO NOT EDIT.?$ HOT 6
- Extension issue HOT 1
- 0.14.2 broken on macos HOT 3
- Extension Repository Migration Plan HOT 1
- Region comments not working when extension is enabled HOT 3
- Debugging uses wrong working directory HOT 4
- Background of covered and not covered code cannot be removed after running package test HOT 9
- Extension Migration Plan HOT 4
- numeric constants containing underscore are not colored correctly HOT 1
- Gopls does not support versions of go <=1.12 HOT 2
- Unable to set breakpoint when using gutter and clear Code coverage HOT 3
- Updated to 0.14.3 or the nightly and entirely stopped working HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vscode-go.