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

Commit

Permalink
Support multiple build tags #1355
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya-rao-a committed Nov 21, 2017
1 parent a8a68e2 commit 328c6e0
Show file tree
Hide file tree
Showing 8 changed files with 861 additions and 804 deletions.
2 changes: 1 addition & 1 deletion src/goBuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function goBuild(fileUri: vscode.Uri, goConfig: vscode.WorkspaceConfigura
buildArgs.push('-i', '-o', tmpPath, ...buildFlags);
if (goConfig['buildTags'] && buildFlags.indexOf('-tags') === -1) {
buildArgs.push('-tags');
buildArgs.push('"' + goConfig['buildTags'] + '"');
buildArgs.push(goConfig['buildTags']);
}

if (buildWorkspace && currentWorkspace && !isTestFile) {
Expand Down
2 changes: 1 addition & 1 deletion src/goDeclaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ function definitionLocation_gogetdoc(document: vscode.TextDocument, position: vs

let gogetdocFlagsWithoutTags = ['-u', '-json', '-modified', '-pos', document.fileName + ':#' + offset.toString()];
let buildTags = vscode.workspace.getConfiguration('go', document.uri)['buildTags'];
let gogetdocFlags = (buildTags && useTags) ? [...gogetdocFlagsWithoutTags, '-tags', '"' + buildTags + '"'] : gogetdocFlagsWithoutTags;
let gogetdocFlags = (buildTags && useTags) ? [...gogetdocFlagsWithoutTags, '-tags', buildTags] : gogetdocFlagsWithoutTags;
p = cp.execFile(gogetdoc, gogetdocFlags, { env }, (err, stdout, stderr) => {
try {
if (err && (<any>err).code === 'ENOENT') {
Expand Down
5 changes: 3 additions & 2 deletions src/goImplementations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ export class GoImplementationProvider implements vscode.ImplementationProvider {
let cwd = path.dirname(filename);
let offset = byteOffsetAt(document, position);
let goGuru = getBinPath('guru');
let buildTags = '"' + vscode.workspace.getConfiguration('go', document.uri)['buildTags'] + '"';
let args = ['-scope', `${scope}/...`, '-json', '-tags', buildTags, 'implements', `${filename}:#${offset.toString()}`];
const buildTags = vscode.workspace.getConfiguration('go', document.uri)['buildTags'];
let args = buildTags ? ['-tags', buildTags] : [];
args.push('-scope', `${scope}/...`, '-json', 'implements', `${filename}:#${offset.toString()}`);

let guruProcess = cp.execFile(goGuru, args, { env }, (err, stdout, stderr) => {
if (err && (<any>err).code === 'ENOENT') {
Expand Down
2 changes: 1 addition & 1 deletion src/goInstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function installCurrentPackage() {
const args = ['install', ...buildFlags];

if (goConfig['buildTags'] && buildFlags.indexOf('-tags') === -1) {
args.push('-tags', '"' + goConfig['buildTags'] + '"');
args.push('-tags', goConfig['buildTags']);
}

// Find the right importPath instead of directly using `.`. Fixes https://github.com/Microsoft/vscode-go/issues/846
Expand Down
6 changes: 4 additions & 2 deletions src/goReferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ export class GoReferenceProvider implements vscode.ReferenceProvider {
let cwd = path.dirname(filename);
let offset = byteOffsetAt(document, position);
let env = getToolsEnvVars();
let buildTags = '"' + vscode.workspace.getConfiguration('go', document.uri)['buildTags'] + '"';
let buildTags = vscode.workspace.getConfiguration('go', document.uri)['buildTags'];
let args = buildTags ? ['-tags', buildTags] : [];
args.push('-modified', 'referrers', `${filename}:#${offset.toString()}`);

let process = cp.execFile(goGuru, ['-modified', '-tags', buildTags, 'referrers', `${filename}:#${offset.toString()}`], { env }, (err, stdout, stderr) => {
let process = cp.execFile(goGuru, args, { env }, (err, stdout, stderr) => {
try {
if (err && (<any>err).code === 'ENOENT') {
promptForMissingTool('guru');
Expand Down
7 changes: 5 additions & 2 deletions src/goRename.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ export class GoRenameProvider implements vscode.RenameProvider {
let offset = byteOffsetAt(document, pos);
let env = getToolsEnvVars();
let gorename = getBinPath('gorename');
let buildTags = '"' + vscode.workspace.getConfiguration('go', document.uri)['buildTags'] + '"';
let gorenameArgs = ['-offset', filename + ':#' + offset, '-to', newName, '-tags', buildTags];
const buildTags = vscode.workspace.getConfiguration('go', document.uri)['buildTags'] ;
let gorenameArgs = ['-offset', filename + ':#' + offset, '-to', newName];
if (buildTags) {
gorenameArgs.push('-tags', buildTags);
}
let canRenameToolUseDiff = isDiffToolAvailable();
if (canRenameToolUseDiff) {
gorenameArgs.push('-d');
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/buildTags/hello.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// +build randomtag

package main

import "fmt"

func main() {
fmt.Prinln("hello")
}
1,632 changes: 837 additions & 795 deletions test/go.test.ts

Large diffs are not rendered by default.

0 comments on commit 328c6e0

Please sign in to comment.