Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartik Raj committed Mar 28, 2023
1 parent 606d501 commit 2201f39
Showing 1 changed file with 18 additions and 32 deletions.
50 changes: 18 additions & 32 deletions src/client/application/diagnostics/checks/pythonInterpreter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,13 @@ export class InvalidPythonInterpreterDiagnostic extends BaseDiagnostic {
}
}

type DefaultShellDiagnostics =
| DiagnosticCodes.InvalidComspecDiagnostic
| DiagnosticCodes.IncompletePathVarDiagnostic
| DiagnosticCodes.DefaultShellErrorDiagnostic;

export class DefaultShellDiagnostic extends BaseDiagnostic {
constructor(
code:
| DiagnosticCodes.InvalidComspecDiagnostic
| DiagnosticCodes.IncompletePathVarDiagnostic
| DiagnosticCodes.DefaultShellErrorDiagnostic,
resource: Resource,
scope = DiagnosticScope.Global,
) {
constructor(code: DefaultShellDiagnostics, resource: Resource, scope = DiagnosticScope.Global) {
super(code, messages[code], DiagnosticSeverity.Error, scope, resource, undefined, 'always');
}
}
Expand All @@ -106,6 +104,7 @@ export class InvalidPythonInterpreterService extends BaseDiagnosticsService
DiagnosticCodes.InvalidPythonInterpreterDiagnostic,
DiagnosticCodes.InvalidComspecDiagnostic,
DiagnosticCodes.IncompletePathVarDiagnostic,
DiagnosticCodes.DefaultShellErrorDiagnostic,
],
serviceContainer,
disposableRegistry,
Expand Down Expand Up @@ -262,35 +261,22 @@ export class InvalidPythonInterpreterService extends BaseDiagnosticsService

private getCommandPrompts(diagnostic: IDiagnostic): { prompt: string; command?: IDiagnosticCommand }[] {
const commandFactory = this.serviceContainer.get<IDiagnosticsCommandFactory>(IDiagnosticsCommandFactory);
if (diagnostic.code === DiagnosticCodes.InvalidComspecDiagnostic) {
return [
{
prompt: Common.seeInstructions,
command: commandFactory.createCommand(diagnostic, {
type: 'launch',
options: 'https://aka.ms/AAk3djo',
}),
},
];
}
if (diagnostic.code === DiagnosticCodes.IncompletePathVarDiagnostic) {
return [
{
prompt: Common.seeInstructions,
command: commandFactory.createCommand(diagnostic, {
type: 'launch',
options: 'https://aka.ms/AAk744c',
}),
},
];
}
if (diagnostic.code === DiagnosticCodes.DefaultShellErrorDiagnostic) {
if (
diagnostic.code === DiagnosticCodes.InvalidComspecDiagnostic ||
diagnostic.code === DiagnosticCodes.IncompletePathVarDiagnostic ||
diagnostic.code === DiagnosticCodes.DefaultShellErrorDiagnostic
) {
const links: Record<DefaultShellDiagnostics, string> = {
InvalidComspecDiagnostic: 'https://aka.ms/AAk3djo',
IncompletePathVarDiagnostic: 'https://aka.ms/AAk744c',
DefaultShellErrorDiagnostic: 'https://aka.ms/AAk7qix',
};
return [
{
prompt: Common.seeInstructions,
command: commandFactory.createCommand(diagnostic, {
type: 'launch',
options: 'https://aka.ms/AAk7qix',
options: links[diagnostic.code],
}),
},
];
Expand Down

0 comments on commit 2201f39

Please sign in to comment.