From 72d5422cfa6591c9e0086e63520fa569b721245c Mon Sep 17 00:00:00 2001 From: Aswin M Prabhu Date: Thu, 22 Nov 2018 23:11:32 +0530 Subject: [PATCH] Fix tslint errors --- src/goDoctor.ts | 176 ++++++++++++++++++++++++------------------------ 1 file changed, 88 insertions(+), 88 deletions(-) diff --git a/src/goDoctor.ts b/src/goDoctor.ts index 6e7752f8c..149f91e23 100644 --- a/src/goDoctor.ts +++ b/src/goDoctor.ts @@ -16,23 +16,23 @@ import { resolve } from 'dns'; * Extracts function out of current selection and replaces the current selection with a call to the extracted function. */ export function extractFunction() { - let activeEditor = vscode.window.activeTextEditor; - if (!activeEditor) { - vscode.window.showInformationMessage('No editor is active.'); - return; - } - if (activeEditor.selections.length !== 1) { - vscode.window.showInformationMessage('You need to have a single selection for extracting method'); - return; - } - let showInputBoxPromise = vscode.window.showInputBox({ placeHolder: 'Plese enter a name for the extracted function.' }); - showInputBoxPromise.then((functionName: string) => { - runGoDoctorExtract(functionName, activeEditor.selection, activeEditor).then(errorMessage => { - if (errorMessage) { - vscode.window.showErrorMessage(errorMessage); - } - }); - }); + let activeEditor = vscode.window.activeTextEditor; + if (!activeEditor) { + vscode.window.showInformationMessage('No editor is active.'); + return; + } + if (activeEditor.selections.length !== 1) { + vscode.window.showInformationMessage('You need to have a single selection for extracting method'); + return; + } + let showInputBoxPromise = vscode.window.showInputBox({ placeHolder: 'Plese enter a name for the extracted function.' }); + showInputBoxPromise.then((functionName: string) => { + runGoDoctorExtract(functionName, activeEditor.selection, activeEditor).then(errorMessage => { + if (errorMessage) { + vscode.window.showErrorMessage(errorMessage); + } + }); + }); } /** @@ -40,23 +40,23 @@ export function extractFunction() { * replaces the current selection with the new var. */ export function extractVariable() { - let activeEditor = vscode.window.activeTextEditor; - if (!activeEditor) { - vscode.window.showInformationMessage('No editor is active.'); - return; - } - if (activeEditor.selections.length !== 1) { - vscode.window.showInformationMessage('You need to have a single selection for extracting variable'); - return; - } - let showInputBoxPromise = vscode.window.showInputBox({ placeHolder: 'Plese enter a name for the extracted variable.' }); - showInputBoxPromise.then((varName: string) => { - runGoDoctorVar(varName, activeEditor.selection, activeEditor).then(errorMessage => { - if (errorMessage) { - vscode.window.showErrorMessage(errorMessage); - } - }); - }); + let activeEditor = vscode.window.activeTextEditor; + if (!activeEditor) { + vscode.window.showInformationMessage('No editor is active.'); + return; + } + if (activeEditor.selections.length !== 1) { + vscode.window.showInformationMessage('You need to have a single selection for extracting variable'); + return; + } + let showInputBoxPromise = vscode.window.showInputBox({ placeHolder: 'Plese enter a name for the extracted variable.' }); + showInputBoxPromise.then((varName: string) => { + runGoDoctorVar(varName, activeEditor.selection, activeEditor).then(errorMessage => { + if (errorMessage) { + vscode.window.showErrorMessage(errorMessage); + } + }); + }); } /** @@ -66,35 +66,35 @@ export function extractVariable() { * @returns errorMessage in case the method fails, null otherwise */ export function runGoDoctorExtract(functionName: string, selection: vscode.Selection, activeEditor: vscode.TextEditor): Thenable { - let godoctor = getBinPath('godoctor'); + let godoctor = getBinPath('godoctor'); - return new Promise((resolve, reject) => { - if (typeof functionName === 'undefined') { - return resolve('Function Name is undefined'); - } - let args = [ - '-w', - '-pos', - `${selection.start.line + 1},${selection.start.character + 1}:${selection.end.line + 1},${selection.end.character + 1}`, - '-file', - activeEditor.document.fileName, - 'extract', - functionName, - ]; - let p = cp.execFile(godoctor, args, { env: getToolsEnvVars(), cwd: dirname(activeEditor.document.fileName) }, (err, stdout, stderr) => { - if (err && (err).code === 'ENOENT') { - promptForMissingTool('godoctor'); - return resolve('Could not find godoctor'); - } - if (err) { - return resolve(`Could not extract function : \n\n${stderr}`); - } - }); - if (p.pid) { - p.stdin.end(); - } + return new Promise((resolve, reject) => { + if (typeof functionName === 'undefined') { + return resolve('Function Name is undefined'); + } + let args = [ + '-w', + '-pos', + `${selection.start.line + 1},${selection.start.character + 1}:${selection.end.line + 1},${selection.end.character + 1}`, + '-file', + activeEditor.document.fileName, + 'extract', + functionName, + ]; + let p = cp.execFile(godoctor, args, { env: getToolsEnvVars(), cwd: dirname(activeEditor.document.fileName) }, (err, stdout, stderr) => { + if (err && (err).code === 'ENOENT') { + promptForMissingTool('godoctor'); + return resolve('Could not find godoctor'); + } + if (err) { + return resolve(`Could not extract function : \n\n${stderr}`); + } + }); + if (p.pid) { + p.stdin.end(); + } - }); + }); } /** @@ -104,33 +104,33 @@ export function runGoDoctorExtract(functionName: string, selection: vscode.Selec * @returns errorMessage in case the method fails, null otherwise */ export function runGoDoctorVar(varName: string, selection: vscode.Selection, activeEditor: vscode.TextEditor): Thenable { - let godoctor = getBinPath('godoctor'); + let godoctor = getBinPath('godoctor'); - return new Promise((resolve, reject) => { - if (typeof varName === 'undefined') { - return resolve('Function Name is undefined'); - } - let args = [ - '-w', - '-pos', - `${selection.start.line + 1},${selection.start.character + 1}:${selection.end.line + 1},${selection.end.character + 1}`, - '-file', - activeEditor.document.fileName, - 'var', - varName, - ]; - let p = cp.execFile(godoctor, args, { env: getToolsEnvVars(), cwd: dirname(activeEditor.document.fileName) }, (err, stdout, stderr) => { - if (err && (err).code === 'ENOENT') { - promptForMissingTool('godoctor'); - return resolve('Could not find godoctor'); - } - if (err) { - return resolve(`Could not extract variable : \n\n${stderr}`); - } - }); - if (p.pid) { - p.stdin.end(); - } + return new Promise((resolve, reject) => { + if (typeof varName === 'undefined') { + return resolve('Function Name is undefined'); + } + let args = [ + '-w', + '-pos', + `${selection.start.line + 1},${selection.start.character + 1}:${selection.end.line + 1},${selection.end.character + 1}`, + '-file', + activeEditor.document.fileName, + 'var', + varName, + ]; + let p = cp.execFile(godoctor, args, { env: getToolsEnvVars(), cwd: dirname(activeEditor.document.fileName) }, (err, stdout, stderr) => { + if (err && (err).code === 'ENOENT') { + promptForMissingTool('godoctor'); + return resolve('Could not find godoctor'); + } + if (err) { + return resolve(`Could not extract variable : \n\n${stderr}`); + } + }); + if (p.pid) { + p.stdin.end(); + } - }); + }); } \ No newline at end of file