Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Ignore import statements in Go to Symbol in File feature #775

Merged
merged 2 commits into from
Feb 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 40 additions & 35 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@
"default": [],
"description": "Flags to `go build`/`go test` used during build-on-save or running tests. (e.g. ['-ldflags=\"-s\"'])"
},
"go.buildTags": {
"type": "string",
"default": "",
"description": "The Go build tags to use for all commands that support a `-tags '...'` argument"
},
"go.lintOnSave": {
"type": "boolean",
"default": true,
Expand Down Expand Up @@ -311,6 +316,11 @@
"default": [],
"description": "Flags to pass to `go tool vet` (e.g. ['-all', '-shadow'])"
},
"go.formatOnSave": {
"type": "boolean",
"default": true,
"description": "Runs formatting tool on save."
},
"go.formatTool": {
"type": "string",
"default": "goreturns",
Expand All @@ -334,11 +344,6 @@
"default": true,
"description": "Run the formatting tools with the -d flag"
},
"go.useCodeSnippetsOnFunctionSuggest": {
"type": "boolean",
"default": false,
"description": "Complete functions with their parameter signature"
},
"go.inferGopath": {
"type": "boolean",
"default": false,
Expand All @@ -351,6 +356,11 @@
],
"default": null,
"description": "Specifies the GOPATH to use when no environment variable is set. The inferred GOPATH from workspace root overrides this, if go.inferGopath is set to true."
},
"go.toolsGopath": {
"type": "string",
"default": "",
"description": "Location to install the Go tools that the extension depends on if you don't want them in your GOPATH."
},
"go.goroot": {
"type": [
Expand All @@ -360,11 +370,6 @@
"default": null,
"description": "Specifies the GOROOT to use when no environment variable is set."
},
"go.formatOnSave": {
"type": "boolean",
"default": true,
"description": "Runs formatting tool on save."
},
"go.coverOnSave": {
"type": "boolean",
"default": false,
Expand All @@ -375,20 +380,31 @@
"default": "30s",
"description": "Specifies the timeout for go test in ParseDuration format."
},
"go.testEnvVars": {
"type": "object",
"default": {},
"description": "Environment variables that will passed to the process that runs the Go tests"
},
"go.testFlags": {
"type": [
"array",
"null"
],
"items": {
"type": "string"
},
"default": null,
"description": "Flags to pass to `go test`. If null, then buildFlags will be used."
},
"go.gocodeAutoBuild": {
"type": "boolean",
"default": true,
"description": "Enable gocode's autobuild feature"
},
"go.buildTags": {
"type": "string",
"default": "",
"description": "The Go build tags to use for all commands that support a `-tags '...'` argument"
},
"go.testEnvVars": {
"type": "object",
"default": {},
"description": "Environment variables that will passed to the process that runs the Go tests"
"go.useCodeSnippetsOnFunctionSuggest": {
"type": "boolean",
"default": false,
"description": "Complete functions with their parameter signature"
},
"go.autocompleteUnimportedPackages": {
"type": "boolean",
Expand All @@ -404,26 +420,15 @@
"gogetdoc"
]
},
"go.toolsGopath": {
"type": "string",
"default": "",
"description": "Location to install the Go tools that the extension depends on if you don't want them in your GOPATH."
},
"go.testFlags": {
"type": [
"array",
"null"
],
"items": {
"type": "string"
},
"default": null,
"description": "Flags to pass to `go test`. If null, then buildFlags will be used."
},
"go.useLanguageServer": {
"type": "boolean",
"default": false,
"description": "Experimental: Not available in Windows. Use Go language server from Sourcegraph for Hover, Definition, Find All References, Signature Help, File Outline and Workspace Symbol features"
},
"go.gotoSymbol.includeImports": {
"type": "boolean",
"default": false,
"description": "If false, the import statements will be excluded while using the Go to Symbol in File feature"
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/goOutline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import vscode = require('vscode');
import cp = require('child_process');
import path = require('path');
import { getBinPath } from './util';
import { getBinPath, sendTelemetryEvent } from './util';
import { promptForMissingTool, promptForUpdatingTool } from './goInstallTools';

// Keep in sync with https://github.com/lukehoban/go-outline
Expand Down Expand Up @@ -76,7 +76,11 @@ export class GoDocumentSymbolProvider implements vscode.DocumentSymbolProvider {
};

private convertToCodeSymbols(document: vscode.TextDocument, decls: GoOutlineDeclaration[], symbols: vscode.SymbolInformation[], containerName: string): void {
let gotoSymbolConfig = vscode.workspace.getConfiguration('go')['gotoSymbol'];
let includeImports = gotoSymbolConfig ? gotoSymbolConfig['includeImports'] : false;
sendTelemetryEvent('file-symbols', { includeImports });
decls.forEach(decl => {
if (!includeImports && decl.type === 'import') return;
let label = decl.label;
if (decl.receiverType) {
label = '(' + decl.receiverType + ').' + label;
Expand Down