From 2a24e033cdc404262041407da3a2329e8f157ac2 Mon Sep 17 00:00:00 2001 From: zhengbli Date: Tue, 26 Jan 2016 10:51:10 -0800 Subject: [PATCH 1/5] Fix find all references for salsa (cherry picked from commit e4ab2db9fb88520e81427e2c6f252fdbb717dcf8) --- src/compiler/checker.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e0caf84fa9d..c1b8f452919 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -15366,6 +15366,18 @@ namespace ts { return getSymbolOfNode(entityName.parent); } + if (isInJavaScriptFile(entityName) && entityName.parent.kind === SyntaxKind.PropertyAccessExpression) { + const specialPropertyAssignmentKind = getSpecialPropertyAssignmentKind(entityName.parent.parent); + switch (specialPropertyAssignmentKind) { + case SpecialPropertyAssignmentKind.ExportsProperty: + case SpecialPropertyAssignmentKind.ThisProperty: + case SpecialPropertyAssignmentKind.PrototypeProperty: + return getSymbolOfNode(entityName.parent); + case SpecialPropertyAssignmentKind.ModuleExports: + return getSymbolOfNode(entityName.parent.parent); + } + } + if (entityName.parent.kind === SyntaxKind.ExportAssignment) { return resolveEntityName(entityName, /*all meanings*/ SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias); From ea099e7d13ce0faad4862a8fee2cd72b784ded4e Mon Sep 17 00:00:00 2001 From: zhengbli Date: Wed, 27 Jan 2016 12:43:31 -0800 Subject: [PATCH 2/5] Fix for thisProperty (cherry picked from commit b389e9c61984f1ac303e3382b2d3ceaa9a8e0b84) --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c1b8f452919..5b74931bfd9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -15370,9 +15370,9 @@ namespace ts { const specialPropertyAssignmentKind = getSpecialPropertyAssignmentKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { case SpecialPropertyAssignmentKind.ExportsProperty: - case SpecialPropertyAssignmentKind.ThisProperty: case SpecialPropertyAssignmentKind.PrototypeProperty: return getSymbolOfNode(entityName.parent); + case SpecialPropertyAssignmentKind.ThisProperty: case SpecialPropertyAssignmentKind.ModuleExports: return getSymbolOfNode(entityName.parent.parent); } From 98149f6f0b30001102f7e6b12130f0eabf7f25a6 Mon Sep 17 00:00:00 2001 From: zhengbli Date: Wed, 27 Jan 2016 13:26:41 -0800 Subject: [PATCH 3/5] add tests (cherry picked from commit 9a6815f3c7887c757cbe5a56dc6f6b4e67f6d2bc) --- tests/cases/fourslash/renameJsExports.ts | 12 ++++++++++++ tests/cases/fourslash/renameJsPrototypeProperty.ts | 12 ++++++++++++ tests/cases/fourslash/renameJsThisProperty.ts | 12 ++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 tests/cases/fourslash/renameJsExports.ts create mode 100644 tests/cases/fourslash/renameJsPrototypeProperty.ts create mode 100644 tests/cases/fourslash/renameJsThisProperty.ts diff --git a/tests/cases/fourslash/renameJsExports.ts b/tests/cases/fourslash/renameJsExports.ts new file mode 100644 index 00000000000..227eebe4a0d --- /dev/null +++ b/tests/cases/fourslash/renameJsExports.ts @@ -0,0 +1,12 @@ +/// + +// @allowJs: true +// @Filename: a.js +////exports.[|area|] = function (r) { return r * r; } + +// @Filename: b.js +////var mod = require('./a'); +////var t = mod./**/[|area|](10); + +goTo.marker(); +verify.renameLocations(false, false); \ No newline at end of file diff --git a/tests/cases/fourslash/renameJsPrototypeProperty.ts b/tests/cases/fourslash/renameJsPrototypeProperty.ts new file mode 100644 index 00000000000..651514859cc --- /dev/null +++ b/tests/cases/fourslash/renameJsPrototypeProperty.ts @@ -0,0 +1,12 @@ +/// + +// @allowJs: true +// @Filename: a.js +////function bar() { +////} +////bar.prototype.[|x|] = 10; +////var t = new bar(); +////t./**/[|x|] = 11; + +goTo.marker(); +verify.renameLocations(false, false); \ No newline at end of file diff --git a/tests/cases/fourslash/renameJsThisProperty.ts b/tests/cases/fourslash/renameJsThisProperty.ts new file mode 100644 index 00000000000..aed59d298b1 --- /dev/null +++ b/tests/cases/fourslash/renameJsThisProperty.ts @@ -0,0 +1,12 @@ +/// + +// @allowJs: true +// @Filename: a.js +////function bar() { +//// this.[|x|] = 10; +////} +////var t = new bar(); +////t./**/[|x|] = 11; + +goTo.marker(); +verify.renameLocations(false, false); \ No newline at end of file From 477706cb2d2dcc3728fe61805c59efb715bba4d9 Mon Sep 17 00:00:00 2001 From: zhengbli Date: Wed, 27 Jan 2016 13:38:42 -0800 Subject: [PATCH 4/5] Fix build error (cherry picked from commit 646e46e022cddbfe31655ce5f0a40b7603dcca0b) From 85bb1e861018e4dc6d1ee60aa62ad8b137b64c34 Mon Sep 17 00:00:00 2001 From: zhengbli Date: Thu, 28 Jan 2016 11:26:32 -0800 Subject: [PATCH 5/5] Add more tests and comments (cherry picked from commit bf897c29393e7e7ee92a71e123e502ca3d0ba12f) --- src/compiler/checker.ts | 2 ++ tests/cases/fourslash/renameCrossJsTs01.ts | 12 ++++++++++++ tests/cases/fourslash/renameCrossJsTs02.ts | 12 ++++++++++++ .../{renameJsExports.ts => renameJsExports01.ts} | 2 +- tests/cases/fourslash/renameJsExports02.ts | 12 ++++++++++++ ...ypeProperty.ts => renameJsPrototypeProperty01.ts} | 2 +- tests/cases/fourslash/renameJsPrototypeProperty02.ts | 12 ++++++++++++ ...meJsThisProperty.ts => renameJsThisProperty01.ts} | 2 +- tests/cases/fourslash/renameJsThisProperty02.ts | 12 ++++++++++++ 9 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 tests/cases/fourslash/renameCrossJsTs01.ts create mode 100644 tests/cases/fourslash/renameCrossJsTs02.ts rename tests/cases/fourslash/{renameJsExports.ts => renameJsExports01.ts} (72%) create mode 100644 tests/cases/fourslash/renameJsExports02.ts rename tests/cases/fourslash/{renameJsPrototypeProperty.ts => renameJsPrototypeProperty01.ts} (69%) create mode 100644 tests/cases/fourslash/renameJsPrototypeProperty02.ts rename tests/cases/fourslash/{renameJsThisProperty.ts => renameJsThisProperty01.ts} (68%) create mode 100644 tests/cases/fourslash/renameJsThisProperty02.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5b74931bfd9..85e04c489d6 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -15375,6 +15375,8 @@ namespace ts { case SpecialPropertyAssignmentKind.ThisProperty: case SpecialPropertyAssignmentKind.ModuleExports: return getSymbolOfNode(entityName.parent.parent); + default: + // Fall through if it is not a special property assignment } } diff --git a/tests/cases/fourslash/renameCrossJsTs01.ts b/tests/cases/fourslash/renameCrossJsTs01.ts new file mode 100644 index 00000000000..52cb4c587d1 --- /dev/null +++ b/tests/cases/fourslash/renameCrossJsTs01.ts @@ -0,0 +1,12 @@ +/// + +// @allowJs: true +// @Filename: a.js +////exports.[|area|] = function (r) { return r * r; } + +// @Filename: b.ts +////import { [|area|] } from './a'; +////var t = /**/[|area|](10); + +goTo.marker(); +verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false); \ No newline at end of file diff --git a/tests/cases/fourslash/renameCrossJsTs02.ts b/tests/cases/fourslash/renameCrossJsTs02.ts new file mode 100644 index 00000000000..7ff1ae96ff3 --- /dev/null +++ b/tests/cases/fourslash/renameCrossJsTs02.ts @@ -0,0 +1,12 @@ +/// + +// @allowJs: true +// @Filename: a.js +////exports./**/[|area|] = function (r) { return r * r; } + +// @Filename: b.ts +////import { [|area|] } from './a'; +////var t = [|area|](10); + +goTo.marker(); +verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false); \ No newline at end of file diff --git a/tests/cases/fourslash/renameJsExports.ts b/tests/cases/fourslash/renameJsExports01.ts similarity index 72% rename from tests/cases/fourslash/renameJsExports.ts rename to tests/cases/fourslash/renameJsExports01.ts index 227eebe4a0d..923d30eedf9 100644 --- a/tests/cases/fourslash/renameJsExports.ts +++ b/tests/cases/fourslash/renameJsExports01.ts @@ -9,4 +9,4 @@ ////var t = mod./**/[|area|](10); goTo.marker(); -verify.renameLocations(false, false); \ No newline at end of file +verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false); \ No newline at end of file diff --git a/tests/cases/fourslash/renameJsExports02.ts b/tests/cases/fourslash/renameJsExports02.ts new file mode 100644 index 00000000000..86b0471dc1f --- /dev/null +++ b/tests/cases/fourslash/renameJsExports02.ts @@ -0,0 +1,12 @@ +/// + +// @allowJs: true +// @Filename: a.js +////exports./**/[|area|] = function (r) { return r * r; } + +// @Filename: b.js +////var mod = require('./a'); +////var t = mod.[|area|](10); + +goTo.marker(); +verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false); \ No newline at end of file diff --git a/tests/cases/fourslash/renameJsPrototypeProperty.ts b/tests/cases/fourslash/renameJsPrototypeProperty01.ts similarity index 69% rename from tests/cases/fourslash/renameJsPrototypeProperty.ts rename to tests/cases/fourslash/renameJsPrototypeProperty01.ts index 651514859cc..f756f57edbf 100644 --- a/tests/cases/fourslash/renameJsPrototypeProperty.ts +++ b/tests/cases/fourslash/renameJsPrototypeProperty01.ts @@ -9,4 +9,4 @@ ////t./**/[|x|] = 11; goTo.marker(); -verify.renameLocations(false, false); \ No newline at end of file +verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false); \ No newline at end of file diff --git a/tests/cases/fourslash/renameJsPrototypeProperty02.ts b/tests/cases/fourslash/renameJsPrototypeProperty02.ts new file mode 100644 index 00000000000..721dc312eb6 --- /dev/null +++ b/tests/cases/fourslash/renameJsPrototypeProperty02.ts @@ -0,0 +1,12 @@ +/// + +// @allowJs: true +// @Filename: a.js +////function bar() { +////} +////bar.prototype./**/[|x|] = 10; +////var t = new bar(); +////t.[|x|] = 11; + +goTo.marker(); +verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false); \ No newline at end of file diff --git a/tests/cases/fourslash/renameJsThisProperty.ts b/tests/cases/fourslash/renameJsThisProperty01.ts similarity index 68% rename from tests/cases/fourslash/renameJsThisProperty.ts rename to tests/cases/fourslash/renameJsThisProperty01.ts index aed59d298b1..91338e0431d 100644 --- a/tests/cases/fourslash/renameJsThisProperty.ts +++ b/tests/cases/fourslash/renameJsThisProperty01.ts @@ -9,4 +9,4 @@ ////t./**/[|x|] = 11; goTo.marker(); -verify.renameLocations(false, false); \ No newline at end of file +verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false); \ No newline at end of file diff --git a/tests/cases/fourslash/renameJsThisProperty02.ts b/tests/cases/fourslash/renameJsThisProperty02.ts new file mode 100644 index 00000000000..8398507c9ca --- /dev/null +++ b/tests/cases/fourslash/renameJsThisProperty02.ts @@ -0,0 +1,12 @@ +/// + +// @allowJs: true +// @Filename: a.js +////function bar() { +//// this./**/[|x|] = 10; +////} +////var t = new bar(); +////t.[|x|] = 11; + +goTo.marker(); +verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false); \ No newline at end of file