mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-07-05 00:32:41 -05:00
Add prefix/suffix only to binding element name (#33538)
This commit is contained in:
committed by
Ryan Cavanaugh
parent
9e712dd097
commit
420b478c65
@@ -363,7 +363,7 @@ namespace ts.FindAllReferences {
|
||||
const { node, kind } = entry;
|
||||
const name = originalNode.text;
|
||||
const isShorthandAssignment = isShorthandPropertyAssignment(node.parent);
|
||||
if (isShorthandAssignment || isObjectBindingElementWithoutPropertyName(node.parent)) {
|
||||
if (isShorthandAssignment || isObjectBindingElementWithoutPropertyName(node.parent) && node.parent.name === node) {
|
||||
const prefixColon: PrefixAndSuffix = { prefixText: name + ": " };
|
||||
const suffixColon: PrefixAndSuffix = { suffixText: ": " + name };
|
||||
return kind === EntryKind.SearchedLocalFoundProperty ? prefixColon
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
/// <reference path="fourslash.ts"/>
|
||||
|
||||
////[|const [|{| "contextRangeIndex": 0 |}external|] = true;|]
|
||||
////
|
||||
////function f({
|
||||
//// lvl1 = [|external|],
|
||||
//// nested: { lvl2 = [|external|]},
|
||||
//// oldName: newName = [|external|]
|
||||
////}) {}
|
||||
////
|
||||
////const {
|
||||
//// lvl1 = [|external|],
|
||||
//// nested: { lvl2 = [|external|]},
|
||||
//// oldName: newName = [|external|]
|
||||
////} = obj;
|
||||
|
||||
verify.rangesWithSameTextAreRenameLocations("external");
|
||||
@@ -0,0 +1,20 @@
|
||||
/// <reference path="fourslash.ts"/>
|
||||
|
||||
////function f([|{[|{| "contextRangeIndex": 0 |}required|], optional = [|required|]}: {[|[|{| "contextRangeIndex": 3 |}required|]: number,|] optional?: number}|]) {
|
||||
//// console.log("required", [|required|]);
|
||||
//// console.log("optional", optional);
|
||||
////}
|
||||
////
|
||||
////f({[|[|{| "contextRangeIndex": 6 |}required|]: 10|]});
|
||||
|
||||
const [r0Def, r0, r1, r2Def, r2, r3, r4Def, r4] = test.ranges();
|
||||
verify.renameLocations([r0, r1, r3], [
|
||||
{ range: r0, prefixText: "required: " },
|
||||
{ range: r1},
|
||||
{ range: r3}
|
||||
]);
|
||||
verify.renameLocations([r2, r4], [
|
||||
{ range: r0, suffixText: ": required" },
|
||||
{ range: r2},
|
||||
{ range: r4}
|
||||
]);
|
||||
Reference in New Issue
Block a user