Skip to content
This repository was archived by the owner on Jul 15, 2023. It is now read-only.
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
6 changes: 4 additions & 2 deletions src/goDeclaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ function definitionLocation_godef(input: GoDefinitionInput, token: vscode.Cancel
if (!input.includeDocs || godefImportDefinitionRegex.test(definitionInformation.declarationlines[0])) {
return resolve(definitionInformation);
}
runGodoc(pkgPath, input.word, token).then(doc => {
// TODO #2107 Once godef supports printing method receivers we should pass
// the receiver to runGodoc
runGodoc(pkgPath, '', input.word, token).then(doc => {
if (doc) {
definitionInformation.doc = doc;
}
Expand Down Expand Up @@ -305,4 +307,4 @@ interface GoGetDocOuput {
interface GuruDefinitionOuput {
objpos: string;
desc: string;
}
}
5 changes: 4 additions & 1 deletion src/goSuggest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ interface GoCodeSuggestion {
package?: string;
name: string;
type: string;
receiver?: string;
}

class ExtendedCompletionItem extends vscode.CompletionItem {
package?: string;
receiver?: string;
fileName: string;
}

Expand Down Expand Up @@ -94,7 +96,7 @@ export class GoCompletionItemProvider implements vscode.CompletionItemProvider,
return;
}

return runGodoc(item.package || path.dirname(item.fileName), item.label, token).then(doc => {
return runGodoc(item.package || path.dirname(item.fileName), item.receiver, item.label, token).then(doc => {
item.documentation = new vscode.MarkdownString(doc);
return item;
}).catch(err => {
Expand Down Expand Up @@ -283,6 +285,7 @@ export class GoCompletionItemProvider implements vscode.CompletionItemProvider,
let item = new ExtendedCompletionItem(suggest.name);
item.kind = vscodeKindFromGoCodeClass(suggest.class, suggest.type);
item.package = suggest.package;
item.receiver = suggest.receiver;
item.fileName = document.fileName;
item.detail = suggest.type;
if (suggest.class === 'package') {
Expand Down
7 changes: 6 additions & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ export function cleanupTempDir() {
* @param symbol Symbol for which docs need to be found
* @param token Cancellation token
*/
export function runGodoc(packagePath: string, symbol: string, token: vscode.CancellationToken) {
export function runGodoc(packagePath: string, receiver: string, symbol: string, token: vscode.CancellationToken) {
if (!packagePath) {
return Promise.reject(new Error('Package Path not provided'));
}
Expand All @@ -908,6 +908,11 @@ export function runGodoc(packagePath: string, symbol: string, token: vscode.Canc
const getCurrentPackagePromise = path.isAbsolute(packagePath) ? getCurrentPackage(packagePath) : Promise.resolve(packagePath);
return getCurrentPackagePromise.then(packageImportPath => {
return new Promise<string>((resolve, reject) => {
if (receiver) {
receiver = receiver.replace(/^\*/, '');
symbol = receiver + '.' + symbol;
}

const env = getToolsEnvVars();
const args = ['doc', '-c', '-cmd', '-u', packageImportPath, symbol];
const p = cp.execFile(goRuntimePath, args, { env }, (err, stdout, stderr) => {
Expand Down