Skip to content

Commit 02af254

Browse files
h9jianggopherbot
authored andcommitted
extension: replace logOutputChannel append/appendLine with info
The info() is the implementation of append(). The append() is the implementation of appendLine() with extra '\n'. Fixes #3359 Change-Id: I7e88e74bd50f810cc27a496b2bb66999b7b0ed5d Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/691635 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Hongxiang Jiang <hxjiang@golang.org> Commit-Queue: Hongxiang Jiang <hxjiang@golang.org> kokoro-CI: kokoro <noreply+kokoro@google.com> Reviewed-by: Madeline Kalil <mkalil@google.com>
1 parent 7fd8e3d commit 02af254

14 files changed

+55
-55
lines changed

extension/src/goBuild.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export async function goBuild(
127127
}
128128

129129
if (buildWorkspace && currentWorkspace && !isTestFile) {
130-
outputChannel.appendLine(`Starting building the current workspace at ${currentWorkspace}`);
130+
outputChannel.info(`Starting building the current workspace at ${currentWorkspace}`);
131131
return getNonVendorPackages(currentWorkspace).then((pkgs) => {
132132
running = true;
133133
return runTool(
@@ -146,7 +146,7 @@ export async function goBuild(
146146
});
147147
}
148148

149-
outputChannel.appendLine(`Starting building the current package at ${cwd}`);
149+
outputChannel.info(`Starting building the current package at ${cwd}`);
150150

151151
const currentGoWorkspace = getCurrentGoWorkspaceFromGOPATH(getCurrentGoPath(), cwd);
152152
let importPath = '.';

extension/src/goCheck.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export function check(
6161
goConfig: vscode.WorkspaceConfiguration
6262
): Promise<IToolCheckResults[]> {
6363
diagnosticsStatusBarItem.hide();
64-
outputChannel.appendLine('Running checks...');
64+
outputChannel.info('Running checks...');
6565
const runningToolsPromises = [];
6666
const cwd = path.dirname(fileUri.fsPath);
6767

extension/src/goEnvironmentStatus.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ async function downloadGo(goOption: GoEnvironmentOption): Promise<GoEnvironmentO
237237
location: vscode.ProgressLocation.Notification
238238
},
239239
async () => {
240-
outputChannel.appendLine(`go install ${goOption.binpath}@latest`);
240+
outputChannel.info(`go install ${goOption.binpath}@latest`);
241241
const result = await installTool({
242242
name: newExecutableName,
243243
importPath: goOption.binpath,
@@ -251,15 +251,15 @@ async function downloadGo(goOption: GoEnvironmentOption): Promise<GoEnvironmentO
251251
}
252252
// run `goX.X download`
253253
const goXExecutable = getBinPath(newExecutableName);
254-
outputChannel.appendLine(`${goXExecutable} download`);
254+
outputChannel.info(`${goXExecutable} download`);
255255
try {
256256
await execFile(goXExecutable, ['download']);
257257
} catch (downloadErr) {
258258
outputChannel.error(`Error finishing installation: ${downloadErr}`);
259259
throw new Error('Could not download Go version.');
260260
}
261261

262-
outputChannel.appendLine(`Checking newly downloaded ${goOption.label} SDK`);
262+
outputChannel.info(`Checking newly downloaded ${goOption.label} SDK`);
263263

264264
let sdkPath = '';
265265
try {
@@ -278,11 +278,11 @@ async function downloadGo(goOption: GoEnvironmentOption): Promise<GoEnvironmentO
278278
throw new Error(`SDK path does not exist: ${sdkPath}`);
279279
}
280280

281-
outputChannel.appendLine(`${goOption.label} is available in ${sdkPath}`);
281+
outputChannel.info(`${goOption.label} is available in ${sdkPath}`);
282282

283283
const binpath = path.join(sdkPath, 'bin', correctBinname('go'));
284284
const newOption = new GoEnvironmentOption(binpath, goOption.label);
285-
outputChannel.appendLine('Success!');
285+
outputChannel.info('Success!');
286286
return newOption;
287287
}
288288
);

extension/src/goGenerateTests.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ function generateTests(
197197
}
198198

199199
cp.execFile(cmd, args, { env: toolExecutionEnvironment() }, (err, stdout, stderr) => {
200-
outputChannel.appendLine('Generating Tests: ' + cmd + ' ' + args.join(' '));
200+
outputChannel.info('Generating Tests: ' + cmd + ' ' + args.join(' '));
201201

202202
try {
203203
if (err && (<any>err).code === 'ENOENT') {
@@ -227,7 +227,7 @@ function generateTests(
227227
}
228228

229229
vscode.window.showInformationMessage(message);
230-
outputChannel.append(message);
230+
outputChannel.info(message);
231231

232232
if (testsGenerated && !conf.isTestFile) {
233233
toggleTestFile(ctx, goCtx)();
@@ -236,7 +236,7 @@ function generateTests(
236236
return resolve(true);
237237
} catch (e) {
238238
vscode.window.showInformationMessage((e as any).msg);
239-
outputChannel.append((e as any).msg);
239+
outputChannel.info((e as any).msg);
240240
reject(e);
241241
}
242242
});

extension/src/goInstall.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ export const installCurrentPackage: CommandFactory = () => async () => {
5858
const importPath = currentGoWorkspace && !isMod ? cwd.substr(currentGoWorkspace.length + 1) : '.';
5959
args.push(importPath);
6060

61-
outputChannel.appendLine(`Installing ${importPath === '.' ? 'current package' : importPath}`);
61+
outputChannel.info(`Installing ${importPath === '.' ? 'current package' : importPath}`);
6262

6363
cp.execFile(goRuntimePath, args, { env, cwd }, (err, _, stderr) => {
6464
if (err) {
6565
outputChannel.error(`Installation failed: ${stderr}`);
6666
outputChannel.show();
6767
} else {
68-
outputChannel.appendLine('Installation successful');
68+
outputChannel.info('Installation successful');
6969
vscode.window.showInformationMessage('Installation successful');
7070
}
7171
});

extension/src/goInstallTools.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ export async function installTools(
219219
if (envForTools['GOTOOLCHAIN']) {
220220
envMsg += `, GOTOOLCHAIN=${envForTools['GOTOOLCHAIN']}`;
221221
}
222-
outputChannel.appendLine(envMsg);
222+
outputChannel.info(envMsg);
223223

224224
let installingPath = '';
225225
let installingMsg = `Installing ${missing.length} ${missing.length > 1 ? 'tools' : 'tool'} at `;
@@ -238,16 +238,16 @@ export async function installTools(
238238
}
239239
}
240240

241-
outputChannel.appendLine(installingMsg);
241+
outputChannel.info(installingMsg);
242242
missing.forEach((missingTool) => {
243243
let toolName = missingTool.name;
244244
if (missingTool.version) {
245245
toolName += '@' + missingTool.version;
246246
}
247-
outputChannel.appendLine(' ' + toolName);
247+
outputChannel.info(' ' + toolName);
248248
});
249249

250-
outputChannel.appendLine(''); // Blank line for spacing.
250+
outputChannel.info(''); // Blank line for spacing.
251251

252252
const failures: { tool: ToolAtVersion; reason: string }[] = [];
253253
const tm = options?.toolsManager ?? defaultToolsManager;
@@ -287,18 +287,18 @@ export async function installTools(
287287
}
288288

289289
// Report detailed information about any failures.
290-
outputChannel.appendLine(''); // blank line for spacing
290+
outputChannel.info(''); // blank line for spacing
291291
if (failures.length === 0) {
292-
outputChannel.appendLine('All tools successfully installed. You are ready to Go. :)');
292+
outputChannel.info('All tools successfully installed. You are ready to Go. :)');
293293
} else {
294294
// Show the output channel on failures, even if the installation should
295295
// be silent.
296296
if (silent) {
297297
outputChannel.show();
298298
}
299-
outputChannel.appendLine(failures.length + ' tools failed to install.\n');
299+
outputChannel.info(failures.length + ' tools failed to install.\n');
300300
for (const failure of failures) {
301-
outputChannel.appendLine(`${failure.tool.name}: ${failure.reason} `);
301+
outputChannel.info(`${failure.tool.name}: ${failure.reason} `);
302302
}
303303
}
304304
if (missing.some((tool) => tool.isImportant)) {
@@ -354,10 +354,10 @@ async function installToolWithGo(
354354
try {
355355
await installToolWithGoInstall(goVersionForInstall, env, importPath);
356356
const toolInstallPath = getBinPath(tool.name);
357-
outputChannel.appendLine(`Installing ${importPath} (${toolInstallPath}) SUCCEEDED`);
357+
outputChannel.info(`Installing ${importPath} (${toolInstallPath}) SUCCEEDED`);
358358
} catch (e) {
359-
outputChannel.appendLine(`Installing ${importPath} FAILED`);
360-
outputChannel.appendLine(`${JSON.stringify(e, null, 1)}`);
359+
outputChannel.info(`Installing ${importPath} FAILED`);
360+
outputChannel.info(`${JSON.stringify(e, null, 1)}`);
361361
return `failed to install ${tool.name}(${importPath}): ${e}`;
362362
}
363363
}
@@ -545,7 +545,7 @@ export function updateGoVarsFromConfig(goCtx: GoExtensionContext): Promise<void>
545545
{ env: env, cwd: cwd },
546546
(err, stdout, stderr) => {
547547
if (err) {
548-
outputChannel.append(
548+
outputChannel.info(
549549
`Failed to run '${goRuntimePath} env' (cwd: ${getWorkspaceFolderPath()}): ${err}\n${stderr}`
550550
);
551551
outputChannel.show();
@@ -558,7 +558,7 @@ export function updateGoVarsFromConfig(goCtx: GoExtensionContext): Promise<void>
558558
if (stderr) {
559559
// 'go env' may output warnings about potential misconfiguration.
560560
// Show the messages to users but keep processing the stdout.
561-
outputChannel.append(`'${goRuntimePath} env': ${stderr}`);
561+
outputChannel.info(`'${goRuntimePath} env': ${stderr}`);
562562
outputChannel.show();
563563
}
564564
outputChannel.trace(`${goRuntimePath} env ...:\n${stdout}`);
@@ -623,7 +623,7 @@ export async function maybeInstallImportantTools(
623623
missing = missing
624624
.map((tool) => {
625625
if (alternateTools[tool.name]) {
626-
outputChannel.appendLine(
626+
outputChannel.info(
627627
`skip installing ${
628628
tool.name
629629
} because the 'alternateTools' setting is configured to use ${
@@ -642,7 +642,7 @@ export async function maybeInstallImportantTools(
642642
await updateImportantToolsStatus(tm);
643643
}
644644
} catch (e) {
645-
outputChannel.appendLine('install missing tools failed - ' + JSON.stringify(e));
645+
outputChannel.info('install missing tools failed - ' + JSON.stringify(e));
646646
} finally {
647647
statusBarItem.busy = false;
648648
}

extension/src/goLint.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export function lintCode(scope?: string): CommandFactory {
3636
const goConfig = getGoConfig(documentUri);
3737
const goplsConfig = getGoplsConfig(documentUri);
3838

39-
outputChannel.appendLine('Linting...');
39+
outputChannel.info('Linting...');
4040
diagnosticsStatusBarItem.show();
4141
diagnosticsStatusBarItem.text = 'Linting...';
4242

@@ -170,12 +170,12 @@ export async function goLint(
170170

171171
if (scope === 'workspace' && currentWorkspace) {
172172
args.push('./...');
173-
outputChannel.appendLine(`Starting linting the current workspace at ${currentWorkspace}`);
173+
outputChannel.info(`Starting linting the current workspace at ${currentWorkspace}`);
174174
} else if (scope === 'file') {
175175
args.push(fileUri?.fsPath ?? '');
176-
outputChannel.appendLine(`Starting linting the current file at ${fileUri?.fsPath}`);
176+
outputChannel.info(`Starting linting the current file at ${fileUri?.fsPath}`);
177177
} else {
178-
outputChannel.appendLine(`Starting linting the current package at ${cwd}`);
178+
outputChannel.info(`Starting linting the current package at ${cwd}`);
179179
}
180180

181181
running = true;

extension/src/goModules.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ export const goModInit: CommandFactory = () => async () => {
142142
try {
143143
const env = toolExecutionEnvironment();
144144
const cwd = getWorkspaceFolderPath() ?? '';
145-
outputChannel.appendLine(`Running "${goRuntimePath} mod init ${moduleName}"`);
145+
outputChannel.info(`Running "${goRuntimePath} mod init ${moduleName}"`);
146146
await execFile(goRuntimePath, ['mod', 'init', moduleName], { env, cwd });
147-
outputChannel.appendLine('Module successfully initialized. You are ready to Go :)');
147+
outputChannel.info('Module successfully initialized. You are ready to Go :)');
148148
vscode.commands.executeCommand('vscode.open', vscode.Uri.file(path.join(cwd, 'go.mod')));
149149
} catch (e) {
150150
outputChannel.error((e as Error).message);

extension/src/goPlayground.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,18 @@ export const playgroundCommand: CommandFactory = () => () => {
2929
}
3030

3131
outputChannel.show();
32-
outputChannel.appendLine('Upload to the Go Playground in progress...\n');
32+
outputChannel.info('Upload to the Go Playground in progress...\n');
3333

3434
const selection = editor.selection;
3535
const code = selection.isEmpty ? editor.document.getText() : editor.document.getText(selection);
3636
const config: vscode.WorkspaceConfiguration | undefined = getGoConfig(editor.document.uri).get('playground');
3737
goPlay(code, config).then(
3838
(result) => {
39-
outputChannel.append(result);
39+
outputChannel.info(result);
4040
},
4141
(e: string) => {
4242
if (e) {
43-
outputChannel.append(e);
43+
outputChannel.info(e);
4444
}
4545
}
4646
);

extension/src/goSurvey.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,12 +248,12 @@ export function getStateConfig(globalStateKey: string, workspace?: boolean): any
248248

249249
export const showSurveyConfig: CommandFactory = (ctx, goCtx) => async () => {
250250
// TODO(rstambler): Add developer survey config.
251-
outputChannel.appendLine('HaTs Survey Configuration');
252-
outputChannel.appendLine(JSON.stringify(getGoplsSurveyConfig(), null, 2));
251+
outputChannel.info('HaTs Survey Configuration');
252+
outputChannel.info(JSON.stringify(getGoplsSurveyConfig(), null, 2));
253253
outputChannel.show();
254254

255-
outputChannel.appendLine('Developer Survey Configuration');
256-
outputChannel.appendLine(JSON.stringify(getDeveloperSurveyConfig(), null, 2));
255+
outputChannel.info('Developer Survey Configuration');
256+
outputChannel.info(JSON.stringify(getDeveloperSurveyConfig(), null, 2));
257257
outputChannel.show();
258258

259259
let selected = await vscode.window.showInformationMessage('Prompt for HaTS survey?', 'Yes', 'Maybe', 'No');

0 commit comments

Comments
 (0)