From 8948fe415f05e8fcfeacbbfec3130121c9b62028 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 30 May 2019 12:45:11 -0700 Subject: [PATCH] Rename declarationRange to declarationRangeIndex --- src/harness/fourslash.ts | 12 ++++++------ tests/cases/fourslash/tsxRename1.ts | 2 +- tests/cases/fourslash/tsxRename2.ts | 4 ++-- tests/cases/fourslash/tsxRename3.ts | 4 ++-- tests/cases/fourslash/tsxRename4.ts | 2 +- tests/cases/fourslash/tsxRename5.ts | 2 +- tests/cases/fourslash/tsxRename6.ts | 2 +- tests/cases/fourslash/tsxRename7.ts | 6 +++--- tests/cases/fourslash/tsxRename9.ts | 16 ++++++++-------- tests/cases/fourslash/untypedModuleImport.ts | 2 +- 10 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index edbb485a30b..51e6c2dbe29 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -955,7 +955,7 @@ namespace FourSlash { const fullExpected = ts.map(parts, ({ definition, ranges }) => ({ definition: typeof definition === "string" ? definition : { ...definition, range: ts.createTextSpanFromRange(definition.range) }, references: ranges.map(r => { - const { isWriteAccess = false, isDefinition = false, isInString, declarationRange } = (r.marker && r.marker.data || {}) as { isWriteAccess?: boolean, isDefinition?: boolean, isInString?: true, declarationRange?: number }; + const { isWriteAccess = false, isDefinition = false, isInString, declarationRangeIndex } = (r.marker && r.marker.data || {}) as { isWriteAccess?: boolean, isDefinition?: boolean, isInString?: true, declarationRangeIndex?: number }; const result: ts.ReferenceEntry = { fileName: r.fileName, textSpan: ts.createTextSpanFromRange(r), @@ -963,8 +963,8 @@ namespace FourSlash { isDefinition, ...(isInString ? { isInString: true } : undefined), }; - if (declarationRange !== undefined) { - result.declarationSpan = ts.createTextSpanFromRange(this.getRanges()[declarationRange]); + if (declarationRangeIndex !== undefined) { + result.declarationSpan = ts.createTextSpanFromRange(this.getRanges()[declarationRangeIndex]); } return result; }), @@ -1194,9 +1194,9 @@ Actual: ${stringify(fullActual)}`); assert.deepEqual(sort(references), sort(ranges.map(rangeOrOptions => { const { range, ...prefixSuffixText } = "range" in rangeOrOptions ? rangeOrOptions : { range: rangeOrOptions }; const result: ts.RenameLocation = { fileName: range.fileName, textSpan: ts.createTextSpanFromRange(range), ...prefixSuffixText }; - const { declarationRange } = (range.marker && range.marker.data || {}) as { declarationRange?: number; }; - if (declarationRange !== undefined) { - result.declarationSpan = ts.createTextSpanFromRange(this.getRanges()[declarationRange]); + const { declarationRangeIndex } = (range.marker && range.marker.data || {}) as { declarationRangeIndex?: number; }; + if (declarationRangeIndex !== undefined) { + result.declarationSpan = ts.createTextSpanFromRange(this.getRanges()[declarationRangeIndex]); } return result; }))); diff --git a/tests/cases/fourslash/tsxRename1.ts b/tests/cases/fourslash/tsxRename1.ts index bdf2cf6d2ef..25a4032032d 100644 --- a/tests/cases/fourslash/tsxRename1.ts +++ b/tests/cases/fourslash/tsxRename1.ts @@ -4,7 +4,7 @@ //// declare module JSX { //// interface Element { } //// interface IntrinsicElements { -//// [|[|{| "declarationRange": 0 |}div|]: { +//// [|[|{| "declarationRangeIndex": 0 |}div|]: { //// name?: string; //// isOpen?: boolean; //// };|] diff --git a/tests/cases/fourslash/tsxRename2.ts b/tests/cases/fourslash/tsxRename2.ts index 7a578b3383d..e79e7746d52 100644 --- a/tests/cases/fourslash/tsxRename2.ts +++ b/tests/cases/fourslash/tsxRename2.ts @@ -5,13 +5,13 @@ //// interface Element { } //// interface IntrinsicElements { //// div: { -//// [|[|{| "declarationRange": 0 |}name|]?: string;|] +//// [|[|{| "declarationRangeIndex": 0 |}name|]?: string;|] //// isOpen?: boolean; //// }; //// span: { n: string; }; //// } //// } -//// var x =
; +//// var x =
; const rangesByText = test.rangesByText(); verify.rangesAreRenameLocations(rangesByText.get("name")); diff --git a/tests/cases/fourslash/tsxRename3.ts b/tests/cases/fourslash/tsxRename3.ts index 5a8d0d7a19d..7970c314f45 100644 --- a/tests/cases/fourslash/tsxRename3.ts +++ b/tests/cases/fourslash/tsxRename3.ts @@ -9,12 +9,12 @@ //// } //// class MyClass { //// props: { -//// [|[|{| "declarationRange": 0 |}name|]?: string;|] +//// [|[|{| "declarationRangeIndex": 0 |}name|]?: string;|] //// size?: number; //// } //// //// -//// var x = ; +//// var x = ; const rangesByText = test.rangesByText(); verify.rangesAreRenameLocations(rangesByText.get("name")); diff --git a/tests/cases/fourslash/tsxRename4.ts b/tests/cases/fourslash/tsxRename4.ts index 1a932768b17..cfd9b379fb7 100644 --- a/tests/cases/fourslash/tsxRename4.ts +++ b/tests/cases/fourslash/tsxRename4.ts @@ -9,7 +9,7 @@ //// div: {}; //// } ////} -////[|class [|{| "declarationRange": 0 |}MyClass|] {}|] +////[|class [|{| "declarationRangeIndex": 0 |}MyClass|] {}|] //// ////<[|MyClass|]>; ////<[|MyClass|]/>; diff --git a/tests/cases/fourslash/tsxRename5.ts b/tests/cases/fourslash/tsxRename5.ts index 5ccfcd61953..d57da4b083a 100644 --- a/tests/cases/fourslash/tsxRename5.ts +++ b/tests/cases/fourslash/tsxRename5.ts @@ -13,7 +13,7 @@ //// size?: number; //// } //// -//// [|var [|{| "declarationRange": 0 |}nn|]: string;|] +//// [|var [|{| "declarationRangeIndex": 0 |}nn|]: string;|] //// var x = ; const rangesByText = test.rangesByText(); diff --git a/tests/cases/fourslash/tsxRename6.ts b/tests/cases/fourslash/tsxRename6.ts index f8c2ab41ebf..3b0068d16b9 100644 --- a/tests/cases/fourslash/tsxRename6.ts +++ b/tests/cases/fourslash/tsxRename6.ts @@ -15,7 +15,7 @@ //// propString: string //// optional?: boolean //// } -//// [|declare function [|{| "declarationRange": 0 |}Opt|](attributes: OptionPropBag): JSX.Element;|] +//// [|declare function [|{| "declarationRangeIndex": 0 |}Opt|](attributes: OptionPropBag): JSX.Element;|] //// let opt = <[|Opt|] />; //// let opt1 = <[|Opt|] propx={100} propString />; //// let opt2 = <[|Opt|] propx={100} optional/>; diff --git a/tests/cases/fourslash/tsxRename7.ts b/tests/cases/fourslash/tsxRename7.ts index 8565487c240..57b5da71cfc 100644 --- a/tests/cases/fourslash/tsxRename7.ts +++ b/tests/cases/fourslash/tsxRename7.ts @@ -11,14 +11,14 @@ //// interface ElementAttributesProperty { props; } //// } //// interface OptionPropBag { -//// [|[|{| "declarationRange": 0 |}propx|]: number|] +//// [|[|{| "declarationRangeIndex": 0 |}propx|]: number|] //// propString: string //// optional?: boolean //// } //// declare function Opt(attributes: OptionPropBag): JSX.Element; //// let opt = ; -//// let opt1 = ; -//// let opt2 = ; +//// let opt1 = ; +//// let opt2 = ; //// let opt3 = ; const rangesByText = test.rangesByText(); diff --git a/tests/cases/fourslash/tsxRename9.ts b/tests/cases/fourslash/tsxRename9.ts index 763b9af68a2..8de7a1c6d86 100644 --- a/tests/cases/fourslash/tsxRename9.ts +++ b/tests/cases/fourslash/tsxRename9.ts @@ -15,19 +15,19 @@ //// className?: string; //// } //// interface ButtonProps extends ClickableProps { -//// [|[|{| "declarationRange": 0 |}onClick|](event?: React.MouseEvent): void;|] +//// [|[|{| "declarationRangeIndex": 0 |}onClick|](event?: React.MouseEvent): void;|] //// } //// interface LinkProps extends ClickableProps { -//// [|[|{| "declarationRange": 2 |}goTo|]: string;|] +//// [|[|{| "declarationRangeIndex": 2 |}goTo|]: string;|] //// } -//// [|declare function [|{| "declarationRange": 4 |}MainButton|](buttonProps: ButtonProps): JSX.Element;|] -//// [|declare function [|{| "declarationRange": 6 |}MainButton|](linkProps: LinkProps): JSX.Element;|] -//// [|declare function [|{| "declarationRange": 8 |}MainButton|](props: ButtonProps | LinkProps): JSX.Element;|] +//// [|declare function [|{| "declarationRangeIndex": 4 |}MainButton|](buttonProps: ButtonProps): JSX.Element;|] +//// [|declare function [|{| "declarationRangeIndex": 6 |}MainButton|](linkProps: LinkProps): JSX.Element;|] +//// [|declare function [|{| "declarationRangeIndex": 8 |}MainButton|](props: ButtonProps | LinkProps): JSX.Element;|] //// let opt = <[|MainButton|] />; //// let opt = <[|MainButton|] children="chidlren" />; -//// let opt = <[|MainButton|] [|[|{| "declarationRange": 13 |}onClick|]={()=>{}}|] />; -//// let opt = <[|MainButton|] [|[|{| "declarationRange": 16 |}onClick|]={()=>{}}|] [|ignore-prop|] />; -//// let opt = <[|MainButton|] [|[|{| "declarationRange": 20 |}goTo|]="goTo"|] />; +//// let opt = <[|MainButton|] [|[|{| "declarationRangeIndex": 13 |}onClick|]={()=>{}}|] />; +//// let opt = <[|MainButton|] [|[|{| "declarationRangeIndex": 16 |}onClick|]={()=>{}}|] [|ignore-prop|] />; +//// let opt = <[|MainButton|] [|[|{| "declarationRangeIndex": 20 |}goTo|]="goTo"|] />; //// let opt = <[|MainButton|] [|wrong|] />; const [ diff --git a/tests/cases/fourslash/untypedModuleImport.ts b/tests/cases/fourslash/untypedModuleImport.ts index e64d37d0e6c..783e020e3fc 100644 --- a/tests/cases/fourslash/untypedModuleImport.ts +++ b/tests/cases/fourslash/untypedModuleImport.ts @@ -4,7 +4,7 @@ ////{} // @Filename: a.ts -////[|import /*foo*/[|{| "isWriteAccess": true, "isDefinition": true, "declarationRange": 0 |}foo|] from /*fooModule*/"[|{| "isInString": true |}foo|]";|] +////[|import /*foo*/[|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}foo|] from /*fooModule*/"[|{| "isInString": true |}foo|]";|] ////[|foo|](); goTo.file("a.ts");