Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix reference to worker session #198820

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions extensions/typescript-language-features/web/src/webServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
/// <reference lib='webworker.importscripts' />
/// <reference lib='webworker' />

import ts from 'typescript/lib/tsserverlibrary';
Expand All @@ -12,14 +11,10 @@ import { Logger, parseLogLevel } from './logging';
import { PathMapper } from './pathMapper';
import { createSys } from './serverHost';
import { findArgument, findArgumentStringArray, hasArgument, parseServerMode } from './util/args';
import { StartSessionOptions, createWorkerSession } from './workerSession';
import { StartSessionOptions, startWorkerSession } from './workerSession';

const setSys: (s: ts.System) => void = (ts as any).setSys;

// GLOBALS
let session: WorkerSession | undefined;
// END GLOBALS

async function initializeSession(
args: readonly string[],
extensionUri: URI,
Expand All @@ -46,8 +41,7 @@ async function initializeSession(
removeEventListener('message', listener);
});
setSys(sys);
session = createWorkerSession(ts, sys, fs, sessionOptions, ports.tsserver, pathMapper, logger);
session.listen();
startWorkerSession(ts, sys, fs, sessionOptions, ports.tsserver, pathMapper, logger);
}

function parseSessionOptions(args: readonly string[], serverMode: ts.LanguageServiceMode | undefined): StartSessionOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ export interface StartSessionOptions {
readonly disableAutomaticTypingAcquisition: boolean;
}

export function createWorkerSession(
export function startWorkerSession(
ts: typeof import('typescript/lib/tsserverlibrary'),
host: ts.server.ServerHost,
fs: FileSystem | undefined,
options: StartSessionOptions,
port: MessagePort,
pathMapper: PathMapper,
logger: Logger,
) {
): void {
const indent: (str: string) => string = (ts as any).server.indent;

return new class WorkerSession extends ts.server.Session<{}> {
const worker = new class WorkerSession extends ts.server.Session<{}> {

private readonly wasmCancellationToken: WasmCancellationToken;
private readonly listener: (message: any) => void;
Expand Down Expand Up @@ -121,4 +121,6 @@ export function createWorkerSession(
port.onmessage = this.listener;
}
}();

worker.listen();
}
Loading