Skip to content

Commit

Permalink
rename convert to named parameters (#30401)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabritto authored Mar 14, 2019
1 parent 7ab2ad7 commit 1c8a359
Show file tree
Hide file tree
Showing 40 changed files with 109 additions and 109 deletions.
2 changes: 1 addition & 1 deletion src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -4927,7 +4927,7 @@
"category": "Message",
"code": 95074
},
"Convert to named parameters": {
"Convert parameters to destructured object": {
"category": "Message",
"code": 95075
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* @internal */
namespace ts.refactor.convertToNamedParameters {
const refactorName = "Convert to named parameters";
namespace ts.refactor.convertParamsToDestructuredObject {
const refactorName = "Convert parameters to destructured object";
const minimumParameterLength = 2;
registerRefactor(refactorName, { getEditsForAction, getAvailableActions });

Expand All @@ -12,7 +12,7 @@ namespace ts.refactor.convertToNamedParameters {
const functionDeclaration = getFunctionDeclarationAtPosition(file, startPosition, context.program.getTypeChecker());
if (!functionDeclaration) return emptyArray;

const description = getLocaleSpecificMessage(Diagnostics.Convert_to_named_parameters);
const description = getLocaleSpecificMessage(Diagnostics.Convert_parameters_to_destructured_object);
return [{
name: refactorName,
description,
Expand Down
2 changes: 1 addition & 1 deletion src/services/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"refactors/generateGetAccessorAndSetAccessor.ts",
"refactors/moveToNewFile.ts",
"refactors/addOrRemoveBracesToArrowFunction.ts",
"refactors/convertToNamedParameters.ts",
"refactors/convertParamsToDestructuredObject.ts",
"services.ts",
"breakpoints.ts",
"transform.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert to named parameters",
actionName: "Convert to named parameters",
actionDescription: "Convert to named parameters",
refactorName: "Convert parameters to destructured object",
actionName: "Convert parameters to destructured object",
actionDescription: "Convert parameters to destructured object",
newContent: `function f({ a, b = "1" }: { a?: number; b?: string; } = {}): string {
return b;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert to named parameters",
actionName: "Convert to named parameters",
actionDescription: "Convert to named parameters",
refactorName: "Convert parameters to destructured object",
actionName: "Convert parameters to destructured object",
actionDescription: "Convert parameters to destructured object",
newContent: `const foo = ({ a, b }: { a: number; b: number; }) => { };
foo({ a: 1, b: 2 });`
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
////foo(1, 2);

goTo.select("a", "b");
verify.not.refactorAvailable("Convert to named parameters");
verify.not.refactorAvailable("Convert parameters to destructured object");
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert to named parameters",
actionName: "Convert to named parameters",
actionDescription: "Convert to named parameters",
refactorName: "Convert parameters to destructured object",
actionName: "Convert parameters to destructured object",
actionDescription: "Convert parameters to destructured object",
newContent: `function foo({ a, b, rest = [] }: { a: number; b: number; rest?: number[]; }) {
return a + b;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
goTo.select("a", "b");
/* The expected content is currently wrong. The new argument object has the wrong formatting. */
edit.applyRefactor({
refactorName: "Convert to named parameters",
actionName: "Convert to named parameters",
actionDescription: "Convert to named parameters",
refactorName: "Convert parameters to destructured object",
actionName: "Convert parameters to destructured object",
actionDescription: "Convert parameters to destructured object",
newContent: `function foo({ a, b, rest = [] }: { a: number; b: number; rest?: number[]; }) {
return a + b;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert to named parameters",
actionName: "Convert to named parameters",
actionDescription: "Convert to named parameters",
refactorName: "Convert parameters to destructured object",
actionName: "Convert parameters to destructured object",
actionDescription: "Convert parameters to destructured object",
newContent: `function foo({ a, b }: { a: number; b: number; }) {
return { bar: () => a + b };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
goTo.select("a", "b");
// Refactor should not make changes
edit.applyRefactor({
refactorName: "Convert to named parameters",
actionName: "Convert to named parameters",
actionDescription: "Convert to named parameters",
refactorName: "Convert parameters to destructured object",
actionName: "Convert parameters to destructured object",
actionDescription: "Convert parameters to destructured object",
newContent: `class Foo {
constructor(a: number, b: number) { }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert to named parameters",
actionName: "Convert to named parameters",
actionDescription: "Convert to named parameters",
refactorName: "Convert parameters to destructured object",
actionName: "Convert parameters to destructured object",
actionDescription: "Convert parameters to destructured object",
newContent: `class C {
static a: number = 2;
constructor({ a, b }: { a: number; b: number; }) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert to named parameters",
actionName: "Convert to named parameters",
actionDescription: "Convert to named parameters",
refactorName: "Convert parameters to destructured object",
actionName: "Convert parameters to destructured object",
actionDescription: "Convert parameters to destructured object",
newContent: `const c = class {
constructor({ a, b = { x: 1 } }: { a: number; b?: { x: number; }; }) { }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert to named parameters",
actionName: "Convert to named parameters",
actionDescription: "Convert to named parameters",
refactorName: "Convert parameters to destructured object",
actionName: "Convert parameters to destructured object",
actionDescription: "Convert parameters to destructured object",
newContent: `const c = class C {
static a: number = 2;
constructor({ a, b }: { a: number; b: number; }) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
goTo.select("a", "b");
// Refactor should not make changes
edit.applyRefactor({
refactorName: "Convert to named parameters",
actionName: "Convert to named parameters",
actionDescription: "Convert to named parameters",
refactorName: "Convert parameters to destructured object",
actionName: "Convert parameters to destructured object",
actionDescription: "Convert parameters to destructured object",
newContent: `const foo = class Foo {
constructor(a: number, b: number) { }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert to named parameters",
actionName: "Convert to named parameters",
actionDescription: "Convert to named parameters",
refactorName: "Convert parameters to destructured object",
actionName: "Convert parameters to destructured object",
actionDescription: "Convert parameters to destructured object",
newContent: `class Foo<T> {
bar({ t, s }: { t: T; s: T; }) {
return s;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert to named parameters",
actionName: "Convert to named parameters",
actionDescription: "Convert to named parameters",
refactorName: "Convert parameters to destructured object",
actionName: "Convert parameters to destructured object",
actionDescription: "Convert parameters to destructured object",
newContent: `class Foo {
t: string;
s: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
////}

goTo.select("a", "b");
verify.not.refactorAvailable("Convert to named parameters");
verify.not.refactorAvailable("Convert parameters to destructured object");
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert to named parameters",
actionName: "Convert to named parameters",
actionDescription: "Convert to named parameters",
refactorName: "Convert parameters to destructured object",
actionName: "Convert parameters to destructured object",
actionDescription: "Convert parameters to destructured object",
newContent: `function f({ a, b }: { a: number; b: string; }): string {
return b;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert to named parameters",
actionName: "Convert to named parameters",
actionDescription: "Convert to named parameters",
refactorName: "Convert parameters to destructured object",
actionName: "Convert parameters to destructured object",
actionDescription: "Convert parameters to destructured object",
newContent: `foo({ a: 1, b: 2 }); /**a*/
/**b*/ function foo(/**this1*/ this /**this2*/: /**void1*/ void /**void2*/, { a, b = /**k*/ 1 /**l*/ }: { /**c*/ a /**d*/: /**e*/ number /**f*/; /**g*/ b /**h*/?: /**i*/ number /**j*/; }) {
// m
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert to named parameters",
actionName: "Convert to named parameters",
actionDescription: "Convert to named parameters",
refactorName: "Convert parameters to destructured object",
actionName: "Convert parameters to destructured object",
actionDescription: "Convert parameters to destructured object",
newContent: `function foo({ a, b }: { a: number /** a */; b: number /** b */; }) {
return a + b;
}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert to named parameters",
actionName: "Convert to named parameters",
actionDescription: "Convert to named parameters",
refactorName: "Convert parameters to destructured object",
actionName: "Convert parameters to destructured object",
actionDescription: "Convert parameters to destructured object",
newContent: `function foo(// comment
{ a, b }: {
// a comment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert to named parameters",
actionName: "Convert to named parameters",
actionDescription: "Convert to named parameters",
refactorName: "Convert parameters to destructured object",
actionName: "Convert parameters to destructured object",
actionDescription: "Convert parameters to destructured object",
newContent: `const foo = function({ a, b }: { a: number; b: number; }) { };
foo({ a: 1, b: 2 });`
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert to named parameters",
actionName: "Convert to named parameters",
actionDescription: "Convert to named parameters",
refactorName: "Convert parameters to destructured object",
actionName: "Convert parameters to destructured object",
actionDescription: "Convert parameters to destructured object",
newContent: `function foo<T, S>({ t, s }: { t: T; s: S; }) {
return s;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ goTo.select("a", "b");
`new Bar("a", "b")` should be modified by the refactor to be `new Bar({ t: "a", s: "b" })`
*/
edit.applyRefactor({
refactorName: "Convert to named parameters",
actionName: "Convert to named parameters",
actionDescription: "Convert to named parameters",
refactorName: "Convert parameters to destructured object",
actionName: "Convert parameters to destructured object",
actionDescription: "Convert parameters to destructured object",
newContent: `class Foo {
constructor({ t, s }: { t: string; s: string; }) { }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert to named parameters",
actionName: "Convert to named parameters",
actionDescription: "Convert to named parameters",
refactorName: "Convert parameters to destructured object",
actionName: "Convert parameters to destructured object",
actionDescription: "Convert parameters to destructured object",
newContent: `class Foo {
bar({ t, s }: { t: string; s: string; }): string {
return s + t;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert to named parameters",
actionName: "Convert to named parameters",
actionDescription: "Convert to named parameters",
refactorName: "Convert parameters to destructured object",
actionName: "Convert parameters to destructured object",
actionDescription: "Convert parameters to destructured object",
newContent: `function f({ a, b = "1" }: { a: number; b?: string; }): string {
return b;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert to named parameters",
actionName: "Convert to named parameters",
actionDescription: "Convert to named parameters",
refactorName: "Convert parameters to destructured object",
actionName: "Convert parameters to destructured object",
actionDescription: "Convert parameters to destructured object",
newContent: `function f({ a, b = { x: 1, z: { s: true } } }: { a: number; b?: { x: number; z: { s: boolean; }; }; }) {
return b;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert to named parameters",
actionName: "Convert to named parameters",
actionDescription: "Convert to named parameters",
refactorName: "Convert parameters to destructured object",
actionName: "Convert parameters to destructured object",
actionDescription: "Convert parameters to destructured object",
newContent: `class Foo {
bar({ t, s }: { t: string; s: string; }): string {
return s + t;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
goTo.select("a", "b");
// Refactor should not make changes
edit.applyRefactor({
refactorName: "Convert to named parameters",
actionName: "Convert to named parameters",
actionDescription: "Convert to named parameters",
refactorName: "Convert parameters to destructured object",
actionName: "Convert parameters to destructured object",
actionDescription: "Convert parameters to destructured object",
newContent: `class A {
foo(a: number, b: number) { return a + b; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert to named parameters",
actionName: "Convert to named parameters",
actionDescription: "Convert to named parameters",
refactorName: "Convert parameters to destructured object",
actionName: "Convert parameters to destructured object",
actionDescription: "Convert parameters to destructured object",
newContent: `class Foo {
bar({ t, s }: { t: string; s: string; }): string {
return s + t;
Expand Down
Loading

0 comments on commit 1c8a359

Please sign in to comment.