From c9efee4636f1c53fac0a6a171e52ba6aa7795714 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Fri, 21 Dec 2018 13:51:29 +0100 Subject: [PATCH] debt - remove unused node dialog service --- src/tsconfig.strictNullChecks.json | 1 - src/vs/code/electron-main/main.ts | 3 - src/vs/platform/dialogs/node/dialogService.ts | 67 ------------------- 3 files changed, 71 deletions(-) delete mode 100644 src/vs/platform/dialogs/node/dialogService.ts diff --git a/src/tsconfig.strictNullChecks.json b/src/tsconfig.strictNullChecks.json index 050501fe2db..cbc1cadb439 100644 --- a/src/tsconfig.strictNullChecks.json +++ b/src/tsconfig.strictNullChecks.json @@ -398,7 +398,6 @@ "./vs/platform/diagnostics/electron-main/diagnosticsService.ts", "./vs/platform/dialogs/common/dialogs.ts", "./vs/platform/dialogs/node/dialogIpc.ts", - "./vs/platform/dialogs/node/dialogService.ts", "./vs/platform/download/common/download.ts", "./vs/platform/download/node/downloadIpc.ts", "./vs/platform/download/node/downloadService.ts", diff --git a/src/vs/code/electron-main/main.ts b/src/vs/code/electron-main/main.ts index 59f54f7b49e..2165dcc944f 100644 --- a/src/vs/code/electron-main/main.ts +++ b/src/vs/code/electron-main/main.ts @@ -36,8 +36,6 @@ import { IDiagnosticsService, DiagnosticsService } from 'vs/platform/diagnostics import { BufferLogService } from 'vs/platform/log/common/bufferLog'; import { uploadLogs } from 'vs/code/electron-main/logUploader'; import { setUnexpectedErrorHandler } from 'vs/base/common/errors'; -import { IDialogService } from 'vs/platform/dialogs/common/dialogs'; -import { CommandLineDialogService } from 'vs/platform/dialogs/node/dialogService'; import { createWaitMarkerFile } from 'vs/code/node/wait'; class ExpectedError extends Error { @@ -310,7 +308,6 @@ function createServices(args: ParsedArgs, bufferLogService: BufferLogService): I services.set(IStateService, new SyncDescriptor(StateService)); services.set(IConfigurationService, new SyncDescriptor(ConfigurationService)); services.set(IRequestService, new SyncDescriptor(RequestService)); - services.set(IDialogService, new SyncDescriptor(CommandLineDialogService)); services.set(IDiagnosticsService, new SyncDescriptor(DiagnosticsService)); return new InstantiationService(services, true); diff --git a/src/vs/platform/dialogs/node/dialogService.ts b/src/vs/platform/dialogs/node/dialogService.ts deleted file mode 100644 index cf04c7608e7..00000000000 --- a/src/vs/platform/dialogs/node/dialogService.ts +++ /dev/null @@ -1,67 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import * as readline from 'readline'; -import { IDialogService, IConfirmation, IConfirmationResult } from 'vs/platform/dialogs/common/dialogs'; -import Severity from 'vs/base/common/severity'; -import { localize } from 'vs/nls'; -import { canceled } from 'vs/base/common/errors'; - -export class CommandLineDialogService implements IDialogService { - - _serviceBrand: any; - - show(severity: Severity, message: string, options: string[]): Promise { - const promise = new Promise((c, e) => { - const rl = readline.createInterface({ - input: process.stdin, - output: process.stdout, - terminal: true - }); - rl.prompt(); - rl.write(this.toQuestion(message, options)); - - rl.prompt(); - - rl.once('line', (answer) => { - rl.close(); - c(this.toOption(answer, options)); - }); - rl.once('SIGINT', () => { - rl.close(); - e(canceled()); - }); - }); - return promise; - } - - private toQuestion(message: string, options: string[]): string { - return options.reduce((previousValue: string, currentValue: string, currentIndex: number) => { - return previousValue + currentValue + '(' + currentIndex + ')' + (currentIndex < options.length - 1 ? ' | ' : '\n'); - }, message + ' '); - } - - private toOption(answer: string, options: string[]): number { - const value = parseInt(answer); - if (!isNaN(value)) { - return value; - } - answer = answer.toLocaleLowerCase(); - for (let i = 0; i < options.length; i++) { - if (options[i].toLocaleLowerCase() === answer) { - return i; - } - } - return -1; - } - - confirm(confirmation: IConfirmation): Promise { - return this.show(Severity.Info, confirmation.message, [confirmation.primaryButton || localize('ok', "Ok"), confirmation.secondaryButton || localize('cancel', "Cancel")]).then(index => { - return { - confirmed: index === 0 - } as IConfirmationResult; - }); - } -} -- GitLab