@@ -8294,6 +8294,7 @@ namespace ts.projectSystem {
82948294 info: {
82958295 canRename: true,
82968296 displayName: "C",
8297+ fileToRename: undefined,
82978298 fullDisplayName: '"/users/username/projects/a/c/fc".C',
82988299 kind: ScriptElementKind.constElement,
82998300 kindModifiers: ScriptElementKindModifier.exportedModifier,
@@ -9462,8 +9463,7 @@ export function Test2() {
94629463 content: "{}",
94639464 };
94649465
9465- const host = createServerHost([aTs, bTs, tsconfig]);
9466- const session = createSession(host);
9466+ const session = createSession(createServerHost([aTs, bTs, tsconfig]));
94679467 openFilesForSession([aTs, bTs], session);
94689468
94699469 const requestLocation: protocol.FileLocationRequestArgs = {
@@ -9569,6 +9569,31 @@ export function Test2() {
95699569 });
95709570 });
95719571
9572+ describe("tsserverProjectSystem rename", () => {
9573+ it("works", () => {
9574+ const aTs: File = { path: "/a.ts", content: "export const a = 0;" };
9575+ const bTs: File = { path: "/b.ts", content: 'import { a } from "./a";' };
9576+
9577+ const session = createSession(createServerHost([aTs, bTs]));
9578+ openFilesForSession([bTs], session);
9579+
9580+ const response = executeSessionRequest<protocol.RenameRequest, protocol.RenameResponse>(session, protocol.CommandTypes.Rename, protocolFileLocationFromSubstring(bTs, 'a";'));
9581+ assert.deepEqual<protocol.RenameResponseBody | undefined>(response, {
9582+ info: {
9583+ canRename: true,
9584+ fileToRename: aTs.path,
9585+ displayName: aTs.path,
9586+ fullDisplayName: aTs.path,
9587+ kind: ScriptElementKind.moduleElement,
9588+ kindModifiers: "",
9589+ localizedErrorMessage: undefined,
9590+ triggerSpan: protocolTextSpanFromSubstring(bTs.content, "a", { index: 1 }),
9591+ },
9592+ locs: [{ file: bTs.path, locs: [protocolTextSpanFromSubstring(bTs.content, "./a")] }],
9593+ });
9594+ });
9595+ });
9596+
95729597 describe("tsserverProjectSystem typeReferenceDirectives", () => {
95739598 it("when typeReferenceDirective contains UpperCasePackage", () => {
95749599 const projectLocation = "/user/username/projects/myproject";
@@ -10062,6 +10087,7 @@ declare class TestLib {
1006210087 info: {
1006310088 canRename: true,
1006410089 displayName: "fnA",
10090+ fileToRename: undefined,
1006510091 fullDisplayName: "fnA",
1006610092 kind: ScriptElementKind.alias,
1006710093 kindModifiers: ScriptElementKindModifier.none,
@@ -10081,6 +10107,7 @@ declare class TestLib {
1008110107 info: {
1008210108 canRename: true,
1008310109 displayName: "fnA",
10110+ fileToRename: undefined,
1008410111 fullDisplayName: '"/a/a".fnA',
1008510112 kind: ScriptElementKind.functionElement,
1008610113 kindModifiers: ScriptElementKindModifier.exportedModifier,
@@ -10110,6 +10137,7 @@ declare class TestLib {
1011010137 info: {
1011110138 canRename: true,
1011210139 displayName: "fnB",
10140+ fileToRename: undefined,
1011310141 fullDisplayName: "fnB",
1011410142 kind: ScriptElementKind.alias,
1011510143 kindModifiers: ScriptElementKindModifier.none,
0 commit comments