mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-14 19:16:17 -06:00
Rename declarationRange to declarationRangeIndex
This commit is contained in:
parent
6a961b5bc5
commit
8948fe415f
@ -955,7 +955,7 @@ namespace FourSlash {
|
||||
const fullExpected = ts.map<FourSlashInterface.ReferenceGroup, ReferenceGroupJson>(parts, ({ definition, ranges }) => ({
|
||||
definition: typeof definition === "string" ? definition : { ...definition, range: ts.createTextSpanFromRange(definition.range) },
|
||||
references: ranges.map<ts.ReferenceEntry>(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;
|
||||
})));
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
//// declare module JSX {
|
||||
//// interface Element { }
|
||||
//// interface IntrinsicElements {
|
||||
//// [|[|{| "declarationRange": 0 |}div|]: {
|
||||
//// [|[|{| "declarationRangeIndex": 0 |}div|]: {
|
||||
//// name?: string;
|
||||
//// isOpen?: boolean;
|
||||
//// };|]
|
||||
|
||||
@ -5,13 +5,13 @@
|
||||
//// interface Element { }
|
||||
//// interface IntrinsicElements {
|
||||
//// div: {
|
||||
//// [|[|{| "declarationRange": 0 |}name|]?: string;|]
|
||||
//// [|[|{| "declarationRangeIndex": 0 |}name|]?: string;|]
|
||||
//// isOpen?: boolean;
|
||||
//// };
|
||||
//// span: { n: string; };
|
||||
//// }
|
||||
//// }
|
||||
//// var x = <div [|[|{| "declarationRange": 2 |}name|]="hello"|] />;
|
||||
//// var x = <div [|[|{| "declarationRangeIndex": 2 |}name|]="hello"|] />;
|
||||
|
||||
const rangesByText = test.rangesByText();
|
||||
verify.rangesAreRenameLocations(rangesByText.get("name"));
|
||||
|
||||
@ -9,12 +9,12 @@
|
||||
//// }
|
||||
//// class MyClass {
|
||||
//// props: {
|
||||
//// [|[|{| "declarationRange": 0 |}name|]?: string;|]
|
||||
//// [|[|{| "declarationRangeIndex": 0 |}name|]?: string;|]
|
||||
//// size?: number;
|
||||
//// }
|
||||
////
|
||||
////
|
||||
//// var x = <MyClass [|[|{| "declarationRange": 2 |}name|]='hello'|]/>;
|
||||
//// var x = <MyClass [|[|{| "declarationRangeIndex": 2 |}name|]='hello'|]/>;
|
||||
|
||||
const rangesByText = test.rangesByText();
|
||||
verify.rangesAreRenameLocations(rangesByText.get("name"));
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
//// div: {};
|
||||
//// }
|
||||
////}
|
||||
////[|class [|{| "declarationRange": 0 |}MyClass|] {}|]
|
||||
////[|class [|{| "declarationRangeIndex": 0 |}MyClass|] {}|]
|
||||
////
|
||||
////<[|MyClass|]></[|MyClass|]>;
|
||||
////<[|MyClass|]/>;
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
//// size?: number;
|
||||
//// }
|
||||
////
|
||||
//// [|var [|{| "declarationRange": 0 |}nn|]: string;|]
|
||||
//// [|var [|{| "declarationRangeIndex": 0 |}nn|]: string;|]
|
||||
//// var x = <MyClass name={[|nn|]}></MyClass>;
|
||||
|
||||
const rangesByText = test.rangesByText();
|
||||
|
||||
@ -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/>;
|
||||
|
||||
@ -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 = <Opt />;
|
||||
//// let opt1 = <Opt [|[|{| "declarationRange": 2 |}propx|]={100}|] propString />;
|
||||
//// let opt2 = <Opt [|[|{| "declarationRange": 4 |}propx|]={100}|] optional/>;
|
||||
//// let opt1 = <Opt [|[|{| "declarationRangeIndex": 2 |}propx|]={100}|] propString />;
|
||||
//// let opt2 = <Opt [|[|{| "declarationRangeIndex": 4 |}propx|]={100}|] optional/>;
|
||||
//// let opt3 = <Opt wrong />;
|
||||
|
||||
const rangesByText = test.rangesByText();
|
||||
|
||||
@ -15,19 +15,19 @@
|
||||
//// className?: string;
|
||||
//// }
|
||||
//// interface ButtonProps extends ClickableProps {
|
||||
//// [|[|{| "declarationRange": 0 |}onClick|](event?: React.MouseEvent<HTMLButtonElement>): void;|]
|
||||
//// [|[|{| "declarationRangeIndex": 0 |}onClick|](event?: React.MouseEvent<HTMLButtonElement>): 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 [
|
||||
|
||||
@ -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");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user