Skip to content

Commit fbb07e6

Browse files
committed
cleanup
1 parent 35172cb commit fbb07e6

File tree

5 files changed

+31
-30
lines changed

5 files changed

+31
-30
lines changed

Extension/src/Debugger/configurationProvider.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { expandAllStrings, ExpansionOptions, ExpansionVars } from '../expand';
1717
import { CppBuildTask, CppBuildTaskDefinition, cppBuildTaskProvider } from '../LanguageServer/cppBuildTaskProvider';
1818
import { configPrefix } from '../LanguageServer/extension';
1919
import { CppSettings, OtherSettings } from '../LanguageServer/settings';
20-
import { getOutputChannel, getOutputChannelLogger, Logger, showOutputChannel } from '../logger';
20+
import * as logger from '../logger';
2121
import { PlatformInformation } from '../platform';
2222
import { rsync, scp, ssh } from '../SSH/commands';
2323
import * as Telemetry from '../telemetry';
@@ -236,14 +236,14 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
236236
if (config.type === DebuggerType.cppvsdbg) {
237237
// Fail if cppvsdbg type is running on non-Windows
238238
if (os.platform() !== 'win32') {
239-
void getOutputChannelLogger().showWarningMessage(localize("debugger.not.available", "Debugger of type: '{0}' is only available on Windows. Use type: '{1}' on the current OS platform.", "cppvsdbg", "cppdbg"));
239+
void logger.getOutputChannelLogger().showWarningMessage(localize("debugger.not.available", "Debugger of type: '{0}' is only available on Windows. Use type: '{1}' on the current OS platform.", "cppvsdbg", "cppdbg"));
240240
return undefined; // Abort debugging silently.
241241
}
242242

243243
// Handle legacy 'externalConsole' bool and convert to console: "externalTerminal"
244244
// eslint-disable-next-line no-prototype-builtins
245245
if (config.hasOwnProperty("externalConsole")) {
246-
void getOutputChannelLogger().showWarningMessage(localize("debugger.deprecated.config", "The key '{0}' is deprecated. Please use '{1}' instead.", "externalConsole", "console"));
246+
void logger.getOutputChannelLogger().showWarningMessage(localize("debugger.deprecated.config", "The key '{0}' is deprecated. Please use '{1}' instead.", "externalConsole", "console"));
247247
if (config.externalConsole && !config.console) {
248248
config.console = "externalTerminal";
249249
}
@@ -322,18 +322,18 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
322322
}
323323

324324
if (config.logging?.engineLogging) {
325-
const outputChannel: Logger = getOutputChannelLogger();
325+
const outputChannel: logger.Logger = logger.getOutputChannelLogger();
326326
outputChannel.appendLine(localize("debugger.launchConfig", "Launch configuration:"));
327327
outputChannel.appendLine(JSON.stringify(config, undefined, 2));
328328
// TODO: Enable when https://github.com/microsoft/vscode/issues/108619 is resolved.
329-
// showOutputChannel();
329+
// logger.showOutputChannel();
330330
}
331331

332332
// Run deploy steps
333333
if (config.deploySteps && config.deploySteps.length !== 0) {
334334
const codeVersion: number[] = util.getVsCodeVersion();
335335
if ((util.isNumber(codeVersion[0]) && codeVersion[0] < 1) || (util.isNumber(codeVersion[0]) && codeVersion[0] === 1 && util.isNumber(codeVersion[1]) && codeVersion[1] < 69)) {
336-
void getOutputChannelLogger().showErrorMessage(localize("vs.code.1.69+.required", "'deploySteps' require VS Code 1.69+."));
336+
void logger.getOutputChannelLogger().showErrorMessage(localize("vs.code.1.69+.required", "'deploySteps' require VS Code 1.69+."));
337337
return undefined;
338338
}
339339

@@ -362,7 +362,7 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
362362
if (processId) {
363363
config.processId = processId;
364364
} else {
365-
void getOutputChannelLogger().showErrorMessage("No process was selected.");
365+
void logger.getOutputChannelLogger().showErrorMessage("No process was selected.");
366366
return undefined;
367367
}
368368
}
@@ -421,7 +421,7 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
421421
// Non-absolute. Check on $PATH
422422
(await util.whichAsync(compilerPath) !== undefined);
423423
if (!compilerPathExists) {
424-
getOutputChannelLogger().appendLine(localize('compiler.path.not.exists', "Unable to find {0}. {1} task is ignored.", compilerPath, definition.label));
424+
logger.getOutputChannelLogger().appendLine(localize('compiler.path.not.exists', "Unable to find {0}. {1} task is ignored.", compilerPath, definition.label));
425425
}
426426
const compilerName: string = path.basename(compilerPath);
427427
const newConfig: CppDebugConfiguration = { ...defaultTemplateConfig }; // Copy enumerables and properties
@@ -493,7 +493,7 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
493493
if (!isWindows && await util.checkFileExists(usrDebuggerPath)) {
494494
newConfig.miDebuggerPath = usrDebuggerPath;
495495
} else {
496-
getOutputChannelLogger().appendLine(localize('debugger.path.not.exists', "Unable to find the {0} debugger. The debug configuration for {1} is ignored.", `\"${debuggerName}\"`, compilerName));
496+
logger.getOutputChannelLogger().appendLine(localize('debugger.path.not.exists', "Unable to find the {0} debugger. The debug configuration for {1} is ignored.", `\"${debuggerName}\"`, compilerName));
497497
return undefined;
498498
}
499499
}
@@ -608,7 +608,7 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
608608
}
609609
}
610610

611-
const outputChannel: Logger = getOutputChannelLogger();
611+
const outputChannel: logger.Logger = logger.getOutputChannelLogger();
612612

613613
outputChannel.appendLine(localize("lldb.find.failed", "Missing dependency '{0}' for lldb-mi executable.", LLDBFramework));
614614
outputChannel.appendLine(localize("lldb.search.paths", "Searched in:"));
@@ -617,7 +617,7 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
617617
});
618618
const xcodeCLIInstallCmd: string = "xcode-select --install";
619619
outputChannel.appendLine(localize("lldb.install.help", "To resolve this issue, either install XCode through the Apple App Store or install the XCode Command Line Tools by running '{0}' in a Terminal window.", xcodeCLIInstallCmd));
620-
showOutputChannel();
620+
logger.showOutputChannel();
621621

622622
return undefined;
623623
}
@@ -696,11 +696,11 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
696696
}
697697

698698
if (messages.length > 0) {
699-
getOutputChannel().appendLine(localize("resolving.variables.in.sourcefilemap", "Resolving variables in {0}...", "sourceFileMap"));
699+
logger.getOutputChannel().appendLine(localize("resolving.variables.in.sourcefilemap", "Resolving variables in {0}...", "sourceFileMap"));
700700
messages.forEach((message) => {
701-
getOutputChannel().appendLine(message);
701+
logger.getOutputChannel().appendLine(message);
702702
});
703-
showOutputChannel();
703+
logger.showOutputChannel();
704704
}
705705
}
706706
}
@@ -1038,7 +1038,7 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
10381038
case StepType.command: {
10391039
// VS Code commands are the same regardless of which extension invokes them, so just invoke them here.
10401040
if (step.args && !Array.isArray(step.args)) {
1041-
void getOutputChannelLogger().showErrorMessage(localize('command.args.must.be.array', '"args" in command deploy step must be an array.'));
1041+
void logger.getOutputChannelLogger().showErrorMessage(localize('command.args.must.be.array', '"args" in command deploy step must be an array.'));
10421042
return false;
10431043
}
10441044
const returnCode: unknown = await vscode.commands.executeCommand(step.command, ...step.args);
@@ -1048,7 +1048,7 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
10481048
case StepType.rsync: {
10491049
const isScp: boolean = stepType === StepType.scp;
10501050
if (!step.files || !step.targetDir || !step.host) {
1051-
void getOutputChannelLogger().showErrorMessage(localize('missing.properties.copyFile', '"host", "files", and "targetDir" are required in {0} steps.', isScp ? 'SCP' : 'rsync'));
1051+
void logger.getOutputChannelLogger().showErrorMessage(localize('missing.properties.copyFile', '"host", "files", and "targetDir" are required in {0} steps.', isScp ? 'SCP' : 'rsync'));
10521052
return false;
10531053
}
10541054
const host: util.ISshHostInfo = util.isString(step.host) ? { hostName: step.host } : { hostName: step.host.hostName, user: step.host.user, port: step.host.port };
@@ -1061,7 +1061,7 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
10611061
files = files.concat((await globAsync(fileGlob)).map(file => vscode.Uri.file(file)));
10621062
}
10631063
} else {
1064-
void getOutputChannelLogger().showErrorMessage(localize('incorrect.files.type.copyFile', '"files" must be a string or an array of strings in {0} steps.', isScp ? 'SCP' : 'rsync'));
1064+
void logger.getOutputChannelLogger().showErrorMessage(localize('incorrect.files.type.copyFile', '"files" must be a string or an array of strings in {0} steps.', isScp ? 'SCP' : 'rsync'));
10651065
return false;
10661066
}
10671067

@@ -1079,7 +1079,7 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
10791079
}
10801080
case StepType.ssh: {
10811081
if (!step.host || !step.command) {
1082-
void getOutputChannelLogger().showErrorMessage(localize('missing.properties.ssh', '"host" and "command" are required for ssh steps.'));
1082+
void logger.getOutputChannelLogger().showErrorMessage(localize('missing.properties.ssh', '"host" and "command" are required for ssh steps.'));
10831083
return false;
10841084
}
10851085
const host: util.ISshHostInfo = util.isString(step.host) ? { hostName: step.host } : { hostName: step.host.hostName, user: step.host.user, port: step.host.port };
@@ -1094,18 +1094,18 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
10941094
}
10951095
case StepType.shell: {
10961096
if (!step.command) {
1097-
void getOutputChannelLogger().showErrorMessage(localize('missing.properties.shell', '"command" is required for shell steps.'));
1097+
void logger.getOutputChannelLogger().showErrorMessage(localize('missing.properties.shell', '"command" is required for shell steps.'));
10981098
return false;
10991099
}
11001100
const taskResult: util.ProcessReturnType = await util.spawnChildProcess(step.command, undefined, step.continueOn);
11011101
if (!taskResult.succeeded || cancellationToken?.isCancellationRequested) {
1102-
void getOutputChannelLogger().showErrorMessage(taskResult.output);
1102+
void logger.getOutputChannelLogger().showErrorMessage(taskResult.output);
11031103
return false;
11041104
}
11051105
break;
11061106
}
11071107
default: {
1108-
getOutputChannelLogger().appendLine(localize('deploy.step.type.not.supported', 'Deploy step type {0} is not supported.', step.type));
1108+
logger.getOutputChannelLogger().appendLine(localize('deploy.step.type.not.supported', 'Deploy step type {0} is not supported.', step.type));
11091109
return false;
11101110
}
11111111
}

Extension/src/LanguageServer/client.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,8 +844,9 @@ export function createClient(workspaceFolder?: vscode.WorkspaceFolder): Client {
844844
instrument(vscode.debug, { name: "debug" });
845845
instrument(vscode.env, { name: "env" });
846846
instrument(vscode.extensions, { name: "extensions" });
847+
return instrument(new DefaultClient(workspaceFolder), { ignore: ["enqueue", "onInterval", "logTelemetry"] });
847848
}
848-
return instrument(new DefaultClient(workspaceFolder), { ignore: ["enqueue", "onInterval", "logTelemetry"] });
849+
return new DefaultClient(workspaceFolder);
849850
}
850851

851852
export function createNullClient(): Client {

Extension/src/LanguageServer/lmTool.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import * as vscode from 'vscode';
88
import * as nls from 'vscode-nls';
99
import * as util from '../common';
10-
import { getOutputChannelLogger } from '../logger';
10+
import * as logger from '../logger';
1111
import * as telemetry from '../telemetry';
1212
import { ChatContextResult, ProjectContextResult } from './client';
1313
import { getClients } from './extension';
@@ -181,7 +181,7 @@ export async function getProjectContext(uri: vscode.Uri, context: { flags: Recor
181181
catch (exception) {
182182
try {
183183
const err: Error = exception as Error;
184-
getOutputChannelLogger().appendLine(localize("copilot.projectcontext.error", "Error while retrieving the project context. Reason: {0}", err.message));
184+
logger.getOutputChannelLogger().appendLine(localize("copilot.projectcontext.error", "Error while retrieving the project context. Reason: {0}", err.message));
185185
}
186186
catch {
187187
// Intentionally swallow any exception.
@@ -249,7 +249,7 @@ export class CppConfigurationLanguageModelTool implements vscode.LanguageModelTo
249249

250250
private async reportError(): Promise<void> {
251251
try {
252-
getOutputChannelLogger().appendLine(localize("copilot.cppcontext.error", "Error while retrieving the #cpp context."));
252+
logger.getOutputChannelLogger().appendLine(localize("copilot.cppcontext.error", "Error while retrieving the #cpp context."));
253253
}
254254
catch {
255255
// Intentionally swallow any exception.

Extension/src/LanguageServer/references.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as vscode from 'vscode';
88
import { Position, TextDocumentIdentifier } from 'vscode-languageclient';
99
import * as nls from 'vscode-nls';
1010
import * as util from '../common';
11-
import { getOutputChannel } from '../logger';
11+
import * as logger from '../logger';
1212
import * as telemetry from '../telemetry';
1313
import { DefaultClient } from './client';
1414
import { PersistentState } from './persistentState';
@@ -482,7 +482,7 @@ export class ReferencesManager {
482482
}
483483
}
484484
} else if (this.client.ReferencesCommandMode === ReferencesCommandMode.Find) {
485-
const logChannel: vscode.OutputChannel = getOutputChannel();
485+
const logChannel: vscode.OutputChannel = logger.getOutputChannel();
486486
logChannel.appendLine(msg);
487487
logChannel.appendLine("");
488488
if (showLog) {

Extension/src/platform.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as os from 'os';
88
import * as plist from 'plist';
99
import * as nls from 'vscode-nls';
1010
import { LinuxDistribution } from './linuxDistribution';
11-
import { getOutputChannelLogger, showOutputChannel } from './logger';
11+
import * as logger from './logger';
1212
import { SessionState, SupportedWindowsVersions } from './sessionState';
1313

1414
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
@@ -81,8 +81,8 @@ export class PlatformInformation {
8181
}
8282

8383
if (errorMessage) {
84-
getOutputChannelLogger().appendLine(errorMessage);
85-
showOutputChannel();
84+
logger.getOutputChannel().appendLine(errorMessage);
85+
logger.showOutputChannel();
8686
}
8787

8888
return Promise.resolve(productDarwinVersion);

0 commit comments

Comments
 (0)