From 8cb019d79319a09438e4031828c4655c2976a7d6 Mon Sep 17 00:00:00 2001 From: BigAru Date: Wed, 17 Oct 2018 09:27:08 +0200 Subject: [PATCH] add skeleton --- src/compiler/diagnosticMessages.json | 18 +++++++- .../convertArrowFunctionOrFunction.ts | 41 +++++++++++++++++++ src/services/tsconfig.json | 1 + 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 src/services/refactors/convertArrowFunctionOrFunction.ts diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 1f1ee7a6948..8b713557f32 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -4720,5 +4720,21 @@ "Generate types for all packages without types": { "category": "Message", "code": 95068 + }, + "Convert arrow function or anonymous function": { + "category": "Message", + "code": 95069 + }, + "Convert to anonymous function": { + "category": "Message", + "code": 95070 + }, + "Convert to named function": { + "category": "Message", + "code": 95071 + }, + "Convert to arrow function": { + "category": "Message", + "code": 95072 } -} +} \ No newline at end of file diff --git a/src/services/refactors/convertArrowFunctionOrFunction.ts b/src/services/refactors/convertArrowFunctionOrFunction.ts new file mode 100644 index 00000000000..77fd7b0cdb4 --- /dev/null +++ b/src/services/refactors/convertArrowFunctionOrFunction.ts @@ -0,0 +1,41 @@ +/* @internal */ +namespace ts.refactor.convertArrowFunctionOrFunction { + const refactorName = "Convert arrow function or anonymous function"; + const refactorDescription = Diagnostics.Convert_arrow_function_or_anonymous_function.message; + + const toAnonymousFunctionActionName = "Convert to anonymous function"; + const toNamedFunctionActionName = "Convert to named function"; + const toArrowFunctionActionName = "Convert to arrow function"; + + const toAnonymousFunctionActionDescription = Diagnostics.Convert_to_anonymous_function.message; + const toNamedFunctionActionDescription = Diagnostics.Convert_to_named_function.message; + const toArrowFunctionActionDescription = Diagnostics.Convert_to_arrow_function.message; + + registerRefactor(refactorName, { getEditsForAction, getAvailableActions }); + + function getAvailableActions(context: RefactorContext): ApplicableRefactorInfo[] | undefined { + return [{ + name: refactorName, + description: refactorDescription, + actions: [ + { + name: toAnonymousFunctionActionName, + description: toAnonymousFunctionActionDescription + }, + { + name: toNamedFunctionActionName, + description: toNamedFunctionActionDescription + }, + { + name: toArrowFunctionActionName, + description: toArrowFunctionActionDescription + } + ] + }]; + } + + function getEditsForAction(context: RefactorContext, actionName: string): RefactorEditInfo | undefined { + return undefined; + } + +} diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index 66b1977ddc5..0caa9f8e901 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -80,6 +80,7 @@ "refactors/generateGetAccessorAndSetAccessor.ts", "refactors/moveToNewFile.ts", "refactors/addOrRemoveBracesToArrowFunction.ts", + "refactors/convertArrowFunctionOrFunction.ts", "services.ts", "breakpoints.ts", "transform.ts",