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

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
sunliver committed Dec 27, 2018
1 parent 52951e6 commit 9707de9
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 36 deletions.
6 changes: 3 additions & 3 deletions src/goDeclaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export function definitionLocation(document: vscode.TextDocument, position: vsco
position,
word,
includeDocs,
isMod: modPath != "",
isMod: modPath !== '',
modPath,
};
if (toolForDocs === 'godoc' || (ver && (ver.major < 1 || (ver.major === 1 && ver.minor < 6)))) {
Expand Down Expand Up @@ -94,9 +94,9 @@ function definitionLocation_godef(input: GoDefinitionInput, token: vscode.Cancel
token.onCancellationRequested(() => killProcess(p));
}

let cwd: string
let cwd: string;
if (input.isMod) {
cwd = input.modPath
cwd = input.modPath;
} else {
cwd = getWorkspaceFolderPath(input.document.uri);
}
Expand Down
66 changes: 33 additions & 33 deletions src/goModules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,75 +10,75 @@ const folderModCache = new Map<string, string>();

export function isModSupported(fileuri: vscode.Uri): Promise<boolean> {
return getModPath(fileuri).then(modPath => {
return modPath != ""
})
return modPath !== '';
});
}

export function getModPath(fileuri: vscode.Uri): Promise<string> {
const folderPath = path.dirname(fileuri.fsPath)
const folderPath = path.dirname(fileuri.fsPath);

const hit = folderModCache.get(folderPath)
if (hit != undefined) {
return Promise.resolve(hit)
const hit = folderModCache.get(folderPath);
if (hit !== undefined) {
return Promise.resolve(hit);
}

workspaceModCache.forEach((v, k) => {
if (folderPath.startsWith(k)) {
folderModCache.set(folderPath, k)
return Promise.resolve(k)
folderModCache.set(folderPath, k);
return Promise.resolve(k);
}
})
});

return getGoVersion().then(value => {
if (value && (value.major !== 1 || value.minor < 11)) {
folderModCache.set(folderPath, "")
return ""
folderModCache.set(folderPath, '');
return '';
}

return new Promise<string>(resolve => {
let goExecutable = getBinPath('go')
let goExecutable = getBinPath('go');
if (!goExecutable) {
return Promise.reject(new Error('Cannot find "go" binary. Update PATH or GOROOT appropriately.'))
return Promise.reject(new Error('Cannot find "go" binary. Update PATH or GOROOT appropriately.'));
}
cp.execFile(goExecutable, ['env', 'GOMOD'], { cwd: folderPath, env: getToolsEnvVars() }, (err, stdout) => {
if (err) {
console.warn(`Error when running go env GOMOD: ${err}`)
resolve("")
console.warn(`Error when running go env GOMOD: ${err}`);
resolve('');
}
let [goMod] = stdout.split('\n')
resolve(goMod)
let [goMod] = stdout.split('\n');
resolve(goMod);
});
}).then(result => {
let modPath: string
if (result != "") {
const goConfig = vscode.workspace.getConfiguration('go', fileuri)
let modPath: string;
if (result !== '') {
const goConfig = vscode.workspace.getConfiguration('go', fileuri);
if (goConfig['inferGopath'] === true) {
goConfig.update('inferGopath', false, vscode.ConfigurationTarget.WorkspaceFolder)
alertDisablingInferGopath()
goConfig.update('inferGopath', false, vscode.ConfigurationTarget.WorkspaceFolder);
alertDisablingInferGopath();
}
logModuleUsage(true)
modPath = path.dirname(result)
workspaceModCache.set(modPath, true)
logModuleUsage(true);
modPath = path.dirname(result);
workspaceModCache.set(modPath, true);
} else {
modPath = ""
modPath = '';
}

folderModCache.set(folderPath, modPath)
return modPath
})
folderModCache.set(folderPath, modPath);
return modPath;
});
}).catch(() => {
return ""
})
return '';
});
}

export function updateWorkspaceModCache() {
if (!vscode.workspace.workspaceFolders) {
return;
}
const promises = vscode.workspace.workspaceFolders.map(folder => {
return getModPath(folder.uri)
return getModPath(folder.uri);
});
Promise.all(promises)
Promise.all(promises);
}

function alertDisablingInferGopath() {
Expand Down

0 comments on commit 9707de9

Please sign in to comment.