From 605ab0b1fce65dcf7bb87e6bbe3273e3ad34ddcc Mon Sep 17 00:00:00 2001 From: Yui T Date: Wed, 1 Jul 2015 13:55:02 -0700 Subject: [PATCH] Fix rename for class expression --- src/services/services.ts | 6 ++--- .../renameLocationsForClassExpression01.ts | 26 +++++++------------ 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index e1dfec82e12..6e2698c9e6c 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -5117,10 +5117,10 @@ namespace ts { * a reference to a symbol can occur anywhere. */ function getSymbolScope(symbol: Symbol): Node { - // If this is the symbol of a function expression, then named references - // are limited to its own scope. + // If this is the symbol of a named function expression or named class expression, + // then named references are limited to its own scope. let valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && valueDeclaration.kind === SyntaxKind.FunctionExpression) { + if (valueDeclaration && (valueDeclaration.kind === SyntaxKind.FunctionExpression || valueDeclaration.kind === SyntaxKind.ClassExpression)) { return valueDeclaration; } diff --git a/tests/cases/fourslash/renameLocationsForClassExpression01.ts b/tests/cases/fourslash/renameLocationsForClassExpression01.ts index a1174d503ed..6bedc077d4d 100644 --- a/tests/cases/fourslash/renameLocationsForClassExpression01.ts +++ b/tests/cases/fourslash/renameLocationsForClassExpression01.ts @@ -3,13 +3,14 @@ ////class Foo { ////} //// -////var x = class /**/Foo { +//////The class expression Foo +////var x = class [|Foo|] { //// doIt() { -//// return Foo; +//// return [|Foo|]; //// } //// //// static doItStatically() { -//// return Foo; +//// return [|Foo|].y; //// } ////} //// @@ -18,17 +19,10 @@ //// return Foo //// } ////} +////var z = class Foo {} - -// TODO (yuit): Fix up this test when class expressions are supported. -// Just uncomment the below, remove the marker, and add the -// appropriate ranges in the test itself. -goTo.marker(); -verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); - -////let ranges = test.ranges() -////for (let range of ranges) { -//// goTo.position(range.start); -//// -//// verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); -////} \ No newline at end of file +let ranges = test.ranges() +for (let range of ranges) { + goTo.position(range.start); + verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); +} \ No newline at end of file