MCPcopy
hub / github.com/PowerShell/vscode-powershell / startLanguageClient

Method startLanguageClient

src/session.ts:899–1034  ·  view source on GitHub ↗
(
        sessionDetails: IEditorServicesSessionDetails,
    )

Source from the content-addressed store, hash-verified

897 }
898
899 private async startLanguageClient(
900 sessionDetails: IEditorServicesSessionDetails,
901 ): Promise<LanguageClient> {
902 this.logger.writeDebug("Connecting to language service...");
903 const connectFunc = (): Promise<StreamInfo> => {
904 return new Promise<StreamInfo>((resolve, _reject) => {
905 const socket = net.connect(
906 sessionDetails.languageServicePipeName,
907 );
908 socket.on("connect", () => {
909 this.logger.writeDebug("Language service connected.");
910 resolve({ writer: socket, reader: socket });
911 });
912 });
913 };
914
915 const clientOptions: LanguageClientOptions = {
916 documentSelector: this.documentSelector,
917 synchronize: {
918 // TODO: This is deprecated and they should be pulled by the server.
919 // backend uses "files" and "search" to ignore references.
920 configurationSection: [
921 utils.PowerShellLanguageId,
922 "files",
923 "search",
924 ],
925 // TODO: fileEvents: vscode.workspace.createFileSystemWatcher('**/.eslintrc')
926 },
927 // NOTE: Some settings are only applicable on startup, so we send them during initialization.
928 // When Terminal Shell Integration is enabled, we pass the path to the script that the server should execute.
929 // Passing an empty string implies integration is disabled.
930 initializationOptions: {
931 enableProfileLoading: this.sessionSettings.enableProfileLoading,
932 initialWorkingDirectory: await validateCwdSetting(this.logger),
933 shellIntegrationScript: this.shellIntegrationEnabled
934 ? utils.ShellIntegrationScript
935 : "",
936 },
937 errorHandler: {
938 // Override the default error handler to prevent it from
939 // closing the LanguageClient incorrectly when the socket
940 // hangs up (ECONNRESET errors).
941 error: (
942 _error: Error,
943 _message: Message,
944 _count: number,
945 ): ErrorHandlerResult => {
946 // TODO: Is there any error worth terminating on?
947 this.logger.writeError(
948 `${_error.name}: ${_error.message} ${_error.cause}`,
949 );
950 return { action: ErrorAction.Continue };
951 },
952 closed: (): CloseHandlerResult => {
953 this.logger.write("Language service connection closed.");
954 // We have our own restart experience
955 return {
956 action: CloseAction.DoNotRestart,

Callers 1

startMethod · 0.95

Calls 11

sendTelemetryEventMethod · 0.95
setSessionBusyStatusMethod · 0.95
validateCwdSettingFunction · 0.90
sendKeyPressMethod · 0.80
writeDebugMethod · 0.65
writeErrorMethod · 0.65
writeMethod · 0.65
onLanguageClientSetMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected