vscode-go icon indicating copy to clipboard operation
vscode-go copied to clipboard

glob filter for `implementation` and `reference`

Open 7sunarni opened this issue 9 months ago • 1 comments

Is your feature request related to a problem? Please describe. Sometimes, when we want to find one function had been used in somewhere, we may found there are lots of reference in some test files or some mock files.

Usually, we may skip this references when we view the popup window.

And this is same like to do some search in the vscode global search bar, and there we can config files to include and/or files to exclude to filter out some files we don't care.

Image

I just think if the extension can do same filter in find references, it will save much time when the project is huge.

Describe the solution you'd like

I migrated the vscode glob implementation code so the extension can behave to the vscode search glob. Then I added some filters in the reference and implementation function. And I shared my extension to my workmates, I think this actually make us easier to work in huge project(we need to check the Kubernetes code)

and this is my settings

{
...
    "go.implementation": {
        "filesExclude":"{**/fake/**,**/*_test.go,**/testing/**}",
    },
    "go.reference": {
        "filesExclude":"{**/fake/**,**/*_test.go,**/testing/**,**/test/**}",
    },
...
}

Describe alternatives you've considered If the gopls have some options to do filter, it would may be better and easy.

Additional context vscode glob implementation doesn't export to its extension library. This may dependent on that.

7sunarni avatar Mar 06 '25 02:03 7sunarni

cc @findleyr @adonovan

This remind me of another feature request to re-arranging code actions returned from gopls. Maybe some grammar similar to the glob expression in DirectoryFilters where users can exclude certain patterns.

Or deprioritizing references found in _test.go or */testdata/*

h9jiang avatar Mar 06 '25 18:03 h9jiang