@@ -8294,6 +8294,7 @@ namespace ts.projectSystem {
8294
8294
info: {
8295
8295
canRename: true,
8296
8296
displayName: "C",
8297
+ fileToRename: undefined,
8297
8298
fullDisplayName: '"/users/username/projects/a/c/fc".C',
8298
8299
kind: ScriptElementKind.constElement,
8299
8300
kindModifiers: ScriptElementKindModifier.exportedModifier,
@@ -9462,8 +9463,7 @@ export function Test2() {
9462
9463
content: "{}",
9463
9464
};
9464
9465
9465
- const host = createServerHost([aTs, bTs, tsconfig]);
9466
- const session = createSession(host);
9466
+ const session = createSession(createServerHost([aTs, bTs, tsconfig]));
9467
9467
openFilesForSession([aTs, bTs], session);
9468
9468
9469
9469
const requestLocation: protocol.FileLocationRequestArgs = {
@@ -9569,6 +9569,31 @@ export function Test2() {
9569
9569
});
9570
9570
});
9571
9571
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
+
9572
9597
describe("tsserverProjectSystem typeReferenceDirectives", () => {
9573
9598
it("when typeReferenceDirective contains UpperCasePackage", () => {
9574
9599
const projectLocation = "/user/username/projects/myproject";
@@ -10062,6 +10087,7 @@ declare class TestLib {
10062
10087
info: {
10063
10088
canRename: true,
10064
10089
displayName: "fnA",
10090
+ fileToRename: undefined,
10065
10091
fullDisplayName: "fnA",
10066
10092
kind: ScriptElementKind.alias,
10067
10093
kindModifiers: ScriptElementKindModifier.none,
@@ -10081,6 +10107,7 @@ declare class TestLib {
10081
10107
info: {
10082
10108
canRename: true,
10083
10109
displayName: "fnA",
10110
+ fileToRename: undefined,
10084
10111
fullDisplayName: '"/a/a".fnA',
10085
10112
kind: ScriptElementKind.functionElement,
10086
10113
kindModifiers: ScriptElementKindModifier.exportedModifier,
@@ -10110,6 +10137,7 @@ declare class TestLib {
10110
10137
info: {
10111
10138
canRename: true,
10112
10139
displayName: "fnB",
10140
+ fileToRename: undefined,
10113
10141
fullDisplayName: "fnB",
10114
10142
kind: ScriptElementKind.alias,
10115
10143
kindModifiers: ScriptElementKindModifier.none,
0 commit comments