Skip to content

Commit 2201f39

Browse files
author
Kartik Raj
committed
Refactor
1 parent 606d501 commit 2201f39

File tree

1 file changed

+18
-32
lines changed

1 file changed

+18
-32
lines changed

src/client/application/diagnostics/checks/pythonInterpreter.ts

+18-32
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,13 @@ export class InvalidPythonInterpreterDiagnostic extends BaseDiagnostic {
7676
}
7777
}
7878

79+
type DefaultShellDiagnostics =
80+
| DiagnosticCodes.InvalidComspecDiagnostic
81+
| DiagnosticCodes.IncompletePathVarDiagnostic
82+
| DiagnosticCodes.DefaultShellErrorDiagnostic;
83+
7984
export class DefaultShellDiagnostic extends BaseDiagnostic {
80-
constructor(
81-
code:
82-
| DiagnosticCodes.InvalidComspecDiagnostic
83-
| DiagnosticCodes.IncompletePathVarDiagnostic
84-
| DiagnosticCodes.DefaultShellErrorDiagnostic,
85-
resource: Resource,
86-
scope = DiagnosticScope.Global,
87-
) {
85+
constructor(code: DefaultShellDiagnostics, resource: Resource, scope = DiagnosticScope.Global) {
8886
super(code, messages[code], DiagnosticSeverity.Error, scope, resource, undefined, 'always');
8987
}
9088
}
@@ -106,6 +104,7 @@ export class InvalidPythonInterpreterService extends BaseDiagnosticsService
106104
DiagnosticCodes.InvalidPythonInterpreterDiagnostic,
107105
DiagnosticCodes.InvalidComspecDiagnostic,
108106
DiagnosticCodes.IncompletePathVarDiagnostic,
107+
DiagnosticCodes.DefaultShellErrorDiagnostic,
109108
],
110109
serviceContainer,
111110
disposableRegistry,
@@ -262,35 +261,22 @@ export class InvalidPythonInterpreterService extends BaseDiagnosticsService
262261

263262
private getCommandPrompts(diagnostic: IDiagnostic): { prompt: string; command?: IDiagnosticCommand }[] {
264263
const commandFactory = this.serviceContainer.get<IDiagnosticsCommandFactory>(IDiagnosticsCommandFactory);
265-
if (diagnostic.code === DiagnosticCodes.InvalidComspecDiagnostic) {
266-
return [
267-
{
268-
prompt: Common.seeInstructions,
269-
command: commandFactory.createCommand(diagnostic, {
270-
type: 'launch',
271-
options: 'https://aka.ms/AAk3djo',
272-
}),
273-
},
274-
];
275-
}
276-
if (diagnostic.code === DiagnosticCodes.IncompletePathVarDiagnostic) {
277-
return [
278-
{
279-
prompt: Common.seeInstructions,
280-
command: commandFactory.createCommand(diagnostic, {
281-
type: 'launch',
282-
options: 'https://aka.ms/AAk744c',
283-
}),
284-
},
285-
];
286-
}
287-
if (diagnostic.code === DiagnosticCodes.DefaultShellErrorDiagnostic) {
264+
if (
265+
diagnostic.code === DiagnosticCodes.InvalidComspecDiagnostic ||
266+
diagnostic.code === DiagnosticCodes.IncompletePathVarDiagnostic ||
267+
diagnostic.code === DiagnosticCodes.DefaultShellErrorDiagnostic
268+
) {
269+
const links: Record<DefaultShellDiagnostics, string> = {
270+
InvalidComspecDiagnostic: 'https://aka.ms/AAk3djo',
271+
IncompletePathVarDiagnostic: 'https://aka.ms/AAk744c',
272+
DefaultShellErrorDiagnostic: 'https://aka.ms/AAk7qix',
273+
};
288274
return [
289275
{
290276
prompt: Common.seeInstructions,
291277
command: commandFactory.createCommand(diagnostic, {
292278
type: 'launch',
293-
options: 'https://aka.ms/AAk7qix',
279+
options: links[diagnostic.code],
294280
}),
295281
},
296282
];

0 commit comments

Comments
 (0)