mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Everything builds and tests pass
Except for the new test I added.
This commit is contained in:
@@ -3693,33 +3693,33 @@ namespace ts.server {
|
||||
// ugggggggggg have to copy over all that stuff to here
|
||||
// (though I probably need to create a vfs project anyway, so why not)
|
||||
|
||||
const fs = new vfs.FileSystem(/*ignoreCase*/ true, {
|
||||
files: {
|
||||
[builtFolder]: new Mount(vpath.resolve(host.getWorkspaceRoot(), "built/local"), resolver),
|
||||
[testLibFolder]: new Mount(vpath.resolve(host.getWorkspaceRoot(), "tests/lib"), resolver),
|
||||
[projectsFolder]: new Mount(vpath.resolve(host.getWorkspaceRoot(), "tests/projects"), resolver),
|
||||
[srcFolder]: {}
|
||||
},
|
||||
cwd: srcFolder,
|
||||
meta: { defaultLibLocation: builtFolder }
|
||||
})
|
||||
if (!this.fs)
|
||||
this.fs = fs
|
||||
if (createdFiles) {
|
||||
for (const document of Array.from(createdFiles)) {
|
||||
fs.mkdirpSync(vpath.dirname(document.file));
|
||||
fs.writeFileSync(document.file, document.text, "utf8");
|
||||
fs.filemeta(document.file).set("document", document);
|
||||
// Add symlinks
|
||||
const symlink = document.meta.get("symlink");
|
||||
if (symlink) {
|
||||
for (const link of symlink.split(",").map(link => link.trim())) {
|
||||
fs.mkdirpSync(vpath.dirname(link));
|
||||
fs.symlinkSync(vpath.resolve(fs.cwd(), document.file), link);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// const fs = new vfs.FileSystem(/*ignoreCase*/ true, {
|
||||
// files: {
|
||||
// [builtFolder]: new Mount(vpath.resolve(host.getWorkspaceRoot(), "built/local"), resolver),
|
||||
// [testLibFolder]: new Mount(vpath.resolve(host.getWorkspaceRoot(), "tests/lib"), resolver),
|
||||
// [projectsFolder]: new Mount(vpath.resolve(host.getWorkspaceRoot(), "tests/projects"), resolver),
|
||||
// [srcFolder]: {}
|
||||
// },
|
||||
// cwd: srcFolder,
|
||||
// meta: { defaultLibLocation: builtFolder }
|
||||
// })
|
||||
// if (!this.fs)
|
||||
// this.fs = fs
|
||||
// if (createdFiles) {
|
||||
// for (const document of Array.from(createdFiles)) {
|
||||
// fs.mkdirpSync(vpath.dirname(document.file));
|
||||
// fs.writeFileSync(document.file, document.text, "utf8");
|
||||
// fs.filemeta(document.file).set("document", document);
|
||||
// // Add symlinks
|
||||
// const symlink = document.meta.get("symlink");
|
||||
// if (symlink) {
|
||||
// for (const link of symlink.split(",").map(link => link.trim())) {
|
||||
// fs.mkdirpSync(vpath.dirname(link));
|
||||
// fs.symlinkSync(vpath.resolve(fs.cwd(), document.file), link);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// 1. set some internal tsserver state for mocked FS (if it hasn't already been set, this might not be the first message)
|
||||
// - change this.host at least
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
{ "path": "../server", "prepend": true },
|
||||
{ "path": "../webServer", "prepend": true },
|
||||
{ "path": "../typingsInstallerCore", "prepend": true },
|
||||
{ "path": "../vfs", "prepend": true },
|
||||
{ "path": "../harness", "prepend": true },
|
||||
{ "path": "../loggedIO", "prepend": true }
|
||||
],
|
||||
|
||||
@@ -1598,23 +1598,4 @@ namespace vfs {
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
export function iteratePatch(patch: FileSet | undefined): IterableIterator<[string, string]> | null {
|
||||
// eslint-disable-next-line no-null/no-null
|
||||
return patch ? Harness.Compiler.iterateOutputs(iteratePatchWorker("", patch)) : null;
|
||||
}
|
||||
|
||||
function* iteratePatchWorker(dirname: string, container: FileSet): IterableIterator<documents.TextDocument> {
|
||||
for (const name of Object.keys(container)) {
|
||||
const entry = normalizeFileSetEntry(container[name]);
|
||||
const file = dirname ? vpath.combine(dirname, name) : name;
|
||||
if (entry instanceof Directory) {
|
||||
yield* ts.arrayFrom(iteratePatchWorker(file, entry.files));
|
||||
}
|
||||
else if (entry instanceof File) {
|
||||
const content = typeof entry.data === "string" ? entry.data : entry.data.toString("utf8");
|
||||
yield new documents.TextDocument(file, content);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+30
-1
@@ -6970,6 +6970,7 @@ declare namespace ts.server.protocol {
|
||||
OpenExternalProjects = "openExternalProjects",
|
||||
CloseExternalProject = "closeExternalProject",
|
||||
UpdateOpen = "updateOpen",
|
||||
UpdateFileSystem = "updateFileSystem",
|
||||
GetOutliningSpans = "getOutliningSpans",
|
||||
TodoComments = "todoComments",
|
||||
Indentation = "indentation",
|
||||
@@ -8216,6 +8217,7 @@ declare namespace ts.server.protocol {
|
||||
}
|
||||
/**
|
||||
* Request to synchronize list of open files with the client
|
||||
* TODO: Lots of unit tests refer to this too, a good starting point for UpdateFileSystemRequest
|
||||
*/
|
||||
interface UpdateOpenRequest extends Request {
|
||||
command: CommandTypes.UpdateOpen;
|
||||
@@ -8230,7 +8232,7 @@ declare namespace ts.server.protocol {
|
||||
*/
|
||||
openFiles?: OpenRequestArgs[];
|
||||
/**
|
||||
* List of open files files that were changes
|
||||
* List of open files files that were changed
|
||||
*/
|
||||
changedFiles?: FileCodeEdits[];
|
||||
/**
|
||||
@@ -8238,6 +8240,33 @@ declare namespace ts.server.protocol {
|
||||
*/
|
||||
closedFiles?: string[];
|
||||
}
|
||||
interface UpdateFileSystemRequest extends Request {
|
||||
command: CommandTypes.UpdateFileSystem;
|
||||
arguments: UpdateFileSystemRequestArgs;
|
||||
}
|
||||
interface UpdateFileSystemRequestArgs {
|
||||
/** For now, only 'memfs', initially for exclusive in-memory operation, but it could be other in-memory names later */
|
||||
fileSystem: string;
|
||||
/** For now, a list of newly created or newly available files. Probably need to ADD mocked file watchers */
|
||||
created: FileSystemRequestArgs[];
|
||||
/** Just-deleted files. Also needs to trigger and then remove file watchers (I think) */
|
||||
deleted: string[];
|
||||
/** Needs to replace what file watchers would normally listen to */
|
||||
updated: FileSystemRequestArgs[];
|
||||
}
|
||||
interface FileSystemRequestArgs extends FileRequestArgs {
|
||||
/**
|
||||
* Used to replace the content that would be on disk.
|
||||
* Then the known content will be used upon opening instead of the disk copy
|
||||
*/
|
||||
fileContent?: string;
|
||||
/**
|
||||
* Used to specify the script kind of the file explicitly. It could be one of the following:
|
||||
* "TS", "JS", "TSX", "JSX"
|
||||
* TODO: Not 100% sure this is needed.
|
||||
*/
|
||||
scriptKindName?: ScriptKindName;
|
||||
}
|
||||
/**
|
||||
* External projects have a typeAcquisition option so they need to be added separately to compiler options for inferred projects.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user