Skip to content

Deprecate CommandNames in favor of protocol.CommandTypes, direct import for better bundler output #52208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 40 additions & 41 deletions src/harness/client.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/server/editorServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import {
ProjectFilesWithTSDiagnostics,
ProjectKind,
ProjectOptions,
protocol,
ScriptInfo,
ScriptInfoVersion,
ServerHost,
Expand Down Expand Up @@ -179,6 +178,7 @@ import {
WatchType,
WildcardDirectoryWatcher,
} from "./_namespaces/ts";
import * as protocol from "./protocol";

export const maxProgramSizeForNonTsFiles = 20 * 1024 * 1024;
/** @internal */
Expand Down
2 changes: 1 addition & 1 deletion src/server/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
ProjectOptions,
ProjectReferenceProjectLoadKind,
ProjectService,
protocol,
ScriptInfo,
ServerHost,
Session,
Expand Down Expand Up @@ -148,6 +147,7 @@ import {
WatchOptions,
WatchType,
} from "./_namespaces/ts";
import * as protocol from "./protocol";

export enum ProjectKind {
Inferred,
Expand Down
2 changes: 1 addition & 1 deletion src/server/scriptInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
NormalizedPath,
Project,
ProjectKind,
protocol,
ScriptVersionCache,
ServerHost,
} from "./_namespaces/ts.server";
Expand Down Expand Up @@ -52,6 +51,7 @@ import {
TextSpan,
unorderedRemoveItem,
} from "./_namespaces/ts";
import * as protocol from "./protocol";

export interface ScriptInfoVersion {
svc: number;
Expand Down
2 changes: 1 addition & 1 deletion src/server/scriptVersionCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {
} from "./_namespaces/ts";
import {
emptyArray,
protocol,
} from "./_namespaces/ts.server";
import * as protocol from "./protocol";

const lineCollectionCapacity = 4;

Expand Down
350 changes: 176 additions & 174 deletions src/server/session.ts

Large diffs are not rendered by default.

94 changes: 47 additions & 47 deletions src/testRunner/unittests/tsserver/compileOnSave.ts

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/testRunner/unittests/tsserver/declarationFileMaps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ describe("unittests:: tsserver:: with declaration file maps:: project references
it("goToDefinition -- target does not exist", () => {
const session = makeSampleProjects();
session.executeCommandSeq<ts.server.protocol.DefinitionRequest>({
command: ts.server.CommandNames.Definition,
command: ts.server.protocol.CommandTypes.Definition,
arguments: protocolFileLocationFromSubstring(userTs, "fnB()")
});
verifySingleInferredProject(session);
Expand All @@ -204,7 +204,7 @@ describe("unittests:: tsserver:: with declaration file maps:: project references
it("navigateTo", () => {
const session = makeSampleProjects();
session.executeCommandSeq<ts.server.protocol.NavtoRequest>({
command: ts.server.CommandNames.Navto,
command: ts.server.protocol.CommandTypes.Navto,
arguments: { file: userTs.path, searchValue: "fn" }
});
verifySingleInferredProject(session);
Expand All @@ -214,7 +214,7 @@ describe("unittests:: tsserver:: with declaration file maps:: project references
it("navigateToAll -- when neither file nor project is specified", () => {
const session = makeSampleProjects(/*addUserTsConfig*/ true, /*keepAllFiles*/ true);
session.executeCommandSeq<ts.server.protocol.NavtoRequest>({
command: ts.server.CommandNames.Navto,
command: ts.server.protocol.CommandTypes.Navto,
arguments: { file: undefined, searchValue: "fn" }
});
baselineTsserverLogs("declarationFileMaps", "navigateToAll neither file not project is specified", session);
Expand All @@ -223,7 +223,7 @@ describe("unittests:: tsserver:: with declaration file maps:: project references
it("navigateToAll -- when file is not specified but project is", () => {
const session = makeSampleProjects(/*addUserTsConfig*/ true, /*keepAllFiles*/ true);
session.executeCommandSeq<ts.server.protocol.NavtoRequest>({
command: ts.server.CommandNames.Navto,
command: ts.server.protocol.CommandTypes.Navto,
arguments: { projectFileName: bTsconfig.path, file: undefined, searchValue: "fn" }
});
baselineTsserverLogs("declarationFileMaps", "navigateToAll file is not specified but project is", session);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe("unittests:: tsserver:: events:: ProjectsUpdatedInBackground", () => {
function createVerifyInitialOpen(session: TestSession, verifyProjectsUpdatedInBackgroundEventHandler: (events: ts.server.ProjectsUpdatedInBackgroundEvent[]) => void) {
return (file: File) => {
session.executeCommandSeq({
command: ts.server.CommandNames.Open,
command: ts.server.protocol.CommandTypes.Open,
arguments: {
file: file.path
}
Expand Down Expand Up @@ -237,7 +237,7 @@ describe("unittests:: tsserver:: events:: ProjectsUpdatedInBackground", () => {

function updateContentOfOpenFile(file: File, newContent: string) {
session.executeCommandSeq<ts.server.protocol.ChangeRequest>({
command: ts.server.CommandNames.Change,
command: ts.server.protocol.CommandTypes.Change,
arguments: {
file: file.path,
insertString: newContent,
Expand Down
4 changes: 2 additions & 2 deletions src/testRunner/unittests/tsserver/getEditsForFileRename.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe("unittests:: tsserver:: getEditsForFileRename", () => {
openFilesForSession([aUserTs, bUserTs], session);

session.executeCommandSeq<ts.server.protocol.GetEditsForFileRenameRequest>({
command: ts.server.CommandNames.GetEditsForFileRename,
command: ts.server.protocol.CommandTypes.GetEditsForFileRename,
arguments: {
oldFilePath: aOldTs.path,
newFilePath: "/a/new.ts",
Expand All @@ -101,7 +101,7 @@ describe("unittests:: tsserver:: getEditsForFileRename", () => {
openFilesForSession([aTs, cTs], session);

session.executeCommandSeq<ts.server.protocol.GetEditsForFileRenameRequest>({
command: ts.server.CommandNames.GetEditsForFileRename,
command: ts.server.protocol.CommandTypes.GetEditsForFileRename,
arguments: {
oldFilePath: "/b.ts",
newFilePath: cTs.path,
Expand Down
4 changes: 2 additions & 2 deletions src/testRunner/unittests/tsserver/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ export class TestServerCancellationToken implements ts.server.ServerCancellation
export function openFilesForSession(files: readonly (string | File | { readonly file: File | string, readonly projectRootPath: string, content?: string })[], session: TestSession): void {
for (const file of files) {
session.executeCommandSeq<ts.server.protocol.OpenRequest>({
command: ts.server.CommandNames.Open,
command: ts.server.protocol.CommandTypes.Open,
arguments: ts.isString(file) ?
{ file } :
"projectRootPath" in file ? // eslint-disable-line local/no-in-operator
Expand All @@ -755,7 +755,7 @@ export function openFilesForSession(files: readonly (string | File | { readonly
export function closeFilesForSession(files: readonly File[], session: TestSession): void {
for (const file of files) {
session.executeCommandSeq<ts.server.protocol.CloseRequest>({
command: ts.server.CommandNames.Close,
command: ts.server.protocol.CommandTypes.Close,
arguments: { file: file.path }
});
}
Expand Down
12 changes: 6 additions & 6 deletions src/testRunner/unittests/tsserver/inferredProjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ describe("unittests:: tsserver:: Inferred projects", () => {
session.executeCommand({
seq: 1,
type: "request",
command: ts.server.CommandNames.CompilerOptionsForInferredProjects,
command: ts.server.protocol.CommandTypes.CompilerOptionsForInferredProjects,
arguments: {
options: {
allowJs: true,
Expand All @@ -181,7 +181,7 @@ describe("unittests:: tsserver:: Inferred projects", () => {
session.executeCommand({
seq: 2,
type: "request",
command: ts.server.CommandNames.CompilerOptionsForInferredProjects,
command: ts.server.protocol.CommandTypes.CompilerOptionsForInferredProjects,
arguments: {
options: {
allowJs: true,
Expand All @@ -193,7 +193,7 @@ describe("unittests:: tsserver:: Inferred projects", () => {
session.executeCommand({
seq: 3,
type: "request",
command: ts.server.CommandNames.Open,
command: ts.server.protocol.CommandTypes.Open,
arguments: {
file: file1.path,
fileContent: file1.content,
Expand All @@ -204,7 +204,7 @@ describe("unittests:: tsserver:: Inferred projects", () => {
session.executeCommand({
seq: 4,
type: "request",
command: ts.server.CommandNames.Open,
command: ts.server.protocol.CommandTypes.Open,
arguments: {
file: file2.path,
fileContent: file2.content,
Expand All @@ -215,7 +215,7 @@ describe("unittests:: tsserver:: Inferred projects", () => {
session.executeCommand({
seq: 5,
type: "request",
command: ts.server.CommandNames.Open,
command: ts.server.protocol.CommandTypes.Open,
arguments: {
file: file3.path,
fileContent: file3.content,
Expand All @@ -226,7 +226,7 @@ describe("unittests:: tsserver:: Inferred projects", () => {
session.executeCommand({
seq: 6,
type: "request",
command: ts.server.CommandNames.Open,
command: ts.server.protocol.CommandTypes.Open,
arguments: {
file: file4.path,
fileContent: file4.content,
Expand Down
10 changes: 5 additions & 5 deletions src/testRunner/unittests/tsserver/navTo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ describe("unittests:: tsserver:: navigate-to for javascript project", () => {

// Try to find some interface type defined in lib.d.ts
session.executeCommandSeq<ts.server.protocol.NavtoRequest>({
command: ts.server.CommandNames.Navto,
command: ts.server.protocol.CommandTypes.Navto,
arguments: { searchValue: "Document", file: file1.path, projectFileName: configFile.path }
}).response as ts.server.protocol.NavtoItem[];

session.executeCommandSeq<ts.server.protocol.NavtoRequest>({
command: ts.server.CommandNames.Navto,
command: ts.server.protocol.CommandTypes.Navto,
arguments: { searchValue: "foo", file: file1.path, projectFileName: configFile.path }
}).response as ts.server.protocol.NavtoItem[];
baselineTsserverLogs("navTo", "should not include type symbols", session);
Expand Down Expand Up @@ -72,7 +72,7 @@ export const ghijkl = a.abcdef;`
openFilesForSession([file1, file2], session);

session.executeCommandSeq<ts.server.protocol.NavtoRequest>({
command: ts.server.CommandNames.Navto,
command: ts.server.protocol.CommandTypes.Navto,
arguments: { searchValue: "abcdef", file: file1.path }
});

Expand Down Expand Up @@ -120,7 +120,7 @@ export const ghijkl = a.abcdef;`
openFilesForSession([file1], session);

session.executeCommandSeq<ts.server.protocol.NavtoRequest>({
command: ts.server.CommandNames.Navto,
command: ts.server.protocol.CommandTypes.Navto,
arguments: { searchValue: "abcdef" }
});
baselineTsserverLogs("navTo", "should de-duplicate symbols when searching all projects", session);
Expand All @@ -141,7 +141,7 @@ export const ghijkl = a.abcdef;`

// Try to find some interface type defined in lib.d.ts
session.executeCommandSeq<ts.server.protocol.NavtoRequest>({
command: ts.server.CommandNames.Navto,
command: ts.server.protocol.CommandTypes.Navto,
arguments: { searchValue: "foo", file: file1.path, projectFileName: configFile.path }
});
baselineTsserverLogs("navTo", "should work with Deprecated", session);
Expand Down
6 changes: 3 additions & 3 deletions src/testRunner/unittests/tsserver/occurences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ describe("unittests:: tsserver:: occurrence highlight on string", () => {
const session = createSession(host, { logger: createLoggerWithInMemoryLogs(host) });
openFilesForSession([file1], session);
session.executeCommandSeq<ts.server.protocol.FileLocationRequest>({
command: ts.server.CommandNames.Occurrences,
command: ts.server.protocol.CommandTypes.Occurrences,
arguments: { file: file1.path, line: 1, offset: 11 }
});

session.executeCommandSeq<ts.server.protocol.FileLocationRequest>({
command: ts.server.CommandNames.Occurrences,
command: ts.server.protocol.CommandTypes.Occurrences,
arguments: { file: file1.path, line: 3, offset: 13 }
});

session.executeCommandSeq<ts.server.protocol.FileLocationRequest>({
command: ts.server.CommandNames.Occurrences,
command: ts.server.protocol.CommandTypes.Occurrences,
arguments: { file: file1.path, line: 4, offset: 14 }
});
baselineTsserverLogs("occurences", "should be marked if only on string values", session);
Expand Down
26 changes: 13 additions & 13 deletions src/testRunner/unittests/tsserver/projectErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe("unittests:: tsserver:: Project Errors", () => {
const projectFileName = "/a/b/test.csproj";
const compilerOptionsRequest: ts.server.protocol.CompilerOptionsDiagnosticsRequest = {
type: "request",
command: ts.server.CommandNames.CompilerOptionsDiagnosticsFull,
command: ts.server.protocol.CommandTypes.CompilerOptionsDiagnosticsFull,
seq: 2,
arguments: { projectFileName }
};
Expand Down Expand Up @@ -117,7 +117,7 @@ describe("unittests:: tsserver:: Project Errors", () => {
const project = configuredProjectAt(projectService, 0);
const compilerOptionsRequest: ts.server.protocol.CompilerOptionsDiagnosticsRequest = {
type: "request",
command: ts.server.CommandNames.CompilerOptionsDiagnosticsFull,
command: ts.server.protocol.CommandTypes.CompilerOptionsDiagnosticsFull,
seq: 2,
arguments: { projectFileName: project.getProjectName() }
};
Expand Down Expand Up @@ -262,7 +262,7 @@ describe("unittests:: tsserver:: Project Errors are reported as appropriate", ()
const fileContent = `/// <reference path="${refPathNotFound1}" />
/// <reference path="${refPathNotFound2}" />`;
session.executeCommandSeq<ts.server.protocol.OpenRequest>({
command: ts.server.CommandNames.Open,
command: ts.server.protocol.CommandTypes.Open,
arguments: {
file: untitledFile,
fileContent,
Expand Down Expand Up @@ -305,7 +305,7 @@ describe("unittests:: tsserver:: Project Errors are reported as appropriate", ()
const session = createSession(host, { canUseEvents: true, logger: createLoggerWithInMemoryLogs(host) });

session.executeCommandSeq<ts.server.protocol.OpenRequest>({
command: ts.server.CommandNames.Open,
command: ts.server.protocol.CommandTypes.Open,
arguments: { file: app.path, }
});
verifyGetErrRequest({ session, host, files: [app] });
Expand All @@ -325,7 +325,7 @@ describe("unittests:: tsserver:: Project Errors are reported as appropriate", ()
const host = createServerHost([file, libFile]);
const session = createSession(host, { canUseEvents: true, logger: createLoggerWithInMemoryLogs(host) });
session.executeCommandSeq<ts.server.protocol.GeterrRequest>({
command: ts.server.CommandNames.Geterr,
command: ts.server.protocol.CommandTypes.Geterr,
arguments: {
delay: 0,
files: [file.path]
Expand Down Expand Up @@ -624,21 +624,21 @@ describe("unittests:: tsserver:: Project Errors dont include overwrite emit erro

const diags = session.executeCommand({
type: "request",
command: ts.server.CommandNames.CompilerOptionsDiagnosticsFull,
command: ts.server.protocol.CommandTypes.CompilerOptionsDiagnosticsFull,
seq: 2,
arguments: { projectFileName: projectName }
} as ts.server.protocol.CompilerOptionsDiagnosticsRequest).response as readonly ts.server.protocol.DiagnosticWithLinePosition[];
assert.isTrue(diags.length === 0);

session.executeCommand({
type: "request",
command: ts.server.CommandNames.CompilerOptionsForInferredProjects,
command: ts.server.protocol.CommandTypes.CompilerOptionsForInferredProjects,
seq: 3,
arguments: { options: { module: ts.ModuleKind.CommonJS } }
} as ts.server.protocol.SetCompilerOptionsForInferredProjectsRequest);
const diagsAfterUpdate = session.executeCommand({
type: "request",
command: ts.server.CommandNames.CompilerOptionsDiagnosticsFull,
command: ts.server.protocol.CommandTypes.CompilerOptionsDiagnosticsFull,
seq: 4,
arguments: { projectFileName: projectName }
} as ts.server.protocol.CompilerOptionsDiagnosticsRequest).response as readonly ts.server.protocol.DiagnosticWithLinePosition[];
Expand All @@ -665,15 +665,15 @@ describe("unittests:: tsserver:: Project Errors dont include overwrite emit erro

const diags = session.executeCommand({
type: "request",
command: ts.server.CommandNames.CompilerOptionsDiagnosticsFull,
command: ts.server.protocol.CommandTypes.CompilerOptionsDiagnosticsFull,
seq: 2,
arguments: { projectFileName }
} as ts.server.protocol.CompilerOptionsDiagnosticsRequest).response as readonly ts.server.protocol.DiagnosticWithLinePosition[];
assert.isTrue(diags.length === 0);

session.executeCommand({
type: "request",
command: ts.server.CommandNames.OpenExternalProject,
command: ts.server.protocol.CommandTypes.OpenExternalProject,
seq: 3,
arguments: {
projectFileName,
Expand All @@ -683,7 +683,7 @@ describe("unittests:: tsserver:: Project Errors dont include overwrite emit erro
} as ts.server.protocol.OpenExternalProjectRequest);
const diagsAfterUpdate = session.executeCommand({
type: "request",
command: ts.server.CommandNames.CompilerOptionsDiagnosticsFull,
command: ts.server.protocol.CommandTypes.CompilerOptionsDiagnosticsFull,
seq: 4,
arguments: { projectFileName }
} as ts.server.protocol.CompilerOptionsDiagnosticsRequest).response as readonly ts.server.protocol.DiagnosticWithLinePosition[];
Expand Down Expand Up @@ -723,7 +723,7 @@ describe("unittests:: tsserver:: Project Errors reports Options Diagnostic locat

const diags = session.executeCommand({
type: "request",
command: ts.server.CommandNames.SemanticDiagnosticsSync,
command: ts.server.protocol.CommandTypes.SemanticDiagnosticsSync,
seq: 2,
arguments: { file: configFile.path, projectFileName: projectName, includeLinePosition: true }
} as ts.server.protocol.SemanticDiagnosticsSyncRequest).response as readonly ts.server.protocol.DiagnosticWithLinePosition[];
Expand All @@ -734,7 +734,7 @@ describe("unittests:: tsserver:: Project Errors reports Options Diagnostic locat

const diagsAfterEdit = session.executeCommand({
type: "request",
command: ts.server.CommandNames.SemanticDiagnosticsSync,
command: ts.server.protocol.CommandTypes.SemanticDiagnosticsSync,
seq: 2,
arguments: { file: configFile.path, projectFileName: projectName, includeLinePosition: true }
} as ts.server.protocol.SemanticDiagnosticsSyncRequest).response as readonly ts.server.protocol.DiagnosticWithLinePosition[];
Expand Down
Loading