mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-15 02:41:30 -05:00
Initial scribbles using vscode-sync-api-client
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
/// <reference lib="webworker" />
|
||||
|
||||
namespace ts.server {
|
||||
// declare const lol: import("vscode-sync-api-client").ApiClient
|
||||
const nullLogger: Logger = {
|
||||
close: noop,
|
||||
hasLevel: returnFalse,
|
||||
@@ -23,6 +24,8 @@ namespace ts.server {
|
||||
return LanguageServiceMode.PartialSemantic;
|
||||
case "syntactic":
|
||||
return LanguageServiceMode.Syntactic;
|
||||
case "semantic":
|
||||
if (hasArgument("--vfs")) return LanguageServiceMode.Semantic;
|
||||
default:
|
||||
return mode;
|
||||
}
|
||||
@@ -56,7 +59,7 @@ namespace ts.server {
|
||||
logger,
|
||||
cancellationToken: nullCancellationToken,
|
||||
// Webserver defaults to partial semantic mode
|
||||
serverMode: serverMode ?? LanguageServiceMode.PartialSemantic,
|
||||
serverMode: serverMode ?? (hasArgument("--vfs") ? LanguageServiceMode.Semantic : LanguageServiceMode.PartialSemantic),
|
||||
unknownServerMode,
|
||||
startSession: startWebSession
|
||||
};
|
||||
@@ -71,25 +74,43 @@ namespace ts.server {
|
||||
postMessage(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is called from initializeWebSystem,
|
||||
* which is indirectly called from the toplevel code in tsserver/server that registers a message.
|
||||
* When *something* fires the message, it calls
|
||||
* which calls initializeWebSystem above, but it doesn't need to change much
|
||||
* first create a webhost, which will need to alternately create a vscode-sync-api-host or SOMETHING
|
||||
* then createWebSystem in webserver/webserver.ts, with a thunk for finding arguments (doesn't work until after setSys)
|
||||
* createWebSystem probably needs *some* changes, but not many -- probably not enough to fork it,
|
||||
* but MAYBE since it is a lot of work built around a minimal webHost
|
||||
*/
|
||||
function createWebSystem(args: string[]) {
|
||||
Debug.assert(ts.sys === undefined);
|
||||
const webHost: WebHost = {
|
||||
readFile: webPath => {
|
||||
const request = new XMLHttpRequest();
|
||||
request.open("GET", webPath, /* asynchronous */ false);
|
||||
request.send();
|
||||
return request.status === 200 ? request.responseText : undefined;
|
||||
},
|
||||
fileExists: webPath => {
|
||||
const request = new XMLHttpRequest();
|
||||
request.open("HEAD", webPath, /* asynchronous */ false);
|
||||
request.send();
|
||||
return request.status === 200;
|
||||
},
|
||||
writeMessage,
|
||||
};
|
||||
// Do this after sys has been set as findArguments is going to work only then
|
||||
const sys = server.createWebSystem(webHost, args, () => findArgument("--executingFilePath") || location + "");
|
||||
let sys: ServerHost;
|
||||
// TODO: Actually copy this from the old PR
|
||||
if (args.includes("--vfs")) {
|
||||
sys = {} as any
|
||||
// TODO: maybe createWebSystem could still work
|
||||
}
|
||||
else {
|
||||
const webHost: WebHost = {
|
||||
readFile: webPath => {
|
||||
const request = new XMLHttpRequest();
|
||||
request.open("GET", webPath, /* asynchronous */ false);
|
||||
request.send();
|
||||
return request.status === 200 ? request.responseText : undefined;
|
||||
},
|
||||
fileExists: webPath => {
|
||||
const request = new XMLHttpRequest();
|
||||
request.open("HEAD", webPath, /* asynchronous */ false);
|
||||
request.send();
|
||||
return request.status === 200;
|
||||
},
|
||||
writeMessage,
|
||||
};
|
||||
// Do this after sys has been set as findArguments is going to work only then
|
||||
sys = server.createWebSystem(webHost, args, () => findArgument("--executingFilePath") || location + "");
|
||||
}
|
||||
setSys(sys);
|
||||
const localeStr = findArgument("--locale");
|
||||
if (localeStr) {
|
||||
|
||||
Reference in New Issue
Block a user