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

This commit is contained in:
Jake Bailey
2023-01-19 16:31:50 -08:00
committed by GitHub
parent 5b18979697
commit ddac387c3e
23 changed files with 447 additions and 443 deletions
+40 -41
View File
@@ -74,7 +74,6 @@ import {
UserPreferences,
} from "./_namespaces/ts";
import {
CommandNames,
protocol,
} from "./_namespaces/ts.server";
@@ -206,32 +205,32 @@ export class SessionClient implements LanguageService {
configure(preferences: UserPreferences) {
this.preferences = preferences;
const args: protocol.ConfigureRequestArguments = { preferences };
const request = this.processRequest(CommandNames.Configure, args);
const request = this.processRequest(protocol.CommandTypes.Configure, args);
this.processResponse(request, /*expectEmptyBody*/ true);
}
/** @internal */
setFormattingOptions(formatOptions: FormatCodeSettings) {
const args: protocol.ConfigureRequestArguments = { formatOptions };
const request = this.processRequest(CommandNames.Configure, args);
const request = this.processRequest(protocol.CommandTypes.Configure, args);
this.processResponse(request, /*expectEmptyBody*/ true);
}
/** @internal */
setCompilerOptionsForInferredProjects(options: protocol.CompilerOptions) {
const args: protocol.SetCompilerOptionsForInferredProjectsArgs = { options };
const request = this.processRequest(CommandNames.CompilerOptionsForInferredProjects, args);
const request = this.processRequest(protocol.CommandTypes.CompilerOptionsForInferredProjects, args);
this.processResponse(request, /*expectEmptyBody*/ false);
}
openFile(file: string, fileContent?: string, scriptKindName?: "TS" | "JS" | "TSX" | "JSX"): void {
const args: protocol.OpenRequestArgs = { file, fileContent, scriptKindName };
this.processRequest(CommandNames.Open, args);
this.processRequest(protocol.CommandTypes.Open, args);
}
closeFile(file: string): void {
const args: protocol.FileRequestArgs = { file };
this.processRequest(CommandNames.Close, args);
this.processRequest(protocol.CommandTypes.Close, args);
}
createChangeFileRequestArgs(fileName: string, start: number, end: number, insertString: string): protocol.ChangeRequestArgs {
@@ -241,7 +240,7 @@ export class SessionClient implements LanguageService {
changeFile(fileName: string, args: protocol.ChangeRequestArgs): void {
// clear the line map after an edit
this.lineMaps.set(fileName, undefined!); // TODO: GH#18217
this.processRequest(CommandNames.Change, args);
this.processRequest(protocol.CommandTypes.Change, args);
}
toLineColumnOffset(fileName: string, position: number) {
@@ -252,7 +251,7 @@ export class SessionClient implements LanguageService {
getQuickInfoAtPosition(fileName: string, position: number): QuickInfo {
const args = this.createFileLocationRequestArgs(fileName, position);
const request = this.processRequest<protocol.QuickInfoRequest>(CommandNames.Quickinfo, args);
const request = this.processRequest<protocol.QuickInfoRequest>(protocol.CommandTypes.Quickinfo, args);
const response = this.processResponse<protocol.QuickInfoResponse>(request);
const body = response.body!; // TODO: GH#18217
@@ -269,7 +268,7 @@ export class SessionClient implements LanguageService {
getProjectInfo(file: string, needFileNameList: boolean): protocol.ProjectInfo {
const args: protocol.ProjectInfoRequestArgs = { file, needFileNameList };
const request = this.processRequest<protocol.ProjectInfoRequest>(CommandNames.ProjectInfo, args);
const request = this.processRequest<protocol.ProjectInfoRequest>(protocol.CommandTypes.ProjectInfo, args);
const response = this.processResponse<protocol.ProjectInfoResponse>(request);
return {
@@ -282,7 +281,7 @@ export class SessionClient implements LanguageService {
// Not passing along 'preferences' because server should already have those from the 'configure' command
const args: protocol.CompletionsRequestArgs = this.createFileLocationRequestArgs(fileName, position);
const request = this.processRequest<protocol.CompletionsRequest>(CommandNames.CompletionInfo, args);
const request = this.processRequest<protocol.CompletionsRequest>(protocol.CommandTypes.CompletionInfo, args);
const response = this.processResponse<protocol.CompletionInfoResponse>(request);
return {
@@ -303,7 +302,7 @@ export class SessionClient implements LanguageService {
getCompletionEntryDetails(fileName: string, position: number, entryName: string, _options: FormatCodeOptions | FormatCodeSettings | undefined, source: string | undefined, _preferences: UserPreferences | undefined, data: unknown): CompletionEntryDetails {
const args: protocol.CompletionDetailsRequestArgs = { ...this.createFileLocationRequestArgs(fileName, position), entryNames: [{ name: entryName, source, data }] };
const request = this.processRequest<protocol.CompletionDetailsRequest>(CommandNames.CompletionDetailsFull, args);
const request = this.processRequest<protocol.CompletionDetailsRequest>(protocol.CommandTypes.CompletionDetailsFull, args);
const response = this.processResponse<protocol.Response>(request);
Debug.assert(response.body.length === 1, "Unexpected length of completion details response body.");
return response.body[0];
@@ -319,7 +318,7 @@ export class SessionClient implements LanguageService {
file: this.host.getScriptFileNames()[0]
};
const request = this.processRequest<protocol.NavtoRequest>(CommandNames.Navto, args);
const request = this.processRequest<protocol.NavtoRequest>(protocol.CommandTypes.Navto, args);
const response = this.processResponse<protocol.NavtoResponse>(request);
return response.body!.map(entry => ({ // TODO: GH#18217
@@ -340,7 +339,7 @@ export class SessionClient implements LanguageService {
// TODO: handle FormatCodeOptions
const request = this.processRequest<protocol.FormatRequest>(CommandNames.Format, args);
const request = this.processRequest<protocol.FormatRequest>(protocol.CommandTypes.Format, args);
const response = this.processResponse<protocol.FormatResponse>(request);
return response.body!.map(entry => this.convertCodeEditsToTextChange(file, entry)); // TODO: GH#18217
@@ -354,7 +353,7 @@ export class SessionClient implements LanguageService {
const args: protocol.FormatOnKeyRequestArgs = { ...this.createFileLocationRequestArgs(fileName, position), key };
// TODO: handle FormatCodeOptions
const request = this.processRequest<protocol.FormatOnKeyRequest>(CommandNames.Formatonkey, args);
const request = this.processRequest<protocol.FormatOnKeyRequest>(protocol.CommandTypes.Formatonkey, args);
const response = this.processResponse<protocol.FormatResponse>(request);
return response.body!.map(entry => this.convertCodeEditsToTextChange(fileName, entry)); // TODO: GH#18217
@@ -363,7 +362,7 @@ export class SessionClient implements LanguageService {
getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] {
const args: protocol.FileLocationRequestArgs = this.createFileLocationRequestArgs(fileName, position);
const request = this.processRequest<protocol.DefinitionRequest>(CommandNames.Definition, args);
const request = this.processRequest<protocol.DefinitionRequest>(protocol.CommandTypes.Definition, args);
const response = this.processResponse<protocol.DefinitionResponse>(request);
return response.body!.map(entry => ({ // TODO: GH#18217
@@ -379,7 +378,7 @@ export class SessionClient implements LanguageService {
getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan {
const args: protocol.FileLocationRequestArgs = this.createFileLocationRequestArgs(fileName, position);
const request = this.processRequest<protocol.DefinitionAndBoundSpanRequest>(CommandNames.DefinitionAndBoundSpan, args);
const request = this.processRequest<protocol.DefinitionAndBoundSpanRequest>(protocol.CommandTypes.DefinitionAndBoundSpan, args);
const response = this.processResponse<protocol.DefinitionInfoAndBoundSpanResponse>(request);
const body = Debug.checkDefined(response.body); // TODO: GH#18217
@@ -400,7 +399,7 @@ export class SessionClient implements LanguageService {
getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] {
const args: protocol.FileLocationRequestArgs = this.createFileLocationRequestArgs(fileName, position);
const request = this.processRequest<protocol.TypeDefinitionRequest>(CommandNames.TypeDefinition, args);
const request = this.processRequest<protocol.TypeDefinitionRequest>(protocol.CommandTypes.TypeDefinition, args);
const response = this.processResponse<protocol.TypeDefinitionResponse>(request);
return response.body!.map(entry => ({ // TODO: GH#18217
@@ -415,7 +414,7 @@ export class SessionClient implements LanguageService {
getSourceDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfo[] {
const args: protocol.FileLocationRequestArgs = this.createFileLocationRequestArgs(fileName, position);
const request = this.processRequest<protocol.FindSourceDefinitionRequest>(CommandNames.FindSourceDefinition, args);
const request = this.processRequest<protocol.FindSourceDefinitionRequest>(protocol.CommandTypes.FindSourceDefinition, args);
const response = this.processResponse<protocol.DefinitionResponse>(request);
const body = Debug.checkDefined(response.body); // TODO: GH#18217
@@ -433,7 +432,7 @@ export class SessionClient implements LanguageService {
getImplementationAtPosition(fileName: string, position: number): ImplementationLocation[] {
const args = this.createFileLocationRequestArgs(fileName, position);
const request = this.processRequest<protocol.ImplementationRequest>(CommandNames.Implementation, args);
const request = this.processRequest<protocol.ImplementationRequest>(protocol.CommandTypes.Implementation, args);
const response = this.processResponse<protocol.ImplementationResponse>(request);
return response.body!.map(entry => ({ // TODO: GH#18217
@@ -446,7 +445,7 @@ export class SessionClient implements LanguageService {
findReferences(fileName: string, position: number): ReferencedSymbol[] {
const args = this.createFileLocationRequestArgs(fileName, position);
const request = this.processRequest<protocol.ReferencesRequest>(CommandNames.ReferencesFull, args);
const request = this.processRequest<protocol.ReferencesRequest>(protocol.CommandTypes.ReferencesFull, args);
const response = this.processResponse(request);
return response.body;
}
@@ -454,7 +453,7 @@ export class SessionClient implements LanguageService {
getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[] {
const args = this.createFileLocationRequestArgs(fileName, position);
const request = this.processRequest<protocol.ReferencesRequest>(CommandNames.References, args);
const request = this.processRequest<protocol.ReferencesRequest>(protocol.CommandTypes.References, args);
const response = this.processResponse<protocol.ReferencesResponse>(request);
return response.body!.refs.map(entry => ({ // TODO: GH#18217
@@ -466,7 +465,7 @@ export class SessionClient implements LanguageService {
}
getFileReferences(fileName: string): ReferenceEntry[] {
const request = this.processRequest<protocol.FileReferencesRequest>(CommandNames.FileReferences, { file: fileName });
const request = this.processRequest<protocol.FileReferencesRequest>(protocol.CommandTypes.FileReferences, { file: fileName });
const response = this.processResponse<protocol.FileReferencesResponse>(request);
return response.body!.refs.map(entry => ({ // TODO: GH#18217
@@ -484,16 +483,16 @@ export class SessionClient implements LanguageService {
}
getSyntacticDiagnostics(file: string): DiagnosticWithLocation[] {
return this.getDiagnostics(file, CommandNames.SyntacticDiagnosticsSync);
return this.getDiagnostics(file, protocol.CommandTypes.SyntacticDiagnosticsSync);
}
getSemanticDiagnostics(file: string): Diagnostic[] {
return this.getDiagnostics(file, CommandNames.SemanticDiagnosticsSync);
return this.getDiagnostics(file, protocol.CommandTypes.SemanticDiagnosticsSync);
}
getSuggestionDiagnostics(file: string): DiagnosticWithLocation[] {
return this.getDiagnostics(file, CommandNames.SuggestionDiagnosticsSync);
return this.getDiagnostics(file, protocol.CommandTypes.SuggestionDiagnosticsSync);
}
private getDiagnostics(file: string, command: CommandNames): DiagnosticWithLocation[] {
private getDiagnostics(file: string, command: protocol.CommandTypes): DiagnosticWithLocation[] {
const request = this.processRequest<protocol.SyntacticDiagnosticsSyncRequest | protocol.SemanticDiagnosticsSyncRequest | protocol.SuggestionDiagnosticsSyncRequest>(command, { file, includeLinePosition: true });
const response = this.processResponse<protocol.SyntacticDiagnosticsSyncResponse | protocol.SemanticDiagnosticsSyncResponse | protocol.SuggestionDiagnosticsSyncResponse>(request);
const sourceText = getSnapshotText(this.host.getScriptSnapshot(file)!);
@@ -523,7 +522,7 @@ export class SessionClient implements LanguageService {
// Not passing along 'options' because server should already have those from the 'configure' command
const args: protocol.RenameRequestArgs = { ...this.createFileLocationRequestArgs(fileName, position), findInStrings, findInComments };
const request = this.processRequest<protocol.RenameRequest>(CommandNames.Rename, args);
const request = this.processRequest<protocol.RenameRequest>(protocol.CommandTypes.Rename, args);
const response = this.processResponse<protocol.RenameResponse>(request);
const body = response.body!; // TODO: GH#18217
const locations: RenameLocation[] = [];
@@ -611,7 +610,7 @@ export class SessionClient implements LanguageService {
}
getNavigationBarItems(file: string): NavigationBarItem[] {
const request = this.processRequest<protocol.NavBarRequest>(CommandNames.NavBar, { file });
const request = this.processRequest<protocol.NavBarRequest>(protocol.CommandTypes.NavBar, { file });
const response = this.processResponse<protocol.NavBarResponse>(request);
const lineMap = this.getLineMap(file);
@@ -630,7 +629,7 @@ export class SessionClient implements LanguageService {
}
getNavigationTree(file: string): NavigationTree {
const request = this.processRequest<protocol.NavTreeRequest>(CommandNames.NavTree, { file });
const request = this.processRequest<protocol.NavTreeRequest>(protocol.CommandTypes.NavTree, { file });
const response = this.processResponse<protocol.NavTreeResponse>(request);
const lineMap = this.getLineMap(file);
@@ -668,7 +667,7 @@ export class SessionClient implements LanguageService {
getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems | undefined {
const args: protocol.SignatureHelpRequestArgs = this.createFileLocationRequestArgs(fileName, position);
const request = this.processRequest<protocol.SignatureHelpRequest>(CommandNames.SignatureHelp, args);
const request = this.processRequest<protocol.SignatureHelpRequest>(protocol.CommandTypes.SignatureHelp, args);
const response = this.processResponse<protocol.SignatureHelpResponse>(request);
if (!response.body) {
@@ -686,7 +685,7 @@ export class SessionClient implements LanguageService {
getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[] {
const args = this.createFileLocationRequestArgs(fileName, position);
const request = this.processRequest<protocol.OccurrencesRequest>(CommandNames.Occurrences, args);
const request = this.processRequest<protocol.OccurrencesRequest>(protocol.CommandTypes.Occurrences, args);
const response = this.processResponse<protocol.OccurrencesResponse>(request);
return response.body!.map(entry => ({ // TODO: GH#18217
@@ -699,7 +698,7 @@ export class SessionClient implements LanguageService {
getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[] {
const args: protocol.DocumentHighlightsRequestArgs = { ...this.createFileLocationRequestArgs(fileName, position), filesToSearch };
const request = this.processRequest<protocol.DocumentHighlightsRequest>(CommandNames.DocumentHighlights, args);
const request = this.processRequest<protocol.DocumentHighlightsRequest>(protocol.CommandTypes.DocumentHighlights, args);
const response = this.processResponse<protocol.DocumentHighlightsResponse>(request);
return response.body!.map(item => ({ // TODO: GH#18217
@@ -712,7 +711,7 @@ export class SessionClient implements LanguageService {
}
getOutliningSpans(file: string): OutliningSpan[] {
const request = this.processRequest<protocol.OutliningSpansRequest>(CommandNames.GetOutliningSpans, { file });
const request = this.processRequest<protocol.OutliningSpansRequest>(protocol.CommandTypes.GetOutliningSpans, { file });
const response = this.processResponse<protocol.OutliningSpansResponse>(request);
return response.body!.map<OutliningSpan>(item => ({
@@ -747,7 +746,7 @@ export class SessionClient implements LanguageService {
getCodeFixesAtPosition(file: string, start: number, end: number, errorCodes: readonly number[]): readonly CodeFixAction[] {
const args: protocol.CodeFixRequestArgs = { ...this.createFileRangeRequestArgs(file, start, end), errorCodes };
const request = this.processRequest<protocol.CodeFixRequest>(CommandNames.GetCodeFixes, args);
const request = this.processRequest<protocol.CodeFixRequest>(protocol.CommandTypes.GetCodeFixes, args);
const response = this.processResponse<protocol.CodeFixResponse>(request);
return response.body!.map<CodeFixAction>(({ fixName, description, changes, commands, fixId, fixAllDescription }) => // TODO: GH#18217
@@ -762,7 +761,7 @@ export class SessionClient implements LanguageService {
const { start, length } = span;
const args: protocol.InlayHintsRequestArgs = { file, start, length };
const request = this.processRequest<protocol.InlayHintsRequest>(CommandNames.ProvideInlayHints, args);
const request = this.processRequest<protocol.InlayHintsRequest>(protocol.CommandTypes.ProvideInlayHints, args);
const response = this.processResponse<protocol.InlayHintsResponse>(request);
return response.body!.map(item => ({ // TODO: GH#18217
@@ -798,7 +797,7 @@ export class SessionClient implements LanguageService {
getApplicableRefactors(fileName: string, positionOrRange: number | TextRange): ApplicableRefactorInfo[] {
const args = this.createFileLocationOrRangeRequestArgs(positionOrRange, fileName);
const request = this.processRequest<protocol.GetApplicableRefactorsRequest>(CommandNames.GetApplicableRefactors, args);
const request = this.processRequest<protocol.GetApplicableRefactorsRequest>(protocol.CommandTypes.GetApplicableRefactors, args);
const response = this.processResponse<protocol.GetApplicableRefactorsResponse>(request);
return response.body!; // TODO: GH#18217
}
@@ -814,7 +813,7 @@ export class SessionClient implements LanguageService {
args.refactor = refactorName;
args.action = actionName;
const request = this.processRequest<protocol.GetEditsForRefactorRequest>(CommandNames.GetEditsForRefactor, args);
const request = this.processRequest<protocol.GetEditsForRefactorRequest>(protocol.CommandTypes.GetEditsForRefactor, args);
const response = this.processResponse<protocol.GetEditsForRefactorResponse>(request);
if (!response.body) {
@@ -871,7 +870,7 @@ export class SessionClient implements LanguageService {
getBraceMatchingAtPosition(fileName: string, position: number): TextSpan[] {
const args = this.createFileLocationRequestArgs(fileName, position);
const request = this.processRequest<protocol.BraceRequest>(CommandNames.Brace, args);
const request = this.processRequest<protocol.BraceRequest>(protocol.CommandTypes.Brace, args);
const response = this.processResponse<protocol.BraceResponse>(request);
return response.body!.map(entry => this.decodeSpan(entry, fileName)); // TODO: GH#18217
@@ -918,7 +917,7 @@ export class SessionClient implements LanguageService {
prepareCallHierarchy(fileName: string, position: number): CallHierarchyItem | CallHierarchyItem[] | undefined {
const args = this.createFileLocationRequestArgs(fileName, position);
const request = this.processRequest<protocol.PrepareCallHierarchyRequest>(CommandNames.PrepareCallHierarchy, args);
const request = this.processRequest<protocol.PrepareCallHierarchyRequest>(protocol.CommandTypes.PrepareCallHierarchy, args);
const response = this.processResponse<protocol.PrepareCallHierarchyResponse>(request);
return response.body && mapOneOrMany(response.body, item => this.convertCallHierarchyItem(item));
}
@@ -932,7 +931,7 @@ export class SessionClient implements LanguageService {
provideCallHierarchyIncomingCalls(fileName: string, position: number) {
const args = this.createFileLocationRequestArgs(fileName, position);
const request = this.processRequest<protocol.ProvideCallHierarchyIncomingCallsRequest>(CommandNames.ProvideCallHierarchyIncomingCalls, args);
const request = this.processRequest<protocol.ProvideCallHierarchyIncomingCallsRequest>(protocol.CommandTypes.ProvideCallHierarchyIncomingCalls, args);
const response = this.processResponse<protocol.ProvideCallHierarchyIncomingCallsResponse>(request);
return response.body.map(item => this.convertCallHierarchyIncomingCall(item));
}
@@ -946,7 +945,7 @@ export class SessionClient implements LanguageService {
provideCallHierarchyOutgoingCalls(fileName: string, position: number) {
const args = this.createFileLocationRequestArgs(fileName, position);
const request = this.processRequest<protocol.ProvideCallHierarchyOutgoingCallsRequest>(CommandNames.ProvideCallHierarchyOutgoingCalls, args);
const request = this.processRequest<protocol.ProvideCallHierarchyOutgoingCallsRequest>(protocol.CommandTypes.ProvideCallHierarchyOutgoingCalls, args);
const response = this.processResponse<protocol.ProvideCallHierarchyOutgoingCallsResponse>(request);
return response.body.map(item => this.convertCallHierarchyOutgoingCall(fileName, item));
}
+1 -1
View File
@@ -36,7 +36,6 @@ import {
ProjectFilesWithTSDiagnostics,
ProjectKind,
ProjectOptions,
protocol,
ScriptInfo,
ScriptInfoVersion,
ServerHost,
@@ -179,6 +178,7 @@ import {
WatchType,
WildcardDirectoryWatcher,
} from "./_namespaces/ts";
import * as protocol from "./protocol";
export const maxProgramSizeForNonTsFiles = 20 * 1024 * 1024;
/** @internal */
+1 -1
View File
@@ -14,7 +14,6 @@ import {
ProjectOptions,
ProjectReferenceProjectLoadKind,
ProjectService,
protocol,
ScriptInfo,
ServerHost,
Session,
@@ -148,6 +147,7 @@ import {
WatchOptions,
WatchType,
} from "./_namespaces/ts";
import * as protocol from "./protocol";
export enum ProjectKind {
Inferred,
+1 -1
View File
@@ -11,7 +11,6 @@ import {
NormalizedPath,
Project,
ProjectKind,
protocol,
ScriptVersionCache,
ServerHost,
} from "./_namespaces/ts.server";
@@ -52,6 +51,7 @@ import {
TextSpan,
unorderedRemoveItem,
} from "./_namespaces/ts";
import * as protocol from "./protocol";
export interface ScriptInfoVersion {
svc: number;
+1 -1
View File
@@ -11,8 +11,8 @@ import {
} from "./_namespaces/ts";
import {
emptyArray,
protocol,
} from "./_namespaces/ts.server";
import * as protocol from "./protocol";
const lineCollectionCapacity = 4;
+176 -174
View File
@@ -171,7 +171,6 @@ import {
ProjectServiceEventHandler,
ProjectServiceOptions,
ProjectsUpdatedInBackgroundEvent,
protocol,
ScriptInfo,
ScriptInfoOrConfig,
ServerHost,
@@ -179,6 +178,7 @@ import {
toNormalizedPath,
updateProjectIfDirty,
} from "./_namespaces/ts.server";
import * as protocol from "./protocol";
interface StackTraceError extends Error {
stack?: string;
@@ -305,7 +305,9 @@ function allEditsBeforePos(edits: readonly TextChange[], pos: number): boolean {
// The var assignment ensures that even though CommandTypes are a const enum
// we want to ensure the value is maintained in the out since the file is
// built using --preseveConstEnum.
/** @deprecated use ts.server.protocol.CommandTypes */
export type CommandNames = protocol.CommandTypes;
/** @deprecated use ts.server.protocol.CommandTypes */
export const CommandNames = (protocol as any).CommandTypes;
export function formatMessage<T extends protocol.Message>(msg: T, logger: Logger, byteLength: (s: string, encoding: BufferEncoding) => number, newLine: string): string {
@@ -847,67 +849,67 @@ function getMappedContextSpanForProject(documentSpan: DocumentSpan, project: Pro
return getMappedContextSpan(documentSpan, project.getSourceMapper(), p => project.projectService.fileExists(p as NormalizedPath));
}
const invalidPartialSemanticModeCommands: readonly CommandNames[] = [
CommandNames.OpenExternalProject,
CommandNames.OpenExternalProjects,
CommandNames.CloseExternalProject,
CommandNames.SynchronizeProjectList,
CommandNames.EmitOutput,
CommandNames.CompileOnSaveAffectedFileList,
CommandNames.CompileOnSaveEmitFile,
CommandNames.CompilerOptionsDiagnosticsFull,
CommandNames.EncodedSemanticClassificationsFull,
CommandNames.SemanticDiagnosticsSync,
CommandNames.SuggestionDiagnosticsSync,
CommandNames.GeterrForProject,
CommandNames.Reload,
CommandNames.ReloadProjects,
CommandNames.GetCodeFixes,
CommandNames.GetCodeFixesFull,
CommandNames.GetCombinedCodeFix,
CommandNames.GetCombinedCodeFixFull,
CommandNames.ApplyCodeActionCommand,
CommandNames.GetSupportedCodeFixes,
CommandNames.GetApplicableRefactors,
CommandNames.GetEditsForRefactor,
CommandNames.GetEditsForRefactorFull,
CommandNames.OrganizeImports,
CommandNames.OrganizeImportsFull,
CommandNames.GetEditsForFileRename,
CommandNames.GetEditsForFileRenameFull,
CommandNames.PrepareCallHierarchy,
CommandNames.ProvideCallHierarchyIncomingCalls,
CommandNames.ProvideCallHierarchyOutgoingCalls,
const invalidPartialSemanticModeCommands: readonly protocol.CommandTypes[] = [
protocol.CommandTypes.OpenExternalProject,
protocol.CommandTypes.OpenExternalProjects,
protocol.CommandTypes.CloseExternalProject,
protocol.CommandTypes.SynchronizeProjectList,
protocol.CommandTypes.EmitOutput,
protocol.CommandTypes.CompileOnSaveAffectedFileList,
protocol.CommandTypes.CompileOnSaveEmitFile,
protocol.CommandTypes.CompilerOptionsDiagnosticsFull,
protocol.CommandTypes.EncodedSemanticClassificationsFull,
protocol.CommandTypes.SemanticDiagnosticsSync,
protocol.CommandTypes.SuggestionDiagnosticsSync,
protocol.CommandTypes.GeterrForProject,
protocol.CommandTypes.Reload,
protocol.CommandTypes.ReloadProjects,
protocol.CommandTypes.GetCodeFixes,
protocol.CommandTypes.GetCodeFixesFull,
protocol.CommandTypes.GetCombinedCodeFix,
protocol.CommandTypes.GetCombinedCodeFixFull,
protocol.CommandTypes.ApplyCodeActionCommand,
protocol.CommandTypes.GetSupportedCodeFixes,
protocol.CommandTypes.GetApplicableRefactors,
protocol.CommandTypes.GetEditsForRefactor,
protocol.CommandTypes.GetEditsForRefactorFull,
protocol.CommandTypes.OrganizeImports,
protocol.CommandTypes.OrganizeImportsFull,
protocol.CommandTypes.GetEditsForFileRename,
protocol.CommandTypes.GetEditsForFileRenameFull,
protocol.CommandTypes.PrepareCallHierarchy,
protocol.CommandTypes.ProvideCallHierarchyIncomingCalls,
protocol.CommandTypes.ProvideCallHierarchyOutgoingCalls,
];
const invalidSyntacticModeCommands: readonly CommandNames[] = [
const invalidSyntacticModeCommands: readonly protocol.CommandTypes[] = [
...invalidPartialSemanticModeCommands,
CommandNames.Definition,
CommandNames.DefinitionFull,
CommandNames.DefinitionAndBoundSpan,
CommandNames.DefinitionAndBoundSpanFull,
CommandNames.TypeDefinition,
CommandNames.Implementation,
CommandNames.ImplementationFull,
CommandNames.References,
CommandNames.ReferencesFull,
CommandNames.Rename,
CommandNames.RenameLocationsFull,
CommandNames.RenameInfoFull,
CommandNames.Quickinfo,
CommandNames.QuickinfoFull,
CommandNames.CompletionInfo,
CommandNames.Completions,
CommandNames.CompletionsFull,
CommandNames.CompletionDetails,
CommandNames.CompletionDetailsFull,
CommandNames.SignatureHelp,
CommandNames.SignatureHelpFull,
CommandNames.Navto,
CommandNames.NavtoFull,
CommandNames.Occurrences,
CommandNames.DocumentHighlights,
CommandNames.DocumentHighlightsFull,
protocol.CommandTypes.Definition,
protocol.CommandTypes.DefinitionFull,
protocol.CommandTypes.DefinitionAndBoundSpan,
protocol.CommandTypes.DefinitionAndBoundSpanFull,
protocol.CommandTypes.TypeDefinition,
protocol.CommandTypes.Implementation,
protocol.CommandTypes.ImplementationFull,
protocol.CommandTypes.References,
protocol.CommandTypes.ReferencesFull,
protocol.CommandTypes.Rename,
protocol.CommandTypes.RenameLocationsFull,
protocol.CommandTypes.RenameInfoFull,
protocol.CommandTypes.Quickinfo,
protocol.CommandTypes.QuickinfoFull,
protocol.CommandTypes.CompletionInfo,
protocol.CommandTypes.Completions,
protocol.CommandTypes.CompletionsFull,
protocol.CommandTypes.CompletionDetails,
protocol.CommandTypes.CompletionDetailsFull,
protocol.CommandTypes.SignatureHelp,
protocol.CommandTypes.SignatureHelpFull,
protocol.CommandTypes.Navto,
protocol.CommandTypes.NavtoFull,
protocol.CommandTypes.Occurrences,
protocol.CommandTypes.DocumentHighlights,
protocol.CommandTypes.DocumentHighlightsFull,
];
export interface SessionOptions {
@@ -2456,7 +2458,7 @@ export class Session<TMessage = string> implements EventSender {
this.changeSeq++;
// make sure no changes happen before this one is finished
if (info.reloadFromFile(tempFileName)) {
this.doOutput(/*info*/ undefined, CommandNames.Reload, reqSeq, /*success*/ true);
this.doOutput(/*info*/ undefined, protocol.CommandTypes.Reload, reqSeq, /*success*/ true);
}
}
}
@@ -3101,26 +3103,26 @@ export class Session<TMessage = string> implements EventSender {
}
private handlers = new Map(Object.entries<(request: any) => HandlerResponse>({ // TODO(jakebailey): correctly type the handlers
[CommandNames.Status]: () => {
[protocol.CommandTypes.Status]: () => {
const response: protocol.StatusResponseBody = { version };
return this.requiredResponse(response);
},
[CommandNames.OpenExternalProject]: (request: protocol.OpenExternalProjectRequest) => {
[protocol.CommandTypes.OpenExternalProject]: (request: protocol.OpenExternalProjectRequest) => {
this.projectService.openExternalProject(request.arguments);
// TODO: GH#20447 report errors
return this.requiredResponse(/*response*/ true);
},
[CommandNames.OpenExternalProjects]: (request: protocol.OpenExternalProjectsRequest) => {
[protocol.CommandTypes.OpenExternalProjects]: (request: protocol.OpenExternalProjectsRequest) => {
this.projectService.openExternalProjects(request.arguments.projects);
// TODO: GH#20447 report errors
return this.requiredResponse(/*response*/ true);
},
[CommandNames.CloseExternalProject]: (request: protocol.CloseExternalProjectRequest) => {
[protocol.CommandTypes.CloseExternalProject]: (request: protocol.CloseExternalProjectRequest) => {
this.projectService.closeExternalProject(request.arguments.projectFileName);
// TODO: GH#20447 report errors
return this.requiredResponse(/*response*/ true);
},
[CommandNames.SynchronizeProjectList]: (request: protocol.SynchronizeProjectListRequest) => {
[protocol.CommandTypes.SynchronizeProjectList]: (request: protocol.SynchronizeProjectListRequest) => {
const result = this.projectService.synchronizeProjectList(request.arguments.knownProjects, request.arguments.includeProjectReferenceRedirectInfo);
if (!result.some(p => p.projectErrors && p.projectErrors.length !== 0)) {
return this.requiredResponse(result);
@@ -3138,7 +3140,7 @@ export class Session<TMessage = string> implements EventSender {
});
return this.requiredResponse(converted);
},
[CommandNames.UpdateOpen]: (request: protocol.UpdateOpenRequest) => {
[protocol.CommandTypes.UpdateOpen]: (request: protocol.UpdateOpenRequest) => {
this.changeSeq++;
this.projectService.applyChangesInOpenFiles(
request.arguments.openFiles && mapIterator(request.arguments.openFiles, file => ({
@@ -3160,7 +3162,7 @@ export class Session<TMessage = string> implements EventSender {
);
return this.requiredResponse(/*response*/ true);
},
[CommandNames.ApplyChangedToOpenFiles]: (request: protocol.ApplyChangedToOpenFilesRequest) => {
[protocol.CommandTypes.ApplyChangedToOpenFiles]: (request: protocol.ApplyChangedToOpenFilesRequest) => {
this.changeSeq++;
this.projectService.applyChangesInOpenFiles(
request.arguments.openFiles,
@@ -3174,53 +3176,53 @@ export class Session<TMessage = string> implements EventSender {
// TODO: report errors
return this.requiredResponse(/*response*/ true);
},
[CommandNames.Exit]: () => {
[protocol.CommandTypes.Exit]: () => {
this.exit();
return this.notRequired();
},
[CommandNames.Definition]: (request: protocol.DefinitionRequest) => {
[protocol.CommandTypes.Definition]: (request: protocol.DefinitionRequest) => {
return this.requiredResponse(this.getDefinition(request.arguments, /*simplifiedResult*/ true));
},
[CommandNames.DefinitionFull]: (request: protocol.DefinitionRequest) => {
[protocol.CommandTypes.DefinitionFull]: (request: protocol.DefinitionRequest) => {
return this.requiredResponse(this.getDefinition(request.arguments, /*simplifiedResult*/ false));
},
[CommandNames.DefinitionAndBoundSpan]: (request: protocol.DefinitionAndBoundSpanRequest) => {
[protocol.CommandTypes.DefinitionAndBoundSpan]: (request: protocol.DefinitionAndBoundSpanRequest) => {
return this.requiredResponse(this.getDefinitionAndBoundSpan(request.arguments, /*simplifiedResult*/ true));
},
[CommandNames.DefinitionAndBoundSpanFull]: (request: protocol.DefinitionAndBoundSpanRequest) => {
[protocol.CommandTypes.DefinitionAndBoundSpanFull]: (request: protocol.DefinitionAndBoundSpanRequest) => {
return this.requiredResponse(this.getDefinitionAndBoundSpan(request.arguments, /*simplifiedResult*/ false));
},
[CommandNames.FindSourceDefinition]: (request: protocol.FindSourceDefinitionRequest) => {
[protocol.CommandTypes.FindSourceDefinition]: (request: protocol.FindSourceDefinitionRequest) => {
return this.requiredResponse(this.findSourceDefinition(request.arguments));
},
[CommandNames.EmitOutput]: (request: protocol.EmitOutputRequest) => {
[protocol.CommandTypes.EmitOutput]: (request: protocol.EmitOutputRequest) => {
return this.requiredResponse(this.getEmitOutput(request.arguments));
},
[CommandNames.TypeDefinition]: (request: protocol.FileLocationRequest) => {
[protocol.CommandTypes.TypeDefinition]: (request: protocol.FileLocationRequest) => {
return this.requiredResponse(this.getTypeDefinition(request.arguments));
},
[CommandNames.Implementation]: (request: protocol.Request) => {
[protocol.CommandTypes.Implementation]: (request: protocol.Request) => {
return this.requiredResponse(this.getImplementation(request.arguments, /*simplifiedResult*/ true));
},
[CommandNames.ImplementationFull]: (request: protocol.Request) => {
[protocol.CommandTypes.ImplementationFull]: (request: protocol.Request) => {
return this.requiredResponse(this.getImplementation(request.arguments, /*simplifiedResult*/ false));
},
[CommandNames.References]: (request: protocol.FileLocationRequest) => {
[protocol.CommandTypes.References]: (request: protocol.FileLocationRequest) => {
return this.requiredResponse(this.getReferences(request.arguments, /*simplifiedResult*/ true));
},
[CommandNames.ReferencesFull]: (request: protocol.FileLocationRequest) => {
[protocol.CommandTypes.ReferencesFull]: (request: protocol.FileLocationRequest) => {
return this.requiredResponse(this.getReferences(request.arguments, /*simplifiedResult*/ false));
},
[CommandNames.Rename]: (request: protocol.RenameRequest) => {
[protocol.CommandTypes.Rename]: (request: protocol.RenameRequest) => {
return this.requiredResponse(this.getRenameLocations(request.arguments, /*simplifiedResult*/ true));
},
[CommandNames.RenameLocationsFull]: (request: protocol.RenameFullRequest) => {
[protocol.CommandTypes.RenameLocationsFull]: (request: protocol.RenameFullRequest) => {
return this.requiredResponse(this.getRenameLocations(request.arguments, /*simplifiedResult*/ false));
},
[CommandNames.RenameInfoFull]: (request: protocol.FileLocationRequest) => {
[protocol.CommandTypes.RenameInfoFull]: (request: protocol.FileLocationRequest) => {
return this.requiredResponse(this.getRenameInfo(request.arguments));
},
[CommandNames.Open]: (request: protocol.OpenRequest) => {
[protocol.CommandTypes.Open]: (request: protocol.OpenRequest) => {
this.openClientFile(
toNormalizedPath(request.arguments.file),
request.arguments.fileContent,
@@ -3228,271 +3230,271 @@ export class Session<TMessage = string> implements EventSender {
request.arguments.projectRootPath ? toNormalizedPath(request.arguments.projectRootPath) : undefined);
return this.notRequired();
},
[CommandNames.Quickinfo]: (request: protocol.QuickInfoRequest) => {
[protocol.CommandTypes.Quickinfo]: (request: protocol.QuickInfoRequest) => {
return this.requiredResponse(this.getQuickInfoWorker(request.arguments, /*simplifiedResult*/ true));
},
[CommandNames.QuickinfoFull]: (request: protocol.QuickInfoRequest) => {
[protocol.CommandTypes.QuickinfoFull]: (request: protocol.QuickInfoRequest) => {
return this.requiredResponse(this.getQuickInfoWorker(request.arguments, /*simplifiedResult*/ false));
},
[CommandNames.GetOutliningSpans]: (request: protocol.FileRequest) => {
[protocol.CommandTypes.GetOutliningSpans]: (request: protocol.FileRequest) => {
return this.requiredResponse(this.getOutliningSpans(request.arguments, /*simplifiedResult*/ true));
},
[CommandNames.GetOutliningSpansFull]: (request: protocol.FileRequest) => {
[protocol.CommandTypes.GetOutliningSpansFull]: (request: protocol.FileRequest) => {
return this.requiredResponse(this.getOutliningSpans(request.arguments, /*simplifiedResult*/ false));
},
[CommandNames.TodoComments]: (request: protocol.TodoCommentRequest) => {
[protocol.CommandTypes.TodoComments]: (request: protocol.TodoCommentRequest) => {
return this.requiredResponse(this.getTodoComments(request.arguments));
},
[CommandNames.Indentation]: (request: protocol.IndentationRequest) => {
[protocol.CommandTypes.Indentation]: (request: protocol.IndentationRequest) => {
return this.requiredResponse(this.getIndentation(request.arguments));
},
[CommandNames.NameOrDottedNameSpan]: (request: protocol.FileLocationRequest) => {
[protocol.CommandTypes.NameOrDottedNameSpan]: (request: protocol.FileLocationRequest) => {
return this.requiredResponse(this.getNameOrDottedNameSpan(request.arguments));
},
[CommandNames.BreakpointStatement]: (request: protocol.FileLocationRequest) => {
[protocol.CommandTypes.BreakpointStatement]: (request: protocol.FileLocationRequest) => {
return this.requiredResponse(this.getBreakpointStatement(request.arguments));
},
[CommandNames.BraceCompletion]: (request: protocol.BraceCompletionRequest) => {
[protocol.CommandTypes.BraceCompletion]: (request: protocol.BraceCompletionRequest) => {
return this.requiredResponse(this.isValidBraceCompletion(request.arguments));
},
[CommandNames.DocCommentTemplate]: (request: protocol.DocCommentTemplateRequest) => {
[protocol.CommandTypes.DocCommentTemplate]: (request: protocol.DocCommentTemplateRequest) => {
return this.requiredResponse(this.getDocCommentTemplate(request.arguments));
},
[CommandNames.GetSpanOfEnclosingComment]: (request: protocol.SpanOfEnclosingCommentRequest) => {
[protocol.CommandTypes.GetSpanOfEnclosingComment]: (request: protocol.SpanOfEnclosingCommentRequest) => {
return this.requiredResponse(this.getSpanOfEnclosingComment(request.arguments));
},
[CommandNames.FileReferences]: (request: protocol.FileReferencesRequest) => {
[protocol.CommandTypes.FileReferences]: (request: protocol.FileReferencesRequest) => {
return this.requiredResponse(this.getFileReferences(request.arguments, /*simplifiedResult*/ true));
},
[CommandNames.FileReferencesFull]: (request: protocol.FileReferencesRequest) => {
[protocol.CommandTypes.FileReferencesFull]: (request: protocol.FileReferencesRequest) => {
return this.requiredResponse(this.getFileReferences(request.arguments, /*simplifiedResult*/ false));
},
[CommandNames.Format]: (request: protocol.FormatRequest) => {
[protocol.CommandTypes.Format]: (request: protocol.FormatRequest) => {
return this.requiredResponse(this.getFormattingEditsForRange(request.arguments));
},
[CommandNames.Formatonkey]: (request: protocol.FormatOnKeyRequest) => {
[protocol.CommandTypes.Formatonkey]: (request: protocol.FormatOnKeyRequest) => {
return this.requiredResponse(this.getFormattingEditsAfterKeystroke(request.arguments));
},
[CommandNames.FormatFull]: (request: protocol.FormatRequest) => {
[protocol.CommandTypes.FormatFull]: (request: protocol.FormatRequest) => {
return this.requiredResponse(this.getFormattingEditsForDocumentFull(request.arguments));
},
[CommandNames.FormatonkeyFull]: (request: protocol.FormatOnKeyRequest) => {
[protocol.CommandTypes.FormatonkeyFull]: (request: protocol.FormatOnKeyRequest) => {
return this.requiredResponse(this.getFormattingEditsAfterKeystrokeFull(request.arguments));
},
[CommandNames.FormatRangeFull]: (request: protocol.FormatRequest) => {
[protocol.CommandTypes.FormatRangeFull]: (request: protocol.FormatRequest) => {
return this.requiredResponse(this.getFormattingEditsForRangeFull(request.arguments));
},
[CommandNames.CompletionInfo]: (request: protocol.CompletionsRequest) => {
return this.requiredResponse(this.getCompletions(request.arguments, CommandNames.CompletionInfo));
[protocol.CommandTypes.CompletionInfo]: (request: protocol.CompletionsRequest) => {
return this.requiredResponse(this.getCompletions(request.arguments, protocol.CommandTypes.CompletionInfo));
},
[CommandNames.Completions]: (request: protocol.CompletionsRequest) => {
return this.requiredResponse(this.getCompletions(request.arguments, CommandNames.Completions));
[protocol.CommandTypes.Completions]: (request: protocol.CompletionsRequest) => {
return this.requiredResponse(this.getCompletions(request.arguments, protocol.CommandTypes.Completions));
},
[CommandNames.CompletionsFull]: (request: protocol.CompletionsRequest) => {
return this.requiredResponse(this.getCompletions(request.arguments, CommandNames.CompletionsFull));
[protocol.CommandTypes.CompletionsFull]: (request: protocol.CompletionsRequest) => {
return this.requiredResponse(this.getCompletions(request.arguments, protocol.CommandTypes.CompletionsFull));
},
[CommandNames.CompletionDetails]: (request: protocol.CompletionDetailsRequest) => {
[protocol.CommandTypes.CompletionDetails]: (request: protocol.CompletionDetailsRequest) => {
return this.requiredResponse(this.getCompletionEntryDetails(request.arguments, /*fullResult*/ false));
},
[CommandNames.CompletionDetailsFull]: (request: protocol.CompletionDetailsRequest) => {
[protocol.CommandTypes.CompletionDetailsFull]: (request: protocol.CompletionDetailsRequest) => {
return this.requiredResponse(this.getCompletionEntryDetails(request.arguments, /*fullResult*/ true));
},
[CommandNames.CompileOnSaveAffectedFileList]: (request: protocol.CompileOnSaveAffectedFileListRequest) => {
[protocol.CommandTypes.CompileOnSaveAffectedFileList]: (request: protocol.CompileOnSaveAffectedFileListRequest) => {
return this.requiredResponse(this.getCompileOnSaveAffectedFileList(request.arguments));
},
[CommandNames.CompileOnSaveEmitFile]: (request: protocol.CompileOnSaveEmitFileRequest) => {
[protocol.CommandTypes.CompileOnSaveEmitFile]: (request: protocol.CompileOnSaveEmitFileRequest) => {
return this.requiredResponse(this.emitFile(request.arguments));
},
[CommandNames.SignatureHelp]: (request: protocol.SignatureHelpRequest) => {
[protocol.CommandTypes.SignatureHelp]: (request: protocol.SignatureHelpRequest) => {
return this.requiredResponse(this.getSignatureHelpItems(request.arguments, /*simplifiedResult*/ true));
},
[CommandNames.SignatureHelpFull]: (request: protocol.SignatureHelpRequest) => {
[protocol.CommandTypes.SignatureHelpFull]: (request: protocol.SignatureHelpRequest) => {
return this.requiredResponse(this.getSignatureHelpItems(request.arguments, /*simplifiedResult*/ false));
},
[CommandNames.CompilerOptionsDiagnosticsFull]: (request: protocol.CompilerOptionsDiagnosticsRequest) => {
[protocol.CommandTypes.CompilerOptionsDiagnosticsFull]: (request: protocol.CompilerOptionsDiagnosticsRequest) => {
return this.requiredResponse(this.getCompilerOptionsDiagnostics(request.arguments));
},
[CommandNames.EncodedSyntacticClassificationsFull]: (request: protocol.EncodedSyntacticClassificationsRequest) => {
[protocol.CommandTypes.EncodedSyntacticClassificationsFull]: (request: protocol.EncodedSyntacticClassificationsRequest) => {
return this.requiredResponse(this.getEncodedSyntacticClassifications(request.arguments));
},
[CommandNames.EncodedSemanticClassificationsFull]: (request: protocol.EncodedSemanticClassificationsRequest) => {
[protocol.CommandTypes.EncodedSemanticClassificationsFull]: (request: protocol.EncodedSemanticClassificationsRequest) => {
return this.requiredResponse(this.getEncodedSemanticClassifications(request.arguments));
},
[CommandNames.Cleanup]: () => {
[protocol.CommandTypes.Cleanup]: () => {
this.cleanup();
return this.requiredResponse(/*response*/ true);
},
[CommandNames.SemanticDiagnosticsSync]: (request: protocol.SemanticDiagnosticsSyncRequest) => {
[protocol.CommandTypes.SemanticDiagnosticsSync]: (request: protocol.SemanticDiagnosticsSyncRequest) => {
return this.requiredResponse(this.getSemanticDiagnosticsSync(request.arguments));
},
[CommandNames.SyntacticDiagnosticsSync]: (request: protocol.SyntacticDiagnosticsSyncRequest) => {
[protocol.CommandTypes.SyntacticDiagnosticsSync]: (request: protocol.SyntacticDiagnosticsSyncRequest) => {
return this.requiredResponse(this.getSyntacticDiagnosticsSync(request.arguments));
},
[CommandNames.SuggestionDiagnosticsSync]: (request: protocol.SuggestionDiagnosticsSyncRequest) => {
[protocol.CommandTypes.SuggestionDiagnosticsSync]: (request: protocol.SuggestionDiagnosticsSyncRequest) => {
return this.requiredResponse(this.getSuggestionDiagnosticsSync(request.arguments));
},
[CommandNames.Geterr]: (request: protocol.GeterrRequest) => {
[protocol.CommandTypes.Geterr]: (request: protocol.GeterrRequest) => {
this.errorCheck.startNew(next => this.getDiagnostics(next, request.arguments.delay, request.arguments.files));
return this.notRequired();
},
[CommandNames.GeterrForProject]: (request: protocol.GeterrForProjectRequest) => {
[protocol.CommandTypes.GeterrForProject]: (request: protocol.GeterrForProjectRequest) => {
this.errorCheck.startNew(next => this.getDiagnosticsForProject(next, request.arguments.delay, request.arguments.file));
return this.notRequired();
},
[CommandNames.Change]: (request: protocol.ChangeRequest) => {
[protocol.CommandTypes.Change]: (request: protocol.ChangeRequest) => {
this.change(request.arguments);
return this.notRequired();
},
[CommandNames.Configure]: (request: protocol.ConfigureRequest) => {
[protocol.CommandTypes.Configure]: (request: protocol.ConfigureRequest) => {
this.projectService.setHostConfiguration(request.arguments);
this.doOutput(/*info*/ undefined, CommandNames.Configure, request.seq, /*success*/ true);
this.doOutput(/*info*/ undefined, protocol.CommandTypes.Configure, request.seq, /*success*/ true);
return this.notRequired();
},
[CommandNames.Reload]: (request: protocol.ReloadRequest) => {
[protocol.CommandTypes.Reload]: (request: protocol.ReloadRequest) => {
this.reload(request.arguments, request.seq);
return this.requiredResponse({ reloadFinished: true });
},
[CommandNames.Saveto]: (request: protocol.Request) => {
[protocol.CommandTypes.Saveto]: (request: protocol.Request) => {
const savetoArgs = request.arguments as protocol.SavetoRequestArgs;
this.saveToTmp(savetoArgs.file, savetoArgs.tmpfile);
return this.notRequired();
},
[CommandNames.Close]: (request: protocol.Request) => {
[protocol.CommandTypes.Close]: (request: protocol.Request) => {
const closeArgs = request.arguments as protocol.FileRequestArgs;
this.closeClientFile(closeArgs.file);
return this.notRequired();
},
[CommandNames.Navto]: (request: protocol.NavtoRequest) => {
[protocol.CommandTypes.Navto]: (request: protocol.NavtoRequest) => {
return this.requiredResponse(this.getNavigateToItems(request.arguments, /*simplifiedResult*/ true));
},
[CommandNames.NavtoFull]: (request: protocol.NavtoRequest) => {
[protocol.CommandTypes.NavtoFull]: (request: protocol.NavtoRequest) => {
return this.requiredResponse(this.getNavigateToItems(request.arguments, /*simplifiedResult*/ false));
},
[CommandNames.Brace]: (request: protocol.FileLocationRequest) => {
[protocol.CommandTypes.Brace]: (request: protocol.FileLocationRequest) => {
return this.requiredResponse(this.getBraceMatching(request.arguments, /*simplifiedResult*/ true));
},
[CommandNames.BraceFull]: (request: protocol.FileLocationRequest) => {
[protocol.CommandTypes.BraceFull]: (request: protocol.FileLocationRequest) => {
return this.requiredResponse(this.getBraceMatching(request.arguments, /*simplifiedResult*/ false));
},
[CommandNames.NavBar]: (request: protocol.FileRequest) => {
[protocol.CommandTypes.NavBar]: (request: protocol.FileRequest) => {
return this.requiredResponse(this.getNavigationBarItems(request.arguments, /*simplifiedResult*/ true));
},
[CommandNames.NavBarFull]: (request: protocol.FileRequest) => {
[protocol.CommandTypes.NavBarFull]: (request: protocol.FileRequest) => {
return this.requiredResponse(this.getNavigationBarItems(request.arguments, /*simplifiedResult*/ false));
},
[CommandNames.NavTree]: (request: protocol.FileRequest) => {
[protocol.CommandTypes.NavTree]: (request: protocol.FileRequest) => {
return this.requiredResponse(this.getNavigationTree(request.arguments, /*simplifiedResult*/ true));
},
[CommandNames.NavTreeFull]: (request: protocol.FileRequest) => {
[protocol.CommandTypes.NavTreeFull]: (request: protocol.FileRequest) => {
return this.requiredResponse(this.getNavigationTree(request.arguments, /*simplifiedResult*/ false));
},
[CommandNames.Occurrences]: (request: protocol.FileLocationRequest) => {
[protocol.CommandTypes.Occurrences]: (request: protocol.FileLocationRequest) => {
return this.requiredResponse(this.getOccurrences(request.arguments));
},
[CommandNames.DocumentHighlights]: (request: protocol.DocumentHighlightsRequest) => {
[protocol.CommandTypes.DocumentHighlights]: (request: protocol.DocumentHighlightsRequest) => {
return this.requiredResponse(this.getDocumentHighlights(request.arguments, /*simplifiedResult*/ true));
},
[CommandNames.DocumentHighlightsFull]: (request: protocol.DocumentHighlightsRequest) => {
[protocol.CommandTypes.DocumentHighlightsFull]: (request: protocol.DocumentHighlightsRequest) => {
return this.requiredResponse(this.getDocumentHighlights(request.arguments, /*simplifiedResult*/ false));
},
[CommandNames.CompilerOptionsForInferredProjects]: (request: protocol.SetCompilerOptionsForInferredProjectsRequest) => {
[protocol.CommandTypes.CompilerOptionsForInferredProjects]: (request: protocol.SetCompilerOptionsForInferredProjectsRequest) => {
this.setCompilerOptionsForInferredProjects(request.arguments);
return this.requiredResponse(/*response*/ true);
},
[CommandNames.ProjectInfo]: (request: protocol.ProjectInfoRequest) => {
[protocol.CommandTypes.ProjectInfo]: (request: protocol.ProjectInfoRequest) => {
return this.requiredResponse(this.getProjectInfo(request.arguments));
},
[CommandNames.ReloadProjects]: () => {
[protocol.CommandTypes.ReloadProjects]: () => {
this.projectService.reloadProjects();
return this.notRequired();
},
[CommandNames.JsxClosingTag]: (request: protocol.JsxClosingTagRequest) => {
[protocol.CommandTypes.JsxClosingTag]: (request: protocol.JsxClosingTagRequest) => {
return this.requiredResponse(this.getJsxClosingTag(request.arguments));
},
[CommandNames.GetCodeFixes]: (request: protocol.CodeFixRequest) => {
[protocol.CommandTypes.GetCodeFixes]: (request: protocol.CodeFixRequest) => {
return this.requiredResponse(this.getCodeFixes(request.arguments, /*simplifiedResult*/ true));
},
[CommandNames.GetCodeFixesFull]: (request: protocol.CodeFixRequest) => {
[protocol.CommandTypes.GetCodeFixesFull]: (request: protocol.CodeFixRequest) => {
return this.requiredResponse(this.getCodeFixes(request.arguments, /*simplifiedResult*/ false));
},
[CommandNames.GetCombinedCodeFix]: (request: protocol.GetCombinedCodeFixRequest) => {
[protocol.CommandTypes.GetCombinedCodeFix]: (request: protocol.GetCombinedCodeFixRequest) => {
return this.requiredResponse(this.getCombinedCodeFix(request.arguments, /*simplifiedResult*/ true));
},
[CommandNames.GetCombinedCodeFixFull]: (request: protocol.GetCombinedCodeFixRequest) => {
[protocol.CommandTypes.GetCombinedCodeFixFull]: (request: protocol.GetCombinedCodeFixRequest) => {
return this.requiredResponse(this.getCombinedCodeFix(request.arguments, /*simplifiedResult*/ false));
},
[CommandNames.ApplyCodeActionCommand]: (request: protocol.ApplyCodeActionCommandRequest) => {
[protocol.CommandTypes.ApplyCodeActionCommand]: (request: protocol.ApplyCodeActionCommandRequest) => {
return this.requiredResponse(this.applyCodeActionCommand(request.arguments));
},
[CommandNames.GetSupportedCodeFixes]: (request: protocol.GetSupportedCodeFixesRequest) => {
[protocol.CommandTypes.GetSupportedCodeFixes]: (request: protocol.GetSupportedCodeFixesRequest) => {
return this.requiredResponse(this.getSupportedCodeFixes(request.arguments));
},
[CommandNames.GetApplicableRefactors]: (request: protocol.GetApplicableRefactorsRequest) => {
[protocol.CommandTypes.GetApplicableRefactors]: (request: protocol.GetApplicableRefactorsRequest) => {
return this.requiredResponse(this.getApplicableRefactors(request.arguments));
},
[CommandNames.GetEditsForRefactor]: (request: protocol.GetEditsForRefactorRequest) => {
[protocol.CommandTypes.GetEditsForRefactor]: (request: protocol.GetEditsForRefactorRequest) => {
return this.requiredResponse(this.getEditsForRefactor(request.arguments, /*simplifiedResult*/ true));
},
[CommandNames.GetEditsForRefactorFull]: (request: protocol.GetEditsForRefactorRequest) => {
[protocol.CommandTypes.GetEditsForRefactorFull]: (request: protocol.GetEditsForRefactorRequest) => {
return this.requiredResponse(this.getEditsForRefactor(request.arguments, /*simplifiedResult*/ false));
},
[CommandNames.OrganizeImports]: (request: protocol.OrganizeImportsRequest) => {
[protocol.CommandTypes.OrganizeImports]: (request: protocol.OrganizeImportsRequest) => {
return this.requiredResponse(this.organizeImports(request.arguments, /*simplifiedResult*/ true));
},
[CommandNames.OrganizeImportsFull]: (request: protocol.OrganizeImportsRequest) => {
[protocol.CommandTypes.OrganizeImportsFull]: (request: protocol.OrganizeImportsRequest) => {
return this.requiredResponse(this.organizeImports(request.arguments, /*simplifiedResult*/ false));
},
[CommandNames.GetEditsForFileRename]: (request: protocol.GetEditsForFileRenameRequest) => {
[protocol.CommandTypes.GetEditsForFileRename]: (request: protocol.GetEditsForFileRenameRequest) => {
return this.requiredResponse(this.getEditsForFileRename(request.arguments, /*simplifiedResult*/ true));
},
[CommandNames.GetEditsForFileRenameFull]: (request: protocol.GetEditsForFileRenameRequest) => {
[protocol.CommandTypes.GetEditsForFileRenameFull]: (request: protocol.GetEditsForFileRenameRequest) => {
return this.requiredResponse(this.getEditsForFileRename(request.arguments, /*simplifiedResult*/ false));
},
[CommandNames.ConfigurePlugin]: (request: protocol.ConfigurePluginRequest) => {
[protocol.CommandTypes.ConfigurePlugin]: (request: protocol.ConfigurePluginRequest) => {
this.configurePlugin(request.arguments);
this.doOutput(/*info*/ undefined, CommandNames.ConfigurePlugin, request.seq, /*success*/ true);
this.doOutput(/*info*/ undefined, protocol.CommandTypes.ConfigurePlugin, request.seq, /*success*/ true);
return this.notRequired();
},
[CommandNames.SelectionRange]: (request: protocol.SelectionRangeRequest) => {
[protocol.CommandTypes.SelectionRange]: (request: protocol.SelectionRangeRequest) => {
return this.requiredResponse(this.getSmartSelectionRange(request.arguments, /*simplifiedResult*/ true));
},
[CommandNames.SelectionRangeFull]: (request: protocol.SelectionRangeRequest) => {
[protocol.CommandTypes.SelectionRangeFull]: (request: protocol.SelectionRangeRequest) => {
return this.requiredResponse(this.getSmartSelectionRange(request.arguments, /*simplifiedResult*/ false));
},
[CommandNames.PrepareCallHierarchy]: (request: protocol.PrepareCallHierarchyRequest) => {
[protocol.CommandTypes.PrepareCallHierarchy]: (request: protocol.PrepareCallHierarchyRequest) => {
return this.requiredResponse(this.prepareCallHierarchy(request.arguments));
},
[CommandNames.ProvideCallHierarchyIncomingCalls]: (request: protocol.ProvideCallHierarchyIncomingCallsRequest) => {
[protocol.CommandTypes.ProvideCallHierarchyIncomingCalls]: (request: protocol.ProvideCallHierarchyIncomingCallsRequest) => {
return this.requiredResponse(this.provideCallHierarchyIncomingCalls(request.arguments));
},
[CommandNames.ProvideCallHierarchyOutgoingCalls]: (request: protocol.ProvideCallHierarchyOutgoingCallsRequest) => {
[protocol.CommandTypes.ProvideCallHierarchyOutgoingCalls]: (request: protocol.ProvideCallHierarchyOutgoingCallsRequest) => {
return this.requiredResponse(this.provideCallHierarchyOutgoingCalls(request.arguments));
},
[CommandNames.ToggleLineComment]: (request: protocol.ToggleLineCommentRequest) => {
[protocol.CommandTypes.ToggleLineComment]: (request: protocol.ToggleLineCommentRequest) => {
return this.requiredResponse(this.toggleLineComment(request.arguments, /*simplifiedResult*/ true));
},
[CommandNames.ToggleLineCommentFull]: (request: protocol.ToggleLineCommentRequest) => {
[protocol.CommandTypes.ToggleLineCommentFull]: (request: protocol.ToggleLineCommentRequest) => {
return this.requiredResponse(this.toggleLineComment(request.arguments, /*simplifiedResult*/ false));
},
[CommandNames.ToggleMultilineComment]: (request: protocol.ToggleMultilineCommentRequest) => {
[protocol.CommandTypes.ToggleMultilineComment]: (request: protocol.ToggleMultilineCommentRequest) => {
return this.requiredResponse(this.toggleMultilineComment(request.arguments, /*simplifiedResult*/ true));
},
[CommandNames.ToggleMultilineCommentFull]: (request: protocol.ToggleMultilineCommentRequest) => {
[protocol.CommandTypes.ToggleMultilineCommentFull]: (request: protocol.ToggleMultilineCommentRequest) => {
return this.requiredResponse(this.toggleMultilineComment(request.arguments, /*simplifiedResult*/ false));
},
[CommandNames.CommentSelection]: (request: protocol.CommentSelectionRequest) => {
[protocol.CommandTypes.CommentSelection]: (request: protocol.CommentSelectionRequest) => {
return this.requiredResponse(this.commentSelection(request.arguments, /*simplifiedResult*/ true));
},
[CommandNames.CommentSelectionFull]: (request: protocol.CommentSelectionRequest) => {
[protocol.CommandTypes.CommentSelectionFull]: (request: protocol.CommentSelectionRequest) => {
return this.requiredResponse(this.commentSelection(request.arguments, /*simplifiedResult*/ false));
},
[CommandNames.UncommentSelection]: (request: protocol.UncommentSelectionRequest) => {
[protocol.CommandTypes.UncommentSelection]: (request: protocol.UncommentSelectionRequest) => {
return this.requiredResponse(this.uncommentSelection(request.arguments, /*simplifiedResult*/ true));
},
[CommandNames.UncommentSelectionFull]: (request: protocol.UncommentSelectionRequest) => {
[protocol.CommandTypes.UncommentSelectionFull]: (request: protocol.UncommentSelectionRequest) => {
return this.requiredResponse(this.uncommentSelection(request.arguments, /*simplifiedResult*/ false));
},
[CommandNames.ProvideInlayHints]: (request: protocol.InlayHintsRequest) => {
[protocol.CommandTypes.ProvideInlayHints]: (request: protocol.InlayHintsRequest) => {
return this.requiredResponse(this.provideInlayHints(request.arguments));
}
}));
@@ -3535,7 +3537,7 @@ export class Session<TMessage = string> implements EventSender {
}
else {
this.logger.msg(`Unrecognized JSON command:${stringifyIndented(request)}`, Msg.Err);
this.doOutput(/*info*/ undefined, CommandNames.Unknown, request.seq, /*success*/ false, `Unrecognized JSON command: ${request.command}`);
this.doOutput(/*info*/ undefined, protocol.CommandTypes.Unknown, request.seq, /*success*/ false, `Unrecognized JSON command: ${request.command}`);
return { responseRequired: false };
}
}
@@ -3604,7 +3606,7 @@ export class Session<TMessage = string> implements EventSender {
this.doOutput(
/*info*/ undefined,
request ? request.command : CommandNames.Unknown,
request ? request.command : protocol.CommandTypes.Unknown,
request ? request.seq : 0,
/*success*/ false,
"Error processing request. " + (err as StackTraceError).message + "\n" + (err as StackTraceError).stack);
@@ -67,11 +67,11 @@ describe("unittests:: tsserver:: compileOnSave:: affected list", () => {
// Send an initial compileOnSave request
session.executeCommandSeq<ts.server.protocol.CompileOnSaveAffectedFileListRequest>({
command: ts.server.CommandNames.CompileOnSaveAffectedFileList,
command: ts.server.protocol.CommandTypes.CompileOnSaveAffectedFileList,
arguments: { file: moduleFile1.path, projectFileName: configFile.path }
});
session.executeCommandSeq<ts.server.protocol.ChangeRequest>({
command: ts.server.CommandNames.Change,
command: ts.server.protocol.CommandTypes.Change,
arguments: {
file: moduleFile1.path,
line: 1,
@@ -82,13 +82,13 @@ describe("unittests:: tsserver:: compileOnSave:: affected list", () => {
}
});
session.executeCommandSeq<ts.server.protocol.CompileOnSaveAffectedFileListRequest>({
command: ts.server.CommandNames.CompileOnSaveAffectedFileList,
command: ts.server.protocol.CommandTypes.CompileOnSaveAffectedFileList,
arguments: { file: moduleFile1.path, projectFileName: configFile.path }
});
// Change the content of file1 to `export var T: number;export function Foo() { console.log('hi'); };`
session.executeCommandSeq<ts.server.protocol.ChangeRequest>({
command: ts.server.CommandNames.Change,
command: ts.server.protocol.CommandTypes.Change,
arguments: {
file: moduleFile1.path,
line: 1,
@@ -99,7 +99,7 @@ describe("unittests:: tsserver:: compileOnSave:: affected list", () => {
}
});
session.executeCommandSeq<ts.server.protocol.CompileOnSaveAffectedFileListRequest>({
command: ts.server.CommandNames.CompileOnSaveAffectedFileList,
command: ts.server.protocol.CommandTypes.CompileOnSaveAffectedFileList,
arguments: { file: moduleFile1.path, projectFileName: configFile.path }
});
baselineTsserverLogs("compileOnSave", "configProjects module shape changed", session);
@@ -115,13 +115,13 @@ describe("unittests:: tsserver:: compileOnSave:: affected list", () => {
// Send an initial compileOnSave request
session.executeCommandSeq<ts.server.protocol.CompileOnSaveAffectedFileListRequest>({
command: ts.server.CommandNames.CompileOnSaveAffectedFileList,
command: ts.server.protocol.CommandTypes.CompileOnSaveAffectedFileList,
arguments: { file: moduleFile1.path, projectFileName: configFile.path }
});
// Change file2 content to `let y = Foo();`
session.executeCommandSeq<ts.server.protocol.ChangeRequest>({
command: ts.server.CommandNames.Change,
command: ts.server.protocol.CommandTypes.Change,
arguments: {
file: file1Consumer1.path,
line: 1,
@@ -132,7 +132,7 @@ describe("unittests:: tsserver:: compileOnSave:: affected list", () => {
}
});
session.executeCommandSeq<ts.server.protocol.ChangeRequest>({
command: ts.server.CommandNames.Change,
command: ts.server.protocol.CommandTypes.Change,
arguments: {
file: moduleFile1.path,
line: 1,
@@ -143,13 +143,13 @@ describe("unittests:: tsserver:: compileOnSave:: affected list", () => {
}
});
session.executeCommandSeq<ts.server.protocol.CompileOnSaveAffectedFileListRequest>({
command: ts.server.CommandNames.CompileOnSaveAffectedFileList,
command: ts.server.protocol.CommandTypes.CompileOnSaveAffectedFileList,
arguments: { file: moduleFile1.path, projectFileName: configFile.path }
});
// Add the import statements back to file2
session.executeCommandSeq<ts.server.protocol.ChangeRequest>({
command: ts.server.CommandNames.Change,
command: ts.server.protocol.CommandTypes.Change,
arguments: {
file: file1Consumer1.path,
line: 1,
@@ -162,7 +162,7 @@ describe("unittests:: tsserver:: compileOnSave:: affected list", () => {
// Change the content of file1 to `export var T2: string;export var T: number;export function Foo() { };`
session.executeCommandSeq<ts.server.protocol.ChangeRequest>({
command: ts.server.CommandNames.Change,
command: ts.server.protocol.CommandTypes.Change,
arguments: {
file: moduleFile1.path,
line: 1,
@@ -173,7 +173,7 @@ describe("unittests:: tsserver:: compileOnSave:: affected list", () => {
}
});
session.executeCommandSeq<ts.server.protocol.CompileOnSaveAffectedFileListRequest>({
command: ts.server.CommandNames.CompileOnSaveAffectedFileList,
command: ts.server.protocol.CommandTypes.CompileOnSaveAffectedFileList,
arguments: { file: moduleFile1.path, projectFileName: configFile.path }
});
baselineTsserverLogs("compileOnSave", "configProjects uptodate with reference map changes", session);
@@ -189,14 +189,14 @@ describe("unittests:: tsserver:: compileOnSave:: affected list", () => {
// Send an initial compileOnSave request
session.executeCommandSeq<ts.server.protocol.CompileOnSaveAffectedFileListRequest>({
command: ts.server.CommandNames.CompileOnSaveAffectedFileList,
command: ts.server.protocol.CommandTypes.CompileOnSaveAffectedFileList,
arguments: { file: moduleFile1.path, projectFileName: configFile.path }
});
host.writeFile(file1Consumer1.path, `let y = 10;`);
session.executeCommandSeq<ts.server.protocol.ChangeRequest>({
command: ts.server.CommandNames.Change,
command: ts.server.protocol.CommandTypes.Change,
arguments: {
file: moduleFile1.path,
line: 1,
@@ -207,7 +207,7 @@ describe("unittests:: tsserver:: compileOnSave:: affected list", () => {
}
});
session.executeCommandSeq<ts.server.protocol.CompileOnSaveAffectedFileListRequest>({
command: ts.server.CommandNames.CompileOnSaveAffectedFileList,
command: ts.server.protocol.CommandTypes.CompileOnSaveAffectedFileList,
arguments: { file: moduleFile1.path, projectFileName: configFile.path }
});
baselineTsserverLogs("compileOnSave", "configProjects uptodate with changes in non open files", session);
@@ -221,12 +221,12 @@ describe("unittests:: tsserver:: compileOnSave:: affected list", () => {
openFilesForSession([moduleFile1], session);
session.executeCommandSeq<ts.server.protocol.CompileOnSaveAffectedFileListRequest>({
command: ts.server.CommandNames.CompileOnSaveAffectedFileList,
command: ts.server.protocol.CommandTypes.CompileOnSaveAffectedFileList,
arguments: { file: moduleFile1.path, projectFileName: configFile.path }
});
session.executeCommandSeq<ts.server.protocol.ChangeRequest>({
command: ts.server.CommandNames.Change,
command: ts.server.protocol.CommandTypes.Change,
arguments: {
file: moduleFile1.path,
line: 1,
@@ -239,7 +239,7 @@ describe("unittests:: tsserver:: compileOnSave:: affected list", () => {
// Delete file1Consumer2
host.deleteFile(file1Consumer2.path);
session.executeCommandSeq<ts.server.protocol.CompileOnSaveAffectedFileListRequest>({
command: ts.server.CommandNames.CompileOnSaveAffectedFileList,
command: ts.server.protocol.CommandTypes.CompileOnSaveAffectedFileList,
arguments: { file: moduleFile1.path, projectFileName: configFile.path }
});
baselineTsserverLogs("compileOnSave", "configProjects uptodate with deleted files", session);
@@ -253,7 +253,7 @@ describe("unittests:: tsserver:: compileOnSave:: affected list", () => {
openFilesForSession([moduleFile1], session);
session.executeCommandSeq<ts.server.protocol.CompileOnSaveAffectedFileListRequest>({
command: ts.server.CommandNames.CompileOnSaveAffectedFileList,
command: ts.server.protocol.CommandTypes.CompileOnSaveAffectedFileList,
arguments: { file: moduleFile1.path, projectFileName: configFile.path }
});
@@ -264,7 +264,7 @@ describe("unittests:: tsserver:: compileOnSave:: affected list", () => {
host.writeFile(file1Consumer3.path, file1Consumer3.content);
host.runQueuedTimeoutCallbacks();
session.executeCommandSeq<ts.server.protocol.ChangeRequest>({
command: ts.server.CommandNames.Change,
command: ts.server.protocol.CommandTypes.Change,
arguments: {
file: moduleFile1.path,
line: 1,
@@ -275,7 +275,7 @@ describe("unittests:: tsserver:: compileOnSave:: affected list", () => {
}
});
session.executeCommandSeq<ts.server.protocol.CompileOnSaveAffectedFileListRequest>({
command: ts.server.CommandNames.CompileOnSaveAffectedFileList,
command: ts.server.protocol.CommandTypes.CompileOnSaveAffectedFileList,
arguments: { file: moduleFile1.path, projectFileName: configFile.path }
});
baselineTsserverLogs("compileOnSave", "configProjects uptodate with new files", session);
@@ -306,13 +306,13 @@ describe("unittests:: tsserver:: compileOnSave:: affected list", () => {
openFilesForSession([moduleFile1, file1Consumer1], session);
session.executeCommandSeq<ts.server.protocol.CompileOnSaveAffectedFileListRequest>({
command: ts.server.CommandNames.CompileOnSaveAffectedFileList,
command: ts.server.protocol.CommandTypes.CompileOnSaveAffectedFileList,
arguments: { file: moduleFile1.path, projectFileName: configFile.path }
});
// change file1 shape now, and verify both files are affected
session.executeCommandSeq<ts.server.protocol.ChangeRequest>({
command: ts.server.CommandNames.Change,
command: ts.server.protocol.CommandTypes.Change,
arguments: {
file: moduleFile1.path,
line: 1,
@@ -323,13 +323,13 @@ describe("unittests:: tsserver:: compileOnSave:: affected list", () => {
}
});
session.executeCommandSeq<ts.server.protocol.CompileOnSaveAffectedFileListRequest>({
command: ts.server.CommandNames.CompileOnSaveAffectedFileList,
command: ts.server.protocol.CommandTypes.CompileOnSaveAffectedFileList,
arguments: { file: moduleFile1.path, projectFileName: configFile.path }
});
// change file1 internal, and verify only file1 is affected
session.executeCommandSeq<ts.server.protocol.ChangeRequest>({
command: ts.server.CommandNames.Change,
command: ts.server.protocol.CommandTypes.Change,
arguments: {
file: moduleFile1.path,
line: 1,
@@ -340,7 +340,7 @@ describe("unittests:: tsserver:: compileOnSave:: affected list", () => {
}
});
session.executeCommandSeq<ts.server.protocol.CompileOnSaveAffectedFileListRequest>({
command: ts.server.CommandNames.CompileOnSaveAffectedFileList,
command: ts.server.protocol.CommandTypes.CompileOnSaveAffectedFileList,
arguments: { file: moduleFile1.path, projectFileName: configFile.path }
});
baselineTsserverLogs("compileOnSave", "configProjects detect changes in non-root files", session);
@@ -356,7 +356,7 @@ describe("unittests:: tsserver:: compileOnSave:: affected list", () => {
// check after file1 shape changes
session.executeCommandSeq<ts.server.protocol.ChangeRequest>({
command: ts.server.CommandNames.Change,
command: ts.server.protocol.CommandTypes.Change,
arguments: {
file: globalFile3.path,
line: 1,
@@ -367,7 +367,7 @@ describe("unittests:: tsserver:: compileOnSave:: affected list", () => {
}
});
session.executeCommandSeq<ts.server.protocol.CompileOnSaveAffectedFileListRequest>({
command: ts.server.CommandNames.CompileOnSaveAffectedFileList,
command: ts.server.protocol.CommandTypes.CompileOnSaveAffectedFileList,
arguments: { file: globalFile3.path }
});
baselineTsserverLogs("compileOnSave", "configProjects global file shape changed", session);
@@ -385,7 +385,7 @@ describe("unittests:: tsserver:: compileOnSave:: affected list", () => {
const session = createSession(host, { typingsInstaller, logger: createLoggerWithInMemoryLogs(host) });
openFilesForSession([moduleFile1], session);
session.executeCommandSeq<ts.server.protocol.CompileOnSaveAffectedFileListRequest>({
command: ts.server.CommandNames.CompileOnSaveAffectedFileList,
command: ts.server.protocol.CommandTypes.CompileOnSaveAffectedFileList,
arguments: { file: moduleFile1.path, projectFileName: configFile.path }
});
baselineTsserverLogs("compileOnSave", "configProjects compileOnSave disabled", session);
@@ -408,7 +408,7 @@ describe("unittests:: tsserver:: compileOnSave:: affected list", () => {
const session = createSession(host, { typingsInstaller, logger: createLoggerWithInMemoryLogs(host) });
openFilesForSession([moduleFile1], session);
session.executeCommandSeq<ts.server.protocol.CompileOnSaveAffectedFileListRequest>({
command: ts.server.CommandNames.CompileOnSaveAffectedFileList,
command: ts.server.protocol.CommandTypes.CompileOnSaveAffectedFileList,
arguments: { file: moduleFile1.path, projectFileName: configFile.path }
});
baselineTsserverLogs("compileOnSave", "configProjects noEmit", session);
@@ -436,7 +436,7 @@ describe("unittests:: tsserver:: compileOnSave:: affected list", () => {
openFilesForSession([moduleFile1, file1Consumer1], session);
session.executeCommandSeq<ts.server.protocol.CompileOnSaveAffectedFileListRequest>({
command: ts.server.CommandNames.CompileOnSaveAffectedFileList,
command: ts.server.protocol.CommandTypes.CompileOnSaveAffectedFileList,
arguments: { file: moduleFile1.path, projectFileName: configFile.path }
});
baselineTsserverLogs("compileOnSave", "configProjects compileOnSave in base tsconfig", session);
@@ -460,7 +460,7 @@ describe("unittests:: tsserver:: compileOnSave:: affected list", () => {
openFilesForSession([moduleFile1], session);
session.executeCommandSeq<ts.server.protocol.ChangeRequest>({
command: ts.server.CommandNames.Change,
command: ts.server.protocol.CommandTypes.Change,
arguments: {
file: moduleFile1.path,
line: 1,
@@ -471,7 +471,7 @@ describe("unittests:: tsserver:: compileOnSave:: affected list", () => {
}
});
session.executeCommandSeq<ts.server.protocol.CompileOnSaveAffectedFileListRequest>({
command: ts.server.CommandNames.CompileOnSaveAffectedFileList,
command: ts.server.protocol.CommandTypes.CompileOnSaveAffectedFileList,
arguments: { file: moduleFile1.path, projectFileName: configFile.path }
});
baselineTsserverLogs("compileOnSave", "configProjects isolatedModules", session);
@@ -496,7 +496,7 @@ describe("unittests:: tsserver:: compileOnSave:: affected list", () => {
openFilesForSession([moduleFile1], session);
session.executeCommandSeq<ts.server.protocol.ChangeRequest>({
command: ts.server.CommandNames.Change,
command: ts.server.protocol.CommandTypes.Change,
arguments: {
file: moduleFile1.path,
line: 1,
@@ -507,7 +507,7 @@ describe("unittests:: tsserver:: compileOnSave:: affected list", () => {
}
});
session.executeCommandSeq<ts.server.protocol.CompileOnSaveAffectedFileListRequest>({
command: ts.server.CommandNames.CompileOnSaveAffectedFileList,
command: ts.server.protocol.CommandTypes.CompileOnSaveAffectedFileList,
arguments: { file: moduleFile1.path, projectFileName: configFile.path }
});
baselineTsserverLogs("compileOnSave", "configProjects outFile", session);
@@ -525,12 +525,12 @@ describe("unittests:: tsserver:: compileOnSave:: affected list", () => {
openFilesForSession([moduleFile1, file1Consumer1], session);
session.executeCommandSeq<ts.server.protocol.CompileOnSaveAffectedFileListRequest>({
command: ts.server.CommandNames.CompileOnSaveAffectedFileList,
command: ts.server.protocol.CommandTypes.CompileOnSaveAffectedFileList,
arguments: { file: moduleFile1.path, projectFileName: configFile.path }
});
session.executeCommandSeq<ts.server.protocol.ChangeRequest>({
command: ts.server.CommandNames.Change,
command: ts.server.protocol.CommandTypes.Change,
arguments: {
file: moduleFile1.path,
line: 1,
@@ -541,7 +541,7 @@ describe("unittests:: tsserver:: compileOnSave:: affected list", () => {
}
});
session.executeCommandSeq<ts.server.protocol.ChangeRequest>({
command: ts.server.CommandNames.Change,
command: ts.server.protocol.CommandTypes.Change,
arguments: {
file: file1Consumer1.path,
line: 2,
@@ -552,7 +552,7 @@ describe("unittests:: tsserver:: compileOnSave:: affected list", () => {
}
});
session.executeCommandSeq<ts.server.protocol.CompileOnSaveAffectedFileListRequest>({
command: ts.server.CommandNames.CompileOnSaveAffectedFileList,
command: ts.server.protocol.CommandTypes.CompileOnSaveAffectedFileList,
arguments: { file: moduleFile1.path, projectFileName: configFile.path }
});
baselineTsserverLogs("compileOnSave", "configProjects cascaded affected file list", session);
@@ -578,7 +578,7 @@ describe("unittests:: tsserver:: compileOnSave:: affected list", () => {
openFilesForSession([file1, file2], session);
session.executeCommandSeq<ts.server.protocol.CompileOnSaveAffectedFileListRequest>({
command: ts.server.CommandNames.CompileOnSaveAffectedFileList,
command: ts.server.protocol.CommandTypes.CompileOnSaveAffectedFileList,
arguments: { file: file1.path }
});
baselineTsserverLogs("compileOnSave", "configProjects circular references", session);
@@ -596,7 +596,7 @@ describe("unittests:: tsserver:: compileOnSave:: affected list", () => {
openFilesForSession([file1, file2, file3], session);
session.executeCommandSeq<ts.server.protocol.CompileOnSaveAffectedFileListRequest>({
command: ts.server.CommandNames.CompileOnSaveAffectedFileList,
command: ts.server.protocol.CommandTypes.CompileOnSaveAffectedFileList,
arguments: { file: file1.path }
});
baselineTsserverLogs("compileOnSave", "configProjects all projects without projectPath", session);
@@ -617,11 +617,11 @@ describe("unittests:: tsserver:: compileOnSave:: affected list", () => {
host.deleteFile(moduleFile1.path);
session.executeCommandSeq<ts.server.protocol.CompileOnSaveAffectedFileListRequest>({
command: ts.server.CommandNames.CompileOnSaveAffectedFileList,
command: ts.server.protocol.CommandTypes.CompileOnSaveAffectedFileList,
arguments: { file: referenceFile1.path }
});
session.executeCommandSeq<ts.server.protocol.CompileOnSaveAffectedFileListRequest>({
command: ts.server.CommandNames.CompileOnSaveAffectedFileList,
command: ts.server.protocol.CommandTypes.CompileOnSaveAffectedFileList,
arguments: { file: moduleFile1.path }
});
baselineTsserverLogs("compileOnSave", "configProjects removed code", session);
@@ -640,7 +640,7 @@ describe("unittests:: tsserver:: compileOnSave:: affected list", () => {
openFilesForSession([referenceFile1], session);
session.executeCommandSeq<ts.server.protocol.CompileOnSaveAffectedFileListRequest>({
command: ts.server.CommandNames.CompileOnSaveAffectedFileList,
command: ts.server.protocol.CommandTypes.CompileOnSaveAffectedFileList,
arguments: { file: referenceFile1.path }
});
baselineTsserverLogs("compileOnSave", "configProjects non existing code", session);
@@ -796,7 +796,7 @@ describe("unittests:: tsserver:: compileOnSave:: EmitFile test", () => {
openFilesForSession([file1, file2], session);
session.executeCommandSeq<ts.server.protocol.CompileOnSaveEmitFileRequest>({
command: ts.server.CommandNames.CompileOnSaveEmitFile,
command: ts.server.protocol.CommandTypes.CompileOnSaveEmitFile,
arguments: { file: file1.path, projectFileName: configFile.path }
});
@@ -834,7 +834,7 @@ describe("unittests:: tsserver:: compileOnSave:: EmitFile test", () => {
});
session.executeCommandSeq<ts.server.protocol.CompileOnSaveEmitFileRequest>({
command: ts.server.CommandNames.CompileOnSaveEmitFile,
command: ts.server.protocol.CommandTypes.CompileOnSaveEmitFile,
arguments: { file: file1.path }
});
@@ -863,7 +863,7 @@ describe("unittests:: tsserver:: compileOnSave:: EmitFile test", () => {
}
});
session.executeCommandSeq<ts.server.protocol.CompileOnSaveEmitFileRequest>({
command: ts.server.CommandNames.CompileOnSaveEmitFile,
command: ts.server.protocol.CommandTypes.CompileOnSaveEmitFile,
arguments: { file: file1.path }
});
baselineTsserverLogs("compileOnSave", "use projectRoot as current directory", session);
@@ -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);
@@ -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);
@@ -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);
@@ -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);
@@ -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
}
@@ -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,
@@ -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",
@@ -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,
+2 -2
View File
@@ -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
@@ -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 }
});
}
@@ -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,
@@ -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,
@@ -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,
@@ -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,
@@ -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,
@@ -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,
+5 -5
View File
@@ -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);
@@ -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 }
});
@@ -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);
@@ -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);
@@ -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);
@@ -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 }
};
@@ -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() }
};
@@ -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,
@@ -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] });
@@ -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]
@@ -624,7 +624,7 @@ 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[];
@@ -632,13 +632,13 @@ describe("unittests:: tsserver:: Project Errors dont include overwrite emit erro
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[];
@@ -665,7 +665,7 @@ 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[];
@@ -673,7 +673,7 @@ describe("unittests:: tsserver:: Project Errors dont include overwrite emit erro
session.executeCommand({
type: "request",
command: ts.server.CommandNames.OpenExternalProject,
command: ts.server.protocol.CommandTypes.OpenExternalProject,
seq: 3,
arguments: {
projectFileName,
@@ -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[];
@@ -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[];
@@ -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[];
@@ -42,14 +42,14 @@ describe("unittests:: tsserver:: Projects", () => {
// Two errors: CommonFile2 not found and cannot find name y
session.executeCommandSeq<ts.server.protocol.SemanticDiagnosticsSyncRequest>({
command: ts.server.CommandNames.SemanticDiagnosticsSync,
command: ts.server.protocol.CommandTypes.SemanticDiagnosticsSync,
arguments: { file: file1.path }
});
host.writeFile(commonFile2.path, commonFile2.content);
host.runQueuedTimeoutCallbacks();
session.executeCommandSeq<ts.server.protocol.SemanticDiagnosticsSyncRequest>({
command: ts.server.CommandNames.SemanticDiagnosticsSync,
command: ts.server.protocol.CommandTypes.SemanticDiagnosticsSync,
arguments: { file: file1.path }
});
baselineTsserverLogs("projects", "handles the missing files added with tripleslash ref", session);
@@ -710,7 +710,7 @@ describe("unittests:: tsserver:: Projects", () => {
const extraFileExtensions = [{ extension: ".html", scriptKind: ts.ScriptKind.JS, isMixedContent: true }];
// The configured project should now be updated to include html file
session.executeCommandSeq<ts.server.protocol.ConfigureRequest>({
command: ts.server.CommandNames.Configure,
command: ts.server.protocol.CommandTypes.Configure,
arguments: { extraFileExtensions }
});
@@ -819,7 +819,7 @@ describe("unittests:: tsserver:: Projects", () => {
logger.host = host;
const session = createSession(host, { logger });
session.executeCommandSeq<ts.server.protocol.ConfigureRequest>({
command: ts.server.CommandNames.Configure,
command: ts.server.protocol.CommandTypes.Configure,
arguments: { extraFileExtensions }
});
openFilesForSession([file1], session);
@@ -1012,19 +1012,19 @@ describe("unittests:: tsserver:: Projects", () => {
const host = createServerHost([f1, libFile, config]);
const session = createSession(host, { logger: createLoggerWithInMemoryLogs(host) });
session.executeCommandSeq({
command: ts.server.CommandNames.Open,
command: ts.server.protocol.CommandTypes.Open,
arguments: {
file: f1.path
}
} as ts.server.protocol.OpenRequest);
session.executeCommandSeq({
command: ts.server.CommandNames.Close,
command: ts.server.protocol.CommandTypes.Close,
arguments: {
file: f1.path
}
} as ts.server.protocol.CloseRequest);
session.executeCommandSeq({
command: ts.server.CommandNames.Geterr,
command: ts.server.protocol.CommandTypes.Geterr,
arguments: {
delay: 0,
files: [f1.path]
@@ -1191,7 +1191,7 @@ describe("unittests:: tsserver:: Projects", () => {
// Configure the deferred extension.
const extraFileExtensions = [{ extension: ".deferred", scriptKind: ts.ScriptKind.Deferred, isMixedContent: true }];
session.executeCommandSeq<ts.server.protocol.ConfigureRequest>({
command: ts.server.CommandNames.Configure,
command: ts.server.protocol.CommandTypes.Configure,
arguments: { extraFileExtensions }
});
@@ -105,7 +105,7 @@ describe("unittests:: tsserver:: resolutionCache:: tsserverProjectSystem add the
const session = createSession(host, { logger: createLoggerWithInMemoryLogs(host) });
openFilesForSession([file1], session);
session.executeCommandSeq<ts.server.protocol.SemanticDiagnosticsSyncRequest>({
command: ts.server.CommandNames.SemanticDiagnosticsSync,
command: ts.server.protocol.CommandTypes.SemanticDiagnosticsSync,
arguments: { file: file1.path }
});
@@ -114,13 +114,13 @@ describe("unittests:: tsserver:: resolutionCache:: tsserverProjectSystem add the
// Make a change to trigger the program rebuild
session.executeCommandSeq<ts.server.protocol.ChangeRequest>({
command: ts.server.CommandNames.Change,
command: ts.server.protocol.CommandTypes.Change,
arguments: { file: file1.path, line: 1, offset: 44, endLine: 1, endOffset: 44, insertString: "\n" }
});
// Recheck
session.executeCommandSeq<ts.server.protocol.SemanticDiagnosticsSyncRequest>({
command: ts.server.CommandNames.SemanticDiagnosticsSync,
command: ts.server.protocol.CommandTypes.SemanticDiagnosticsSync,
arguments: { file: file1.path }
});
baselineTsserverLogs("resolutionCache", "should remove the module not found error", session);
@@ -135,7 +135,7 @@ describe("unittests:: tsserver:: resolutionCache:: tsserverProjectSystem add the
const host = createServerHost([file1, libFile]);
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: file1.path,
fileContent: file1.content,
@@ -168,7 +168,7 @@ describe("unittests:: tsserver:: resolutionCache:: tsserverProjectSystem add the
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: file.path, fileContent: file.content },
});
@@ -187,12 +187,12 @@ describe("unittests:: tsserver:: resolutionCache:: tsserverProjectSystem add the
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: file.path, fileContent: file.content },
});
session.executeCommandSeq<ts.server.protocol.ConfigureRequest>({
command: ts.server.CommandNames.Configure,
command: ts.server.protocol.CommandTypes.Configure,
arguments: {
preferences: { disableSuggestions: true }
},
@@ -213,13 +213,13 @@ describe("unittests:: tsserver:: resolutionCache:: tsserverProjectSystem add the
const session = createSession(host, { canUseEvents: true, suppressDiagnosticEvents: true, logger: createLoggerWithInMemoryLogs(host) });
session.executeCommandSeq<ts.server.protocol.OpenRequest>({
command: ts.server.CommandNames.Open,
command: ts.server.protocol.CommandTypes.Open,
arguments: { file: file.path, fileContent: file.content },
});
host.checkTimeoutQueueLength(0);
session.executeCommandSeq<ts.server.protocol.GeterrRequest>({
command: ts.server.CommandNames.Geterr,
command: ts.server.protocol.CommandTypes.Geterr,
arguments: {
delay: 0,
files: [file.path],
@@ -228,7 +228,7 @@ describe("unittests:: tsserver:: resolutionCache:: tsserverProjectSystem add the
host.checkTimeoutQueueLength(0);
session.executeCommandSeq<ts.server.protocol.GeterrForProjectRequest>({
command: ts.server.CommandNames.Geterr,
command: ts.server.protocol.CommandTypes.GeterrForProject,
arguments: {
delay: 0,
file: file.path,
@@ -255,7 +255,7 @@ describe("unittests:: tsserver:: resolutionCache:: tsserverProjectSystem rename
openFilesForSession([file1], session);
session.executeCommandSeq<ts.server.protocol.SemanticDiagnosticsSyncRequest>({
command: ts.server.CommandNames.SemanticDiagnosticsSync,
command: ts.server.protocol.CommandTypes.SemanticDiagnosticsSync,
arguments: { file: file1.path }
});
@@ -263,7 +263,7 @@ describe("unittests:: tsserver:: resolutionCache:: tsserverProjectSystem rename
host.renameFile(moduleFile.path, moduleFileNewPath);
host.runQueuedTimeoutCallbacks();
session.executeCommandSeq<ts.server.protocol.SemanticDiagnosticsSyncRequest>({
command: ts.server.CommandNames.SemanticDiagnosticsSync,
command: ts.server.protocol.CommandTypes.SemanticDiagnosticsSync,
arguments: { file: file1.path }
});
@@ -272,13 +272,13 @@ describe("unittests:: tsserver:: resolutionCache:: tsserverProjectSystem rename
// Make a change to trigger the program rebuild
session.executeCommandSeq<ts.server.protocol.ChangeRequest>({
command: ts.server.CommandNames.Change,
command: ts.server.protocol.CommandTypes.Change,
arguments: { file: file1.path, line: 1, offset: 44, endLine: 1, endOffset: 44, insertString: "\n" }
});
host.runQueuedTimeoutCallbacks();
session.executeCommandSeq<ts.server.protocol.SemanticDiagnosticsSyncRequest>({
command: ts.server.CommandNames.SemanticDiagnosticsSync,
command: ts.server.protocol.CommandTypes.SemanticDiagnosticsSync,
arguments: { file: file1.path }
});
baselineTsserverLogs("resolutionCache", "renaming module should restore the states for inferred projects", session);
@@ -302,7 +302,7 @@ describe("unittests:: tsserver:: resolutionCache:: tsserverProjectSystem rename
openFilesForSession([file1], session);
session.executeCommandSeq<ts.server.protocol.SemanticDiagnosticsSyncRequest>({
command: ts.server.CommandNames.SemanticDiagnosticsSync,
command: ts.server.protocol.CommandTypes.SemanticDiagnosticsSync,
arguments: { file: file1.path }
});
@@ -310,14 +310,14 @@ describe("unittests:: tsserver:: resolutionCache:: tsserverProjectSystem rename
host.renameFile(moduleFile.path, moduleFileNewPath);
host.runQueuedTimeoutCallbacks();
session.executeCommandSeq<ts.server.protocol.SemanticDiagnosticsSyncRequest>({
command: ts.server.CommandNames.SemanticDiagnosticsSync,
command: ts.server.protocol.CommandTypes.SemanticDiagnosticsSync,
arguments: { file: file1.path }
});
host.renameFile(moduleFileNewPath, moduleFile.path);
host.runQueuedTimeoutCallbacks();
session.executeCommandSeq<ts.server.protocol.SemanticDiagnosticsSyncRequest>({
command: ts.server.CommandNames.SemanticDiagnosticsSync,
command: ts.server.protocol.CommandTypes.SemanticDiagnosticsSync,
arguments: { file: file1.path }
});
baselineTsserverLogs("resolutionCache", "renaming module should restore the states for configured projects", session);
+100 -99
View File
@@ -81,7 +81,7 @@ describe("unittests:: tsserver:: Session:: General functionality", () => {
describe("executeCommand", () => {
it("should throw when commands are executed with invalid arguments", () => {
const req: ts.server.protocol.FileRequest = {
command: ts.server.CommandNames.Open,
command: ts.server.protocol.CommandTypes.Open,
seq: 0,
type: "request",
arguments: {
@@ -101,7 +101,7 @@ describe("unittests:: tsserver:: Session:: General functionality", () => {
session.executeCommand(req);
const expected: ts.server.protocol.Response = {
command: ts.server.CommandNames.Unknown,
command: ts.server.protocol.CommandTypes.Unknown,
type: "response",
seq: 0,
message: "Unrecognized JSON command: foobar",
@@ -113,7 +113,7 @@ describe("unittests:: tsserver:: Session:: General functionality", () => {
});
it("should return a tuple containing the response and if a response is required on success", () => {
const req: ts.server.protocol.ConfigureRequest = {
command: ts.server.CommandNames.Configure,
command: ts.server.protocol.CommandTypes.Configure,
seq: 0,
type: "request",
arguments: {
@@ -128,7 +128,7 @@ describe("unittests:: tsserver:: Session:: General functionality", () => {
responseRequired: false
});
expect(lastSent).to.deep.equal({
command: ts.server.CommandNames.Configure,
command: ts.server.protocol.CommandTypes.Configure,
type: "response",
success: true,
request_seq: 0,
@@ -139,7 +139,7 @@ describe("unittests:: tsserver:: Session:: General functionality", () => {
});
it("should handle literal types in request", () => {
const configureRequest: ts.server.protocol.ConfigureRequest = {
command: ts.server.CommandNames.Configure,
command: ts.server.protocol.CommandTypes.Configure,
seq: 0,
type: "request",
arguments: {
@@ -154,7 +154,7 @@ describe("unittests:: tsserver:: Session:: General functionality", () => {
assert.equal(session.getProjectService().getFormatCodeOptions("" as ts.server.NormalizedPath).indentStyle, ts.IndentStyle.Block);
const setOptionsRequest: ts.server.protocol.SetCompilerOptionsForInferredProjectsRequest = {
command: ts.server.CommandNames.CompilerOptionsForInferredProjects,
command: ts.server.protocol.CommandTypes.CompilerOptionsForInferredProjects,
seq: 1,
type: "request",
arguments: {
@@ -182,7 +182,7 @@ describe("unittests:: tsserver:: Session:: General functionality", () => {
it("Status request gives ts.version", () => {
const req: ts.server.protocol.StatusRequest = {
command: ts.server.CommandNames.Status,
command: ts.server.protocol.CommandTypes.Status,
seq: 0,
type: "request"
};
@@ -195,96 +195,97 @@ describe("unittests:: tsserver:: Session:: General functionality", () => {
});
describe("onMessage", () => {
const allCommandNames: ts.server.CommandNames[] = [
ts.server.CommandNames.Brace,
ts.server.CommandNames.BraceFull,
ts.server.CommandNames.BraceCompletion,
ts.server.CommandNames.Change,
ts.server.CommandNames.Close,
ts.server.CommandNames.Completions,
ts.server.CommandNames.CompletionsFull,
ts.server.CommandNames.CompletionDetails,
ts.server.CommandNames.CompileOnSaveAffectedFileList,
ts.server.CommandNames.Configure,
ts.server.CommandNames.Definition,
ts.server.CommandNames.DefinitionFull,
ts.server.CommandNames.DefinitionAndBoundSpan,
ts.server.CommandNames.DefinitionAndBoundSpanFull,
ts.server.CommandNames.Implementation,
ts.server.CommandNames.ImplementationFull,
ts.server.CommandNames.Exit,
ts.server.CommandNames.FileReferences,
ts.server.CommandNames.FileReferencesFull,
ts.server.CommandNames.Format,
ts.server.CommandNames.Formatonkey,
ts.server.CommandNames.FormatFull,
ts.server.CommandNames.FormatonkeyFull,
ts.server.CommandNames.FormatRangeFull,
ts.server.CommandNames.Geterr,
ts.server.CommandNames.GeterrForProject,
ts.server.CommandNames.SemanticDiagnosticsSync,
ts.server.CommandNames.SyntacticDiagnosticsSync,
ts.server.CommandNames.SuggestionDiagnosticsSync,
ts.server.CommandNames.NavBar,
ts.server.CommandNames.NavBarFull,
ts.server.CommandNames.Navto,
ts.server.CommandNames.NavtoFull,
ts.server.CommandNames.NavTree,
ts.server.CommandNames.NavTreeFull,
ts.server.CommandNames.Occurrences,
ts.server.CommandNames.DocumentHighlights,
ts.server.CommandNames.DocumentHighlightsFull,
ts.server.CommandNames.JsxClosingTag,
ts.server.CommandNames.Open,
ts.server.CommandNames.Quickinfo,
ts.server.CommandNames.QuickinfoFull,
ts.server.CommandNames.References,
ts.server.CommandNames.ReferencesFull,
ts.server.CommandNames.Reload,
ts.server.CommandNames.Rename,
ts.server.CommandNames.RenameInfoFull,
ts.server.CommandNames.RenameLocationsFull,
ts.server.CommandNames.Saveto,
ts.server.CommandNames.SignatureHelp,
ts.server.CommandNames.SignatureHelpFull,
ts.server.CommandNames.Status,
ts.server.CommandNames.TypeDefinition,
ts.server.CommandNames.ProjectInfo,
ts.server.CommandNames.ReloadProjects,
ts.server.CommandNames.Unknown,
ts.server.CommandNames.OpenExternalProject,
ts.server.CommandNames.CloseExternalProject,
ts.server.CommandNames.SynchronizeProjectList,
ts.server.CommandNames.ApplyChangedToOpenFiles,
ts.server.CommandNames.EncodedSemanticClassificationsFull,
ts.server.CommandNames.Cleanup,
ts.server.CommandNames.OutliningSpans,
ts.server.CommandNames.TodoComments,
ts.server.CommandNames.Indentation,
ts.server.CommandNames.DocCommentTemplate,
ts.server.CommandNames.CompilerOptionsDiagnosticsFull,
ts.server.CommandNames.NameOrDottedNameSpan,
ts.server.CommandNames.BreakpointStatement,
ts.server.CommandNames.CompilerOptionsForInferredProjects,
ts.server.CommandNames.GetCodeFixes,
ts.server.CommandNames.GetCodeFixesFull,
ts.server.CommandNames.GetSupportedCodeFixes,
ts.server.CommandNames.GetApplicableRefactors,
ts.server.CommandNames.GetEditsForRefactor,
ts.server.CommandNames.GetEditsForRefactorFull,
ts.server.CommandNames.OrganizeImports,
ts.server.CommandNames.OrganizeImportsFull,
ts.server.CommandNames.GetEditsForFileRename,
ts.server.CommandNames.GetEditsForFileRenameFull,
ts.server.CommandNames.SelectionRange,
ts.server.CommandNames.PrepareCallHierarchy,
ts.server.CommandNames.ProvideCallHierarchyIncomingCalls,
ts.server.CommandNames.ProvideCallHierarchyOutgoingCalls,
ts.server.CommandNames.ToggleLineComment,
ts.server.CommandNames.ToggleMultilineComment,
ts.server.CommandNames.CommentSelection,
ts.server.CommandNames.UncommentSelection,
ts.server.CommandNames.ProvideInlayHints
const allCommandNames: ts.server.protocol.CommandTypes[] = [
ts.server.protocol.CommandTypes.Brace,
ts.server.protocol.CommandTypes.BraceFull,
ts.server.protocol.CommandTypes.BraceCompletion,
ts.server.protocol.CommandTypes.Change,
ts.server.protocol.CommandTypes.Close,
ts.server.protocol.CommandTypes.Completions,
ts.server.protocol.CommandTypes.CompletionsFull,
ts.server.protocol.CommandTypes.CompletionDetails,
ts.server.protocol.CommandTypes.CompileOnSaveAffectedFileList,
ts.server.protocol.CommandTypes.Configure,
ts.server.protocol.CommandTypes.Definition,
ts.server.protocol.CommandTypes.DefinitionFull,
ts.server.protocol.CommandTypes.DefinitionAndBoundSpan,
ts.server.protocol.CommandTypes.DefinitionAndBoundSpanFull,
ts.server.protocol.CommandTypes.Implementation,
ts.server.protocol.CommandTypes.ImplementationFull,
ts.server.protocol.CommandTypes.Exit,
ts.server.protocol.CommandTypes.FileReferences,
ts.server.protocol.CommandTypes.FileReferencesFull,
ts.server.protocol.CommandTypes.Format,
ts.server.protocol.CommandTypes.Formatonkey,
ts.server.protocol.CommandTypes.FormatFull,
ts.server.protocol.CommandTypes.FormatonkeyFull,
ts.server.protocol.CommandTypes.FormatRangeFull,
ts.server.protocol.CommandTypes.Geterr,
ts.server.protocol.CommandTypes.GeterrForProject,
ts.server.protocol.CommandTypes.SemanticDiagnosticsSync,
ts.server.protocol.CommandTypes.SyntacticDiagnosticsSync,
ts.server.protocol.CommandTypes.SuggestionDiagnosticsSync,
ts.server.protocol.CommandTypes.NavBar,
ts.server.protocol.CommandTypes.NavBarFull,
ts.server.protocol.CommandTypes.Navto,
ts.server.protocol.CommandTypes.NavtoFull,
ts.server.protocol.CommandTypes.NavTree,
ts.server.protocol.CommandTypes.NavTreeFull,
ts.server.protocol.CommandTypes.Occurrences,
ts.server.protocol.CommandTypes.DocumentHighlights,
ts.server.protocol.CommandTypes.DocumentHighlightsFull,
ts.server.protocol.CommandTypes.JsxClosingTag,
ts.server.protocol.CommandTypes.Open,
ts.server.protocol.CommandTypes.Quickinfo,
ts.server.protocol.CommandTypes.QuickinfoFull,
ts.server.protocol.CommandTypes.References,
ts.server.protocol.CommandTypes.ReferencesFull,
ts.server.protocol.CommandTypes.Reload,
ts.server.protocol.CommandTypes.Rename,
ts.server.protocol.CommandTypes.RenameInfoFull,
ts.server.protocol.CommandTypes.RenameLocationsFull,
ts.server.protocol.CommandTypes.Saveto,
ts.server.protocol.CommandTypes.SignatureHelp,
ts.server.protocol.CommandTypes.SignatureHelpFull,
ts.server.protocol.CommandTypes.Status,
ts.server.protocol.CommandTypes.TypeDefinition,
ts.server.protocol.CommandTypes.ProjectInfo,
ts.server.protocol.CommandTypes.ReloadProjects,
ts.server.protocol.CommandTypes.Unknown,
ts.server.protocol.CommandTypes.OpenExternalProject,
ts.server.protocol.CommandTypes.CloseExternalProject,
ts.server.protocol.CommandTypes.SynchronizeProjectList,
ts.server.protocol.CommandTypes.ApplyChangedToOpenFiles,
ts.server.protocol.CommandTypes.EncodedSemanticClassificationsFull,
ts.server.protocol.CommandTypes.Cleanup,
ts.server.protocol.CommandTypes.GetOutliningSpans,
ts.server.protocol.CommandTypes.GetOutliningSpansFull,
ts.server.protocol.CommandTypes.TodoComments,
ts.server.protocol.CommandTypes.Indentation,
ts.server.protocol.CommandTypes.DocCommentTemplate,
ts.server.protocol.CommandTypes.CompilerOptionsDiagnosticsFull,
ts.server.protocol.CommandTypes.NameOrDottedNameSpan,
ts.server.protocol.CommandTypes.BreakpointStatement,
ts.server.protocol.CommandTypes.CompilerOptionsForInferredProjects,
ts.server.protocol.CommandTypes.GetCodeFixes,
ts.server.protocol.CommandTypes.GetCodeFixesFull,
ts.server.protocol.CommandTypes.GetSupportedCodeFixes,
ts.server.protocol.CommandTypes.GetApplicableRefactors,
ts.server.protocol.CommandTypes.GetEditsForRefactor,
ts.server.protocol.CommandTypes.GetEditsForRefactorFull,
ts.server.protocol.CommandTypes.OrganizeImports,
ts.server.protocol.CommandTypes.OrganizeImportsFull,
ts.server.protocol.CommandTypes.GetEditsForFileRename,
ts.server.protocol.CommandTypes.GetEditsForFileRenameFull,
ts.server.protocol.CommandTypes.SelectionRange,
ts.server.protocol.CommandTypes.PrepareCallHierarchy,
ts.server.protocol.CommandTypes.ProvideCallHierarchyIncomingCalls,
ts.server.protocol.CommandTypes.ProvideCallHierarchyOutgoingCalls,
ts.server.protocol.CommandTypes.ToggleLineComment,
ts.server.protocol.CommandTypes.ToggleMultilineComment,
ts.server.protocol.CommandTypes.CommentSelection,
ts.server.protocol.CommandTypes.UncommentSelection,
ts.server.protocol.CommandTypes.ProvideInlayHints
];
it("should not throw when commands are executed with invalid arguments", () => {
@@ -322,7 +323,7 @@ describe("unittests:: tsserver:: Session:: General functionality", () => {
});
it("should output the response for a correctly handled message", () => {
const req: ts.server.protocol.ConfigureRequest = {
command: ts.server.CommandNames.Configure,
command: ts.server.protocol.CommandTypes.Configure,
seq: 0,
type: "request",
arguments: {
@@ -336,7 +337,7 @@ describe("unittests:: tsserver:: Session:: General functionality", () => {
session.onMessage(JSON.stringify(req));
expect(lastSent).to.deep.equal({
command: ts.server.CommandNames.Configure,
command: ts.server.protocol.CommandTypes.Configure,
type: "response",
success: true,
request_seq: 0,
@@ -31,23 +31,23 @@ describe("unittests:: tsserver:: with skipLibCheck", () => {
openFilesForSession([file1, file2], session);
session.executeCommandSeq<ts.server.protocol.SemanticDiagnosticsSyncRequest>({
command: ts.server.CommandNames.SemanticDiagnosticsSync,
command: ts.server.protocol.CommandTypes.SemanticDiagnosticsSync,
arguments: { file: file2.path }
});
session.executeCommandSeq<ts.server.protocol.CloseRequest>({
command: ts.server.CommandNames.Close,
command: ts.server.protocol.CommandTypes.Close,
arguments: { file: file1.path }
});
session.executeCommandSeq<ts.server.protocol.SemanticDiagnosticsSyncRequest>({
command: ts.server.CommandNames.SemanticDiagnosticsSync,
command: ts.server.protocol.CommandTypes.SemanticDiagnosticsSync,
arguments: { file: file2.path }
});
openFilesForSession([file1], session);
session.executeCommandSeq<ts.server.protocol.SemanticDiagnosticsSyncRequest>({
command: ts.server.CommandNames.SemanticDiagnosticsSync,
command: ts.server.protocol.CommandTypes.SemanticDiagnosticsSync,
arguments: { file: file2.path }
});
baselineTsserverLogs("skipLibCheck", "jsonly inferred project", session);
@@ -72,7 +72,7 @@ describe("unittests:: tsserver:: with skipLibCheck", () => {
const session = createSession(host, { logger: createLoggerWithInMemoryLogs(host) });
session.executeCommandSeq<ts.server.protocol.OpenExternalProjectRequest>({
command: ts.server.CommandNames.OpenExternalProject,
command: ts.server.protocol.CommandTypes.OpenExternalProject,
arguments: {
projectFileName: "project1",
rootFiles: toExternalFiles([jsFile.path, dTsFile.path]),
@@ -81,7 +81,7 @@ describe("unittests:: tsserver:: with skipLibCheck", () => {
});
session.executeCommandSeq({
command: ts.server.CommandNames.SemanticDiagnosticsSync,
command: ts.server.protocol.CommandTypes.SemanticDiagnosticsSync,
arguments: { file: dTsFile.path }
});
baselineTsserverLogs("skipLibCheck", "jsonly external project", session);
@@ -106,7 +106,7 @@ describe("unittests:: tsserver:: with skipLibCheck", () => {
const session = createSession(host, { logger: createLoggerWithInMemoryLogs(host) });
session.executeCommandSeq<ts.server.protocol.OpenExternalProjectRequest>({
command: ts.server.CommandNames.OpenExternalProject,
command: ts.server.protocol.CommandTypes.OpenExternalProject,
arguments: {
projectFileName: "project1",
rootFiles: toExternalFiles([jsFile.path, dTsFile.path]),
@@ -115,7 +115,7 @@ describe("unittests:: tsserver:: with skipLibCheck", () => {
});
session.executeCommandSeq<ts.server.protocol.SemanticDiagnosticsSyncRequest>({
command: ts.server.CommandNames.SemanticDiagnosticsSync,
command: ts.server.protocol.CommandTypes.SemanticDiagnosticsSync,
arguments: { file: dTsFile.path }
});
baselineTsserverLogs("skipLibCheck", "jsonly external project with skipLibCheck as false", session);
@@ -145,13 +145,13 @@ describe("unittests:: tsserver:: with skipLibCheck", () => {
openFilesForSession([jsFile], session);
const error1Result = session.executeCommandSeq<ts.server.protocol.SemanticDiagnosticsSyncRequest>({
command: ts.server.CommandNames.SemanticDiagnosticsSync,
command: ts.server.protocol.CommandTypes.SemanticDiagnosticsSync,
arguments: { file: dTsFile1.path }
}).response as ts.server.protocol.Diagnostic[];
assert.isTrue(error1Result.length === 0);
const error2Result = session.executeCommandSeq<ts.server.protocol.SemanticDiagnosticsSyncRequest>({
command: ts.server.CommandNames.SemanticDiagnosticsSync,
command: ts.server.protocol.CommandTypes.SemanticDiagnosticsSync,
arguments: { file: dTsFile2.path }
}).response as ts.server.protocol.Diagnostic[];
assert.isTrue(error2Result.length === 0);
@@ -171,7 +171,7 @@ describe("unittests:: tsserver:: with skipLibCheck", () => {
openFilesForSession([jsFile], session);
session.executeCommandSeq<ts.server.protocol.SemanticDiagnosticsSyncRequest>({
command: ts.server.CommandNames.SemanticDiagnosticsSync,
command: ts.server.protocol.CommandTypes.SemanticDiagnosticsSync,
arguments: { file: jsFile.path }
});
@@ -197,7 +197,7 @@ describe("unittests:: tsserver:: with skipLibCheck", () => {
openFilesForSession([jsFile], session);
session.executeCommandSeq<ts.server.protocol.SemanticDiagnosticsSyncRequest>({
command: ts.server.CommandNames.SemanticDiagnosticsSync,
command: ts.server.protocol.CommandTypes.SemanticDiagnosticsSync,
arguments: { file: jsFile.path }
}).response as ts.server.protocol.Diagnostic[];
baselineTsserverLogs("skipLibCheck", "reports semantic error in configured project with tscheck", session);
@@ -224,7 +224,7 @@ describe("unittests:: tsserver:: with skipLibCheck", () => {
openFilesForSession([jsFile], session);
session.executeCommandSeq<ts.server.protocol.SemanticDiagnosticsSyncRequest>({
command: ts.server.CommandNames.SemanticDiagnosticsSync,
command: ts.server.protocol.CommandTypes.SemanticDiagnosticsSync,
arguments: { file: jsFile.path }
}).response as ts.server.protocol.Diagnostic[];
baselineTsserverLogs("skipLibCheck", "reports semantic error in configured js project with tscheck", session);
@@ -29,7 +29,7 @@ class Foo {
const session = createSession(host, { logger: createLoggerWithInMemoryLogs(host) });
openFilesForSession([file], session);
session.executeCommandSeq<ts.server.protocol.SelectionRangeRequest>({
command: ts.server.CommandNames.SelectionRange,
command: ts.server.protocol.CommandTypes.SelectionRange,
arguments: {
file: file.path, locations: [
{ line: 4, offset: 13 }, // a === b
+1 -1
View File
@@ -32,7 +32,6 @@ import {
PackageInstalledResponse,
Project,
ProjectService,
protocol,
ServerCancellationToken,
ServerHost,
Session,
@@ -77,6 +76,7 @@ import {
versionMajorMinor,
WatchOptions,
} from "./_namespaces/ts";
import * as protocol from "../server/protocol";
interface LogOptions {
file?: string;
+2
View File
@@ -3791,7 +3791,9 @@ declare namespace ts {
fileName: NormalizedPath;
project: Project;
}
/** @deprecated use ts.server.protocol.CommandTypes */
type CommandNames = protocol.CommandTypes;
/** @deprecated use ts.server.protocol.CommandTypes */
const CommandNames: any;
type Event = <T extends object>(body: T, eventName: string) => void;
interface EventSender {
@@ -115,7 +115,7 @@ FsWatchesRecursive::
Info 14 [00:00:25.000] request:
{
"command": "geterr",
"command": "geterrForProject",
"arguments": {
"delay": 0,
"file": "/a.ts"