diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 9a3492e5c37..c7713839ce3 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3696,7 +3696,7 @@ "code": 95003 }, - "Extract function into {0}": { + "Extract to {0}": { "category": "Message", "code": 95004 } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 06b8437f76b..d88966e4481 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -4829,16 +4829,29 @@ namespace ts { } /* @internal */ - export function isFunctionLikeKind(kind: SyntaxKind): boolean { + export function isFunctionLikeDeclaration(node: Node): node is FunctionLikeDeclaration { + return node && isFunctionLikeDeclarationKind(node.kind); + } + + function isFunctionLikeDeclarationKind(kind: SyntaxKind): boolean { switch (kind) { - case SyntaxKind.Constructor: - case SyntaxKind.FunctionExpression: case SyntaxKind.FunctionDeclaration: - case SyntaxKind.ArrowFunction: case SyntaxKind.MethodDeclaration: - case SyntaxKind.MethodSignature: + case SyntaxKind.Constructor: case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: + case SyntaxKind.FunctionExpression: + case SyntaxKind.ArrowFunction: + return true; + default: + return false; + } + } + + /* @internal */ + export function isFunctionLikeKind(kind: SyntaxKind): boolean { + switch (kind) { + case SyntaxKind.MethodSignature: case SyntaxKind.CallSignature: case SyntaxKind.ConstructSignature: case SyntaxKind.IndexSignature: @@ -4846,9 +4859,9 @@ namespace ts { case SyntaxKind.JSDocFunctionType: case SyntaxKind.ConstructorType: return true; + default: + return isFunctionLikeDeclarationKind(kind); } - - return false; } // Classes diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index 83908def444..8521e2fac0b 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -40,7 +40,7 @@ namespace ts.refactor.extractMethod { // Don't issue refactorings with duplicated names. // Scopes come back in "innermost first" order, so extractions will // preferentially go into nearer scopes - const description = formatStringFromArgs(Diagnostics.Extract_function_into_0.message, [extr.scopeDescription]); + const description = formatStringFromArgs(Diagnostics.Extract_to_0.message, [extr.scopeDescription]); if (!usedNames.has(description)) { usedNames.set(description, true); actions.push({ @@ -543,44 +543,45 @@ namespace ts.refactor.extractMethod { } } - function getDescriptionForScope(scope: Scope) { - if (isFunctionLike(scope)) { - switch (scope.kind) { - case SyntaxKind.Constructor: - return "constructor"; - case SyntaxKind.FunctionExpression: - return scope.name - ? `function expression ${scope.name.text}` - : "anonymous function expression"; - case SyntaxKind.FunctionDeclaration: - return `function '${scope.name.text}'`; - case SyntaxKind.ArrowFunction: - return "arrow function"; - case SyntaxKind.MethodDeclaration: - return `method '${scope.name.getText()}`; - case SyntaxKind.GetAccessor: - return `'get ${scope.name.getText()}'`; - case SyntaxKind.SetAccessor: - return `'set ${scope.name.getText()}'`; - } - } - else if (isModuleBlock(scope)) { - return `namespace '${scope.parent.name.getText()}'`; - } - else if (isClassLike(scope)) { - return scope.kind === SyntaxKind.ClassDeclaration - ? `class '${scope.name.text}'` - : scope.name && scope.name.text - ? `class expression '${scope.name.text}'` - : "anonymous class expression"; - } - else if (isSourceFile(scope)) { - return scope.externalModuleIndicator ? "module scope" : "global scope"; - } - else { - return "unknown"; + function getDescriptionForScope(scope: Scope): string { + return isFunctionLikeDeclaration(scope) + ? `inner function in ${getDescriptionForFunctionLikeDeclaration(scope)}` + : isClassLike(scope) + ? `method in ${getDescriptionForClassLikeDeclaration(scope)}` + : `function in ${getDescriptionForModuleLikeDeclaration(scope)}`; + } + function getDescriptionForFunctionLikeDeclaration(scope: FunctionLikeDeclaration): string { + switch (scope.kind) { + case SyntaxKind.Constructor: + return "constructor"; + case SyntaxKind.FunctionExpression: + return scope.name + ? `function expression '${scope.name.text}'` + : "anonymous function expression"; + case SyntaxKind.FunctionDeclaration: + return `function '${scope.name.text}'`; + case SyntaxKind.ArrowFunction: + return "arrow function"; + case SyntaxKind.MethodDeclaration: + return `method '${scope.name.getText()}`; + case SyntaxKind.GetAccessor: + return `'get ${scope.name.getText()}'`; + case SyntaxKind.SetAccessor: + return `'set ${scope.name.getText()}'`; + default: + Debug.assertNever(scope); } } + function getDescriptionForClassLikeDeclaration(scope: ClassLikeDeclaration): string { + return scope.kind === SyntaxKind.ClassDeclaration + ? `class '${scope.name.text}'` + : scope.name ? `class expression '${scope.name.text}'` : "anonymous class expression"; + } + function getDescriptionForModuleLikeDeclaration(scope: SourceFile | ModuleBlock): string { + return scope.kind === SyntaxKind.ModuleBlock + ? `namespace '${scope.parent.name.getText()}'` + : scope.externalModuleIndicator ? "module scope" : "global scope"; + } function getUniqueName(isNameOkay: (name: string) => boolean) { let functionNameText = "newFunction"; diff --git a/tests/baselines/reference/extractMethod/extractMethod1.ts b/tests/baselines/reference/extractMethod/extractMethod1.ts index bfe80cb6c9b..660380c1253 100644 --- a/tests/baselines/reference/extractMethod/extractMethod1.ts +++ b/tests/baselines/reference/extractMethod/extractMethod1.ts @@ -14,7 +14,7 @@ namespace A { } } } -// ==SCOPE::function 'a'== +// ==SCOPE::inner function in function 'a'== namespace A { let x = 1; function foo() { @@ -34,7 +34,7 @@ namespace A { } } } -// ==SCOPE::namespace 'B'== +// ==SCOPE::function in namespace 'B'== namespace A { let x = 1; function foo() { @@ -55,7 +55,7 @@ namespace A { } } } -// ==SCOPE::namespace 'A'== +// ==SCOPE::function in namespace 'A'== namespace A { let x = 1; function foo() { @@ -76,7 +76,7 @@ namespace A { return a; } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== namespace A { let x = 1; function foo() { diff --git a/tests/baselines/reference/extractMethod/extractMethod10.ts b/tests/baselines/reference/extractMethod/extractMethod10.ts index 97bd5cbd503..13108a08131 100644 --- a/tests/baselines/reference/extractMethod/extractMethod10.ts +++ b/tests/baselines/reference/extractMethod/extractMethod10.ts @@ -9,7 +9,7 @@ namespace A { } } } -// ==SCOPE::class 'C'== +// ==SCOPE::method in class 'C'== namespace A { export interface I { x: number }; class C { @@ -24,7 +24,7 @@ namespace A { } } } -// ==SCOPE::namespace 'A'== +// ==SCOPE::function in namespace 'A'== namespace A { export interface I { x: number }; class C { @@ -39,7 +39,7 @@ namespace A { return a1.x + 10; } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== namespace A { export interface I { x: number }; class C { diff --git a/tests/baselines/reference/extractMethod/extractMethod11.ts b/tests/baselines/reference/extractMethod/extractMethod11.ts index 4999df4a706..5a2e0da826a 100644 --- a/tests/baselines/reference/extractMethod/extractMethod11.ts +++ b/tests/baselines/reference/extractMethod/extractMethod11.ts @@ -11,7 +11,7 @@ namespace A { } } } -// ==SCOPE::class 'C'== +// ==SCOPE::method in class 'C'== namespace A { let y = 1; class C { @@ -30,7 +30,7 @@ namespace A { } } } -// ==SCOPE::namespace 'A'== +// ==SCOPE::function in namespace 'A'== namespace A { let y = 1; class C { @@ -49,7 +49,7 @@ namespace A { return { __return: a1.x + 10, z }; } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== namespace A { let y = 1; class C { diff --git a/tests/baselines/reference/extractMethod/extractMethod12.ts b/tests/baselines/reference/extractMethod/extractMethod12.ts index 2b95a545ce1..98428a67bd0 100644 --- a/tests/baselines/reference/extractMethod/extractMethod12.ts +++ b/tests/baselines/reference/extractMethod/extractMethod12.ts @@ -13,7 +13,7 @@ namespace A { } } } -// ==SCOPE::class 'C'== +// ==SCOPE::method in class 'C'== namespace A { let y = 1; class C { diff --git a/tests/baselines/reference/extractMethod/extractMethod13.ts b/tests/baselines/reference/extractMethod/extractMethod13.ts index 8f76dea88aa..44968ac4dcf 100644 --- a/tests/baselines/reference/extractMethod/extractMethod13.ts +++ b/tests/baselines/reference/extractMethod/extractMethod13.ts @@ -14,7 +14,7 @@ } } } -// ==SCOPE::function 'F2'== +// ==SCOPE::inner function in function 'F2'== (u1a: U1a, u1b: U1b) => { function F1(t1a: T1a, t1b: T1b) { (u2a: U2a, u2b: U2b) => { @@ -34,7 +34,7 @@ } } } -// ==SCOPE::function 'F1'== +// ==SCOPE::inner function in function 'F1'== (u1a: U1a, u1b: U1b) => { function F1(t1a: T1a, t1b: T1b) { (u2a: U2a, u2b: U2b) => { @@ -54,7 +54,7 @@ } } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== (u1a: U1a, u1b: U1b) => { function F1(t1a: T1a, t1b: T1b) { (u2a: U2a, u2b: U2b) => { diff --git a/tests/baselines/reference/extractMethod/extractMethod14.ts b/tests/baselines/reference/extractMethod/extractMethod14.ts index 38e4c380ebc..4db0e748907 100644 --- a/tests/baselines/reference/extractMethod/extractMethod14.ts +++ b/tests/baselines/reference/extractMethod/extractMethod14.ts @@ -5,7 +5,7 @@ function F(t1: T) { t2.toString(); } } -// ==SCOPE::function 'F'== +// ==SCOPE::inner function in function 'F'== function F(t1: T) { function F(t2: T) { newFunction(); @@ -16,7 +16,7 @@ function F(t1: T) { } } } -// ==SCOPE::function 'F'== +// ==SCOPE::inner function in function 'F'== function F(t1: T) { function F(t2: T) { newFunction(t2); @@ -27,7 +27,7 @@ function F(t1: T) { t2.toString(); } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== function F(t1: T) { function F(t2: T) { newFunction(t1, t2); diff --git a/tests/baselines/reference/extractMethod/extractMethod15.ts b/tests/baselines/reference/extractMethod/extractMethod15.ts index ba5b9b3ad01..7d1c8aa4507 100644 --- a/tests/baselines/reference/extractMethod/extractMethod15.ts +++ b/tests/baselines/reference/extractMethod/extractMethod15.ts @@ -4,7 +4,7 @@ function F(t1: T) { t2.toString(); } } -// ==SCOPE::function 'F'== +// ==SCOPE::inner function in function 'F'== function F(t1: T) { function F(t2: U) { newFunction(); @@ -14,7 +14,7 @@ function F(t1: T) { } } } -// ==SCOPE::function 'F'== +// ==SCOPE::inner function in function 'F'== function F(t1: T) { function F(t2: U) { newFunction(t2); @@ -24,7 +24,7 @@ function F(t1: T) { t2.toString(); } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== function F(t1: T) { function F(t2: U) { newFunction(t2); diff --git a/tests/baselines/reference/extractMethod/extractMethod16.ts b/tests/baselines/reference/extractMethod/extractMethod16.ts index 1ce88b93145..2ecb0703660 100644 --- a/tests/baselines/reference/extractMethod/extractMethod16.ts +++ b/tests/baselines/reference/extractMethod/extractMethod16.ts @@ -2,7 +2,7 @@ function F() { const array: T[] = []; } -// ==SCOPE::function 'F'== +// ==SCOPE::inner function in function 'F'== function F() { const array: T[] = newFunction(); @@ -10,7 +10,7 @@ function F() { return []; } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== function F() { const array: T[] = newFunction(); } diff --git a/tests/baselines/reference/extractMethod/extractMethod17.ts b/tests/baselines/reference/extractMethod/extractMethod17.ts index d800c79f3bd..d0401b6b472 100644 --- a/tests/baselines/reference/extractMethod/extractMethod17.ts +++ b/tests/baselines/reference/extractMethod/extractMethod17.ts @@ -4,7 +4,7 @@ class C { t1.toString(); } } -// ==SCOPE::class 'C'== +// ==SCOPE::method in class 'C'== class C { M(t1: T1, t2: T2) { this.newFunction(t1); @@ -14,7 +14,7 @@ class C { t1.toString(); } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== class C { M(t1: T1, t2: T2) { newFunction(t1); diff --git a/tests/baselines/reference/extractMethod/extractMethod18.ts b/tests/baselines/reference/extractMethod/extractMethod18.ts index ce6a90c3790..85ef9a5d5c0 100644 --- a/tests/baselines/reference/extractMethod/extractMethod18.ts +++ b/tests/baselines/reference/extractMethod/extractMethod18.ts @@ -4,7 +4,7 @@ class C { t1.toString(); } } -// ==SCOPE::class 'C'== +// ==SCOPE::method in class 'C'== class C { M(t1: T1, t2: T2) { this.newFunction(t1); @@ -14,7 +14,7 @@ class C { t1.toString(); } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== class C { M(t1: T1, t2: T2) { newFunction(t1); diff --git a/tests/baselines/reference/extractMethod/extractMethod19.ts b/tests/baselines/reference/extractMethod/extractMethod19.ts index 1bf25550172..80d3c61d1ee 100644 --- a/tests/baselines/reference/extractMethod/extractMethod19.ts +++ b/tests/baselines/reference/extractMethod/extractMethod19.ts @@ -2,7 +2,7 @@ function F(v: V) { v.toString(); } -// ==SCOPE::function 'F'== +// ==SCOPE::inner function in function 'F'== function F(v: V) { newFunction(); @@ -10,7 +10,7 @@ function F(v: V) { v.toString(); } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== function F(v: V) { newFunction(v); } diff --git a/tests/baselines/reference/extractMethod/extractMethod2.ts b/tests/baselines/reference/extractMethod/extractMethod2.ts index 3b61a98d001..17ca6a6ba22 100644 --- a/tests/baselines/reference/extractMethod/extractMethod2.ts +++ b/tests/baselines/reference/extractMethod/extractMethod2.ts @@ -12,7 +12,7 @@ namespace A { } } } -// ==SCOPE::function 'a'== +// ==SCOPE::inner function in function 'a'== namespace A { let x = 1; function foo() { @@ -30,7 +30,7 @@ namespace A { } } } -// ==SCOPE::namespace 'B'== +// ==SCOPE::function in namespace 'B'== namespace A { let x = 1; function foo() { @@ -48,7 +48,7 @@ namespace A { } } } -// ==SCOPE::namespace 'A'== +// ==SCOPE::function in namespace 'A'== namespace A { let x = 1; function foo() { @@ -66,7 +66,7 @@ namespace A { return foo(); } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== namespace A { let x = 1; function foo() { diff --git a/tests/baselines/reference/extractMethod/extractMethod20.ts b/tests/baselines/reference/extractMethod/extractMethod20.ts index 7c35caee30f..7d65bfca1a9 100644 --- a/tests/baselines/reference/extractMethod/extractMethod20.ts +++ b/tests/baselines/reference/extractMethod/extractMethod20.ts @@ -5,7 +5,7 @@ const _ = class { return a1.x + 10; } } -// ==SCOPE::anonymous class expression== +// ==SCOPE::method in anonymous class expression== const _ = class { a() { return this.newFunction(); @@ -16,7 +16,7 @@ const _ = class { return a1.x + 10; } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== const _ = class { a() { return newFunction(); diff --git a/tests/baselines/reference/extractMethod/extractMethod21.ts b/tests/baselines/reference/extractMethod/extractMethod21.ts index 4b73a6ed3c7..6fb5fc43155 100644 --- a/tests/baselines/reference/extractMethod/extractMethod21.ts +++ b/tests/baselines/reference/extractMethod/extractMethod21.ts @@ -4,7 +4,7 @@ function foo() { x++; return; } -// ==SCOPE::function 'foo'== +// ==SCOPE::inner function in function 'foo'== function foo() { let x = 10; return newFunction(); @@ -14,7 +14,7 @@ function foo() { return; } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== function foo() { let x = 10; x = newFunction(x); diff --git a/tests/baselines/reference/extractMethod/extractMethod22.ts b/tests/baselines/reference/extractMethod/extractMethod22.ts index 7603c01681f..1bb76ef67ba 100644 --- a/tests/baselines/reference/extractMethod/extractMethod22.ts +++ b/tests/baselines/reference/extractMethod/extractMethod22.ts @@ -6,7 +6,7 @@ function test() { return 1; } } -// ==SCOPE::function 'test'== +// ==SCOPE::inner function in function 'test'== function test() { try { } @@ -18,7 +18,7 @@ function test() { return 1; } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== function test() { try { } diff --git a/tests/baselines/reference/extractMethod/extractMethod3.ts b/tests/baselines/reference/extractMethod/extractMethod3.ts index 0837fbfc10d..0d8481c9841 100644 --- a/tests/baselines/reference/extractMethod/extractMethod3.ts +++ b/tests/baselines/reference/extractMethod/extractMethod3.ts @@ -11,7 +11,7 @@ namespace A { } } } -// ==SCOPE::function 'a'== +// ==SCOPE::inner function in function 'a'== namespace A { function foo() { } @@ -28,7 +28,7 @@ namespace A { } } } -// ==SCOPE::namespace 'B'== +// ==SCOPE::function in namespace 'B'== namespace A { function foo() { } @@ -45,7 +45,7 @@ namespace A { } } } -// ==SCOPE::namespace 'A'== +// ==SCOPE::function in namespace 'A'== namespace A { function foo() { } @@ -62,7 +62,7 @@ namespace A { return foo(); } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== namespace A { function foo() { } diff --git a/tests/baselines/reference/extractMethod/extractMethod4.ts b/tests/baselines/reference/extractMethod/extractMethod4.ts index 4e9811501f4..4f6a5d85f89 100644 --- a/tests/baselines/reference/extractMethod/extractMethod4.ts +++ b/tests/baselines/reference/extractMethod/extractMethod4.ts @@ -13,7 +13,7 @@ namespace A { } } } -// ==SCOPE::function 'a'== +// ==SCOPE::inner function in function 'a'== namespace A { function foo() { } @@ -32,7 +32,7 @@ namespace A { } } } -// ==SCOPE::namespace 'B'== +// ==SCOPE::function in namespace 'B'== namespace A { function foo() { } @@ -51,7 +51,7 @@ namespace A { } } } -// ==SCOPE::namespace 'A'== +// ==SCOPE::function in namespace 'A'== namespace A { function foo() { } @@ -70,7 +70,7 @@ namespace A { return foo(); } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== namespace A { function foo() { } diff --git a/tests/baselines/reference/extractMethod/extractMethod5.ts b/tests/baselines/reference/extractMethod/extractMethod5.ts index 77b2f7b5545..10ff0005f73 100644 --- a/tests/baselines/reference/extractMethod/extractMethod5.ts +++ b/tests/baselines/reference/extractMethod/extractMethod5.ts @@ -14,7 +14,7 @@ namespace A { } } } -// ==SCOPE::function 'a'== +// ==SCOPE::inner function in function 'a'== namespace A { let x = 1; export function foo() { @@ -34,7 +34,7 @@ namespace A { } } } -// ==SCOPE::namespace 'B'== +// ==SCOPE::function in namespace 'B'== namespace A { let x = 1; export function foo() { @@ -55,7 +55,7 @@ namespace A { } } } -// ==SCOPE::namespace 'A'== +// ==SCOPE::function in namespace 'A'== namespace A { let x = 1; export function foo() { @@ -76,7 +76,7 @@ namespace A { return a; } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== namespace A { let x = 1; export function foo() { diff --git a/tests/baselines/reference/extractMethod/extractMethod6.ts b/tests/baselines/reference/extractMethod/extractMethod6.ts index 3c8c0a99b70..40135e6ec97 100644 --- a/tests/baselines/reference/extractMethod/extractMethod6.ts +++ b/tests/baselines/reference/extractMethod/extractMethod6.ts @@ -14,7 +14,7 @@ namespace A { } } } -// ==SCOPE::function 'a'== +// ==SCOPE::inner function in function 'a'== namespace A { let x = 1; export function foo() { @@ -34,7 +34,7 @@ namespace A { } } } -// ==SCOPE::namespace 'B'== +// ==SCOPE::function in namespace 'B'== namespace A { let x = 1; export function foo() { @@ -56,7 +56,7 @@ namespace A { } } } -// ==SCOPE::namespace 'A'== +// ==SCOPE::function in namespace 'A'== namespace A { let x = 1; export function foo() { @@ -78,7 +78,7 @@ namespace A { return { __return: foo(), a }; } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== namespace A { let x = 1; export function foo() { diff --git a/tests/baselines/reference/extractMethod/extractMethod7.ts b/tests/baselines/reference/extractMethod/extractMethod7.ts index 3f1e25991bd..d01532da796 100644 --- a/tests/baselines/reference/extractMethod/extractMethod7.ts +++ b/tests/baselines/reference/extractMethod/extractMethod7.ts @@ -16,7 +16,7 @@ namespace A { } } } -// ==SCOPE::function 'a'== +// ==SCOPE::inner function in function 'a'== namespace A { let x = 1; export namespace C { @@ -38,7 +38,7 @@ namespace A { } } } -// ==SCOPE::namespace 'B'== +// ==SCOPE::function in namespace 'B'== namespace A { let x = 1; export namespace C { @@ -62,7 +62,7 @@ namespace A { } } } -// ==SCOPE::namespace 'A'== +// ==SCOPE::function in namespace 'A'== namespace A { let x = 1; export namespace C { @@ -86,7 +86,7 @@ namespace A { return { __return: C.foo(), a }; } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== namespace A { let x = 1; export namespace C { diff --git a/tests/baselines/reference/extractMethod/extractMethod8.ts b/tests/baselines/reference/extractMethod/extractMethod8.ts index e6d933ec309..d59ca5dc238 100644 --- a/tests/baselines/reference/extractMethod/extractMethod8.ts +++ b/tests/baselines/reference/extractMethod/extractMethod8.ts @@ -8,7 +8,7 @@ namespace A { } } } -// ==SCOPE::function 'a'== +// ==SCOPE::inner function in function 'a'== namespace A { let x = 1; namespace B { @@ -22,7 +22,7 @@ namespace A { } } } -// ==SCOPE::namespace 'B'== +// ==SCOPE::function in namespace 'B'== namespace A { let x = 1; namespace B { @@ -36,7 +36,7 @@ namespace A { } } } -// ==SCOPE::namespace 'A'== +// ==SCOPE::function in namespace 'A'== namespace A { let x = 1; namespace B { @@ -50,7 +50,7 @@ namespace A { return 1 + a1 + x; } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== namespace A { let x = 1; namespace B { diff --git a/tests/baselines/reference/extractMethod/extractMethod9.ts b/tests/baselines/reference/extractMethod/extractMethod9.ts index 6d0672f11c1..342e3c10eee 100644 --- a/tests/baselines/reference/extractMethod/extractMethod9.ts +++ b/tests/baselines/reference/extractMethod/extractMethod9.ts @@ -8,7 +8,7 @@ namespace A { } } } -// ==SCOPE::function 'a'== +// ==SCOPE::inner function in function 'a'== namespace A { export interface I { x: number }; namespace B { @@ -22,7 +22,7 @@ namespace A { } } } -// ==SCOPE::namespace 'B'== +// ==SCOPE::function in namespace 'B'== namespace A { export interface I { x: number }; namespace B { @@ -36,7 +36,7 @@ namespace A { } } } -// ==SCOPE::namespace 'A'== +// ==SCOPE::function in namespace 'A'== namespace A { export interface I { x: number }; namespace B { @@ -50,7 +50,7 @@ namespace A { return a1.x + 10; } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== namespace A { export interface I { x: number }; namespace B { diff --git a/tests/cases/fourslash/extract-method-formatting.ts b/tests/cases/fourslash/extract-method-formatting.ts index 1342e5632e8..a346ad3bbd9 100644 --- a/tests/cases/fourslash/extract-method-formatting.ts +++ b/tests/cases/fourslash/extract-method-formatting.ts @@ -9,7 +9,7 @@ goTo.select('start', 'end') edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_1", - actionDescription: "Extract function into global scope", + actionDescription: "Extract to function in global scope", }); verify.currentFileContentIs( `function f(x: number): number { diff --git a/tests/cases/fourslash/extract-method1.ts b/tests/cases/fourslash/extract-method1.ts index ff061295c8c..64dffc15a90 100644 --- a/tests/cases/fourslash/extract-method1.ts +++ b/tests/cases/fourslash/extract-method1.ts @@ -16,7 +16,7 @@ goTo.select('start', 'end') edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", - actionDescription: "Extract function into class 'Foo'", + actionDescription: "Extract to method in class 'Foo'", }); verify.currentFileContentIs( `class Foo { diff --git a/tests/cases/fourslash/extract-method10.ts b/tests/cases/fourslash/extract-method10.ts index ffbee7350e2..73ef3029e24 100644 --- a/tests/cases/fourslash/extract-method10.ts +++ b/tests/cases/fourslash/extract-method10.ts @@ -7,5 +7,5 @@ goTo.select('1', '2'); edit.applyRefactor({ refactorName: "Extract Method", actionName: 'scope_0', - actionDescription: "Extract function into module scope", + actionDescription: "Extract to function in module scope", }); diff --git a/tests/cases/fourslash/extract-method13.ts b/tests/cases/fourslash/extract-method13.ts index 94ad86e4399..707921546c5 100644 --- a/tests/cases/fourslash/extract-method13.ts +++ b/tests/cases/fourslash/extract-method13.ts @@ -13,14 +13,14 @@ goTo.select('a', 'b'); edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", - actionDescription: "Extract function into class 'C'", + actionDescription: "Extract to method in class 'C'", }); goTo.select('c', 'd'); edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", - actionDescription: "Extract function into class 'C'", + actionDescription: "Extract to method in class 'C'", }); verify.currentFileContentIs(`class C { diff --git a/tests/cases/fourslash/extract-method14.ts b/tests/cases/fourslash/extract-method14.ts index 696bb664bd3..770ed3d0fcb 100644 --- a/tests/cases/fourslash/extract-method14.ts +++ b/tests/cases/fourslash/extract-method14.ts @@ -14,7 +14,7 @@ goTo.select('a', 'b'); edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_1", - actionDescription: "Extract function into global scope", + actionDescription: "Extract to function in global scope", }); verify.currentFileContentIs(`function foo() { var i = 10; diff --git a/tests/cases/fourslash/extract-method15.ts b/tests/cases/fourslash/extract-method15.ts index 93aa357cfee..8d3db633b11 100644 --- a/tests/cases/fourslash/extract-method15.ts +++ b/tests/cases/fourslash/extract-method15.ts @@ -12,7 +12,7 @@ goTo.select('a', 'b'); edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_1", - actionDescription: "Extract function into global scope", + actionDescription: "Extract to function in global scope", }); verify.currentFileContentIs(`function foo() { diff --git a/tests/cases/fourslash/extract-method18.ts b/tests/cases/fourslash/extract-method18.ts index d99d14bac73..6d4d06ca7bf 100644 --- a/tests/cases/fourslash/extract-method18.ts +++ b/tests/cases/fourslash/extract-method18.ts @@ -12,7 +12,7 @@ goTo.select('a', 'b') edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_1", - actionDescription: "Extract function into global scope", + actionDescription: "Extract to function in global scope", }); verify.currentFileContentIs(`function fn() { const x = { m: 1 }; diff --git a/tests/cases/fourslash/extract-method19.ts b/tests/cases/fourslash/extract-method19.ts index e4fb3e6e111..da999fcc093 100644 --- a/tests/cases/fourslash/extract-method19.ts +++ b/tests/cases/fourslash/extract-method19.ts @@ -12,7 +12,7 @@ goTo.select('a', 'b') edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", - actionDescription: "Extract function into function 'fn'", + actionDescription: "Extract to inner function in function 'fn'", }); verify.currentFileContentIs(`function fn() { newFunction_1(); diff --git a/tests/cases/fourslash/extract-method2.ts b/tests/cases/fourslash/extract-method2.ts index 508836c4199..021716b6e48 100644 --- a/tests/cases/fourslash/extract-method2.ts +++ b/tests/cases/fourslash/extract-method2.ts @@ -13,7 +13,7 @@ goTo.select('start', 'end') edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_2", - actionDescription: "Extract function into global scope", + actionDescription: "Extract to function in global scope", }); verify.currentFileContentIs( `namespace NS { diff --git a/tests/cases/fourslash/extract-method21.ts b/tests/cases/fourslash/extract-method21.ts index c32df5b5979..f19d4b05912 100644 --- a/tests/cases/fourslash/extract-method21.ts +++ b/tests/cases/fourslash/extract-method21.ts @@ -15,7 +15,7 @@ verify.refactorAvailable('Extract Method'); edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", - actionDescription: "Extract function into class 'Foo'", + actionDescription: "Extract to method in class 'Foo'", }); verify.currentFileContentIs(`class Foo { diff --git a/tests/cases/fourslash/extract-method24.ts b/tests/cases/fourslash/extract-method24.ts index 615cb2ac4d2..e5f923bb80d 100644 --- a/tests/cases/fourslash/extract-method24.ts +++ b/tests/cases/fourslash/extract-method24.ts @@ -10,7 +10,7 @@ goTo.select('a', 'b') edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_1", - actionDescription: "Extract function into global scope", + actionDescription: "Extract to function in global scope", }); verify.currentFileContentIs(`function M() { let a = [1,2,3]; diff --git a/tests/cases/fourslash/extract-method25.ts b/tests/cases/fourslash/extract-method25.ts index 8585dd06fd4..d18d0691e61 100644 --- a/tests/cases/fourslash/extract-method25.ts +++ b/tests/cases/fourslash/extract-method25.ts @@ -11,7 +11,7 @@ goTo.select('a', 'b') edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", - actionDescription: "Extract function into function 'fn'", + actionDescription: "Extract to inner function in function 'fn'", }); verify.currentFileContentIs(`function fn() { var q = newFunction() diff --git a/tests/cases/fourslash/extract-method5.ts b/tests/cases/fourslash/extract-method5.ts index 8b0bd4fec6d..014dfb35d08 100644 --- a/tests/cases/fourslash/extract-method5.ts +++ b/tests/cases/fourslash/extract-method5.ts @@ -12,7 +12,7 @@ goTo.select('start', 'end'); edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", - actionDescription: "Extract function into function 'f'", + actionDescription: "Extract to inner function in function 'f'", }); // TODO: GH#18091 (fix formatting to use `2 ? 1 :` and not `2?1:`) verify.currentFileContentIs( diff --git a/tests/cases/fourslash/extract-method7.ts b/tests/cases/fourslash/extract-method7.ts index d10c7c3136e..d8459bf77ad 100644 --- a/tests/cases/fourslash/extract-method7.ts +++ b/tests/cases/fourslash/extract-method7.ts @@ -10,7 +10,7 @@ goTo.select('a', 'b'); edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", - actionDescription: "Extract function into global scope", + actionDescription: "Extract to function in global scope", }); verify.currentFileContentIs(`function fn(x = newFunction()) { }