File: findAllRefsReExportLocal.ts

package info (click to toggle)
node-typescript 4.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 396,552 kB
  • sloc: javascript: 1,444,377; makefile: 7; sh: 3
file content (34 lines) | stat: -rw-r--r-- 1,735 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/// <reference path='fourslash.ts' />

// @noLib: true

// @Filename: /a.ts
////[|var [|{| "isDefinition": true, "contextRangeIndex": 0 |}x|];|]
////[|export { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}x|] };|]
////[|export { [|{| "contextRangeIndex": 4 |}x|] as [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}y|] };|]

// @Filename: /b.ts
////[|import { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 7 |}x|], [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 7 |}y|] } from "./a";|]
////[|x|]; [|y|];

verify.noErrors();

const [ax0Def, ax0, ax1Def, ax1, ax2Def, ax2, ay, bx0Def, bx0, by0, bx1, by1] = test.ranges();
const axRanges = [ax0, ax1, ax2];
const bxRanges = [bx0, bx1];
const byRanges = [by0, by1];
const axGroup = { definition: "var x: any", ranges: axRanges };
const bxGroup = { definition: "(alias) var x: any\nimport x", ranges: bxRanges };
const ayGroup = { definition: "(alias) var y: any\nexport y", ranges: [ay] }
const byGroup = { definition: "(alias) var y: any\nimport y", ranges: byRanges }

verify.referenceGroups(axRanges, [axGroup, bxGroup, ayGroup, byGroup]);
verify.referenceGroups(bxRanges, [bxGroup, axGroup, ayGroup, byGroup]);
verify.referenceGroups(ay, [ayGroup, byGroup]);
verify.referenceGroups(byRanges, [byGroup, ayGroup]);

verify.renameLocations([ax0, ax2], [ax0, { range: ax1, suffixText: " as x" }, ax2]);
verify.renameLocations(ax1, [{ range: ax1, prefixText: "x as " }, bx0, bx1]);
verify.renameLocations(bxRanges, [{ range: bx0, prefixText: "x as " }, bx1]);
verify.renameLocations(ay, [ay, ...byRanges]);
verify.renameLocations(byRanges, [{ range: by0, prefixText: "y as " }, by1]);