Skip to content

Commit 1b300c4

Browse files
committed
extension/src: change function doc using JSDoc
Also update a outdated link in docs/advance.md. For #3697 Change-Id: I4e4b2cf7def757367d9ca02b51a8d16811cb0734 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/660055 Reviewed-by: Madeline Kalil <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> kokoro-CI: kokoro <[email protected]>
1 parent 77a4fdb commit 1b300c4

File tree

2 files changed

+47
-22
lines changed

2 files changed

+47
-22
lines changed

docs/advanced.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ name.
6363

6464
The extension uses pinned versions of command-line tools. See the pinned versions
6565
in tools information
66-
[here](https://github.com/golang/vscode-go/blob/master/src/goToolsInformation.ts).
66+
[here](https://github.com/golang/vscode-go/blob/master/extension/src/goToolsInformation.ts).
6767
To use an alternate version of a tool install it manually with with go install.
6868

6969
## Using a custom linter

extension/src/goInstallTools.ts

Lines changed: 46 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,19 @@ import { allToolsInformation } from './goToolsInformation';
4444

4545
const STATUS_BAR_ITEM_NAME = 'Go Tools';
4646

47-
// minimum go version required for tools installation.
47+
/**
48+
* Minimum go version required for tools installation.
49+
*/
4850
const MINIMUM_GO_VERSION = '1.21.0';
4951

50-
// declinedUpdates tracks the tools that the user has declined to update.
52+
/**
53+
* Tracks the tools that the user has declined to update.
54+
*/
5155
const declinedUpdates: Tool[] = [];
5256

53-
// declinedUpdates tracks the tools that the user has declined to install.
57+
/**
58+
* Tracks the tools that the user has declined to install.
59+
*/
5460
const declinedInstalls: Tool[] = [];
5561

5662
export interface IToolsManager {
@@ -107,10 +113,11 @@ export async function installAllTools(updateExistingToolsOnly = false) {
107113
goVersion
108114
);
109115
}
110-
111-
// Returns the go version to be used for tools installation.
112-
// If `go.toolsManagement.go` is set, it is preferred. Otherwise, the provided
113-
// goVersion or the default version returned by getGoVersion is returned.
116+
/**
117+
* Returns the go version to be used for tools installation.
118+
* If `go.toolsManagement.go` is set, it is preferred. Otherwise, the provided
119+
* goVersion or the default version returned by getGoVersion is returned.
120+
*/
114121
export const getGoVersionForInstall = _getGoVersionForInstall;
115122
async function _getGoVersionForInstall(goVersion?: GoVersion): Promise<GoVersion | undefined> {
116123
let configuredGoForInstall = getGoConfig().get<string>('toolsManagement.go');
@@ -282,8 +289,10 @@ async function tmpDirForToolInstallation() {
282289
return toolsTmpDir;
283290
}
284291

285-
// installTool is used by goEnvironmentStatus.ts.
286-
// TODO(hyangah): replace the callsite to use defaultToolsManager and remove this.
292+
/**
293+
* installTool is used by goEnvironmentStatus.ts.
294+
* TODO(hyangah): replace the callsite to use defaultToolsManager and remove this.
295+
*/
287296
export async function installTool(tool: ToolAtVersion): Promise<string | undefined> {
288297
const goVersionForInstall = await getGoVersionForInstall();
289298
if (!goVersionForInstall) {
@@ -553,9 +562,11 @@ export function updateGoVarsFromConfig(goCtx: GoExtensionContext): Promise<void>
553562
});
554563
}
555564

556-
// maybeInstallImportantTools checks whether important tools are installed
557-
// and they meet the version requirement.
558-
// Then it tries to auto-install them if missing.
565+
/**
566+
* Checks whether important tools are installed and they meet the version
567+
* requirement.
568+
* Then it tries to auto-install them if missing.
569+
*/
559570
export async function maybeInstallImportantTools(
560571
alternateTools: { [key: string]: string } | undefined,
561572
tm: IToolsManager = defaultToolsManager
@@ -648,8 +659,10 @@ async function updateImportantToolsStatus(tm: IToolsManager = defaultToolsManage
648659
}
649660
}
650661

651-
// getMissingTools returns missing tools.
652-
// If matcher is provided, only the tools that match the filter will be checked.
662+
/**
663+
* Returns missing tools.
664+
* If matcher is provided, only the tools that match the filter will be checked.
665+
*/
653666
function getMissingTools(matcher?: (value: Tool) => boolean): Promise<Tool[]> {
654667
let keys = getConfiguredTools(getGoConfig(), getGoplsConfig());
655668
if (matcher) {
@@ -688,13 +701,17 @@ async function suggestDownloadGo() {
688701
suggestedDownloadGo = true;
689702
}
690703

691-
// ListVersionsOutput is the output of `go list -m -versions -json`.
704+
/**
705+
* The output of `go list -m -versions -json`.
706+
*/
692707
interface ListVersionsOutput {
693708
Version: string; // module version
694709
Versions?: string[]; // available module versions (with -versions)
695710
}
696711

697-
// latestToolVersion returns the latest version of the tool.
712+
/**
713+
* Returns the latest version of the tool.
714+
*/
698715
export async function latestToolVersion(tool: Tool, includePrerelease?: boolean): Promise<semver.SemVer | null> {
699716
const goCmd = getBinPath('go');
700717
const tmpDir = await tmpDirForToolInstallation();
@@ -729,8 +746,10 @@ export async function latestToolVersion(tool: Tool, includePrerelease?: boolean)
729746
return ret;
730747
}
731748

732-
// inspectGoToolVersion reads the go version and module version
733-
// of the given go tool using `go version -m` command.
749+
/**
750+
* Reads the go version and module version of the given go tool using
751+
* `go version -m` command.
752+
*/
734753
export const inspectGoToolVersion = defaultInspectGoToolVersion;
735754
async function defaultInspectGoToolVersion(
736755
binPath: string
@@ -803,6 +822,10 @@ export async function shouldUpdateTool(tool: Tool, toolPath: string): Promise<bo
803822
// tool.latestVersion is released when checkForUpdates === 'proxy'
804823
}
805824

825+
/**
826+
* Updates outdated Go tools, prompting for approval if user setting
827+
* `go.toolsManagement.autoUpdate` is unset or disabled.
828+
*/
806829
export async function suggestUpdates() {
807830
const configuredGoVersion = await getGoVersionForInstall();
808831
if (!configuredGoVersion || configuredGoVersion.lt(MINIMUM_GO_VERSION)) {
@@ -895,9 +918,11 @@ export async function listOutdatedTools(configuredGoVersion: GoVersion | undefin
895918
return oldTools.filter((tool): tool is Tool => !!tool);
896919
}
897920

898-
// maybeInstallVSCGO is a special program released and installed with the Go extension.
899-
// Unlike other tools, it is installed under the extension path (which is cleared
900-
// when a new version is installed).
921+
/**
922+
* VSCGO is a special program released and installed with the Go extension.
923+
* Unlike other tools, it is installed under the extension path
924+
* (which is cleared when a new version is installed).
925+
*/
901926
export async function maybeInstallVSCGO(
902927
extensionMode: vscode.ExtensionMode,
903928
extensionId: string,

0 commit comments

Comments
 (0)