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

Commit

Permalink
Review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
segevfiner committed Jan 9, 2019
1 parent e2ec688 commit 11df4b5
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/goDeclaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export function adjustWordPosition(document: vscode.TextDocument, position: vsco
}

const godefImportDefinitionRegex = /^import \(.* ".*"\)$/;
function definitionLocation_godef(input: GoDefinitionInput, token: vscode.CancellationToken): Promise<GoDefinitionInformation> {
function definitionLocation_godef(input: GoDefinitionInput, token: vscode.CancellationToken, useReceivers: boolean = true): Promise<GoDefinitionInformation> {
let godefTool = input.isMod ? 'godef-gomod' : 'godef';
let godefPath = getBinPath(godefTool);
if (!path.isAbsolute(godefPath)) {
Expand All @@ -95,7 +95,11 @@ function definitionLocation_godef(input: GoDefinitionInput, token: vscode.Cancel

return new Promise<GoDefinitionInformation>((resolve, reject) => {
// Spawn `godef` process
p = cp.execFile(godefPath, ['-t', '-r', '-i', '-f', input.document.fileName, '-o', offset.toString()], { env, cwd }, (err, stdout, stderr) => {
const args = ['-t', '-i', '-f', input.document.fileName, '-o', offset.toString()];
if (useReceivers) {
args.push('-r');
}
p = cp.execFile(godefPath, args, { env, cwd }, (err, stdout, stderr) => {
try {
if (err && (<any>err).code === 'ENOENT') {
return reject(missingToolMsg + godefTool);
Expand All @@ -104,7 +108,8 @@ function definitionLocation_godef(input: GoDefinitionInput, token: vscode.Cancel
if (stderr.indexOf('flag provided but not defined: -r') !== -1) {
promptForUpdatingTool('godef');
}
return reject(err.message || stderr);
p = null;
return definitionLocation_godef(input, token, false).then(resolve, reject);
}
let result = stdout.toString();
let lines = result.split('\n');
Expand Down Expand Up @@ -173,7 +178,7 @@ function definitionLocation_gogetdoc(input: GoDefinitionInput, token: vscode.Can
}
if (stderr && stderr.startsWith('flag provided but not defined: -tags')) {
p = null;
return definitionLocation_gogetdoc(input, token, false);
return definitionLocation_gogetdoc(input, token, false).then(resolve, reject);
}
if (err) {
if (input.isMod
Expand Down

0 comments on commit 11df4b5

Please sign in to comment.