mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
clean up oodate TODOs
This commit is contained in:
@@ -214,9 +214,9 @@ namespace fakes {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A fake `ts.CompilerHost` that leverages a virtual file system.
|
||||
*/
|
||||
/**
|
||||
* A fake `ts.CompilerHost` that leverages a virtual file system.
|
||||
*/
|
||||
export class CompilerHost implements ts.CompilerHost {
|
||||
public readonly sys: System;
|
||||
public readonly defaultLibLocation: string;
|
||||
@@ -416,7 +416,7 @@ namespace fakes {
|
||||
diagnostic: ts.Diagnostic;
|
||||
}
|
||||
|
||||
function indentedText(indent: number, text: string) {
|
||||
function indentedText(indent: number, text: string) {
|
||||
if (!indent) return text;
|
||||
let indentText = "";
|
||||
for (let i = 0; i < indent; i++) {
|
||||
@@ -427,7 +427,7 @@ ${indentText}${text}`;
|
||||
}
|
||||
|
||||
function expectedDiagnosticMessageToText([message, ...args]: ExpectedDiagnosticMessage) {
|
||||
let text = ts.getLocaleSpecificMessage(message);
|
||||
let text = ts.getLocaleSpecificMessage(message);
|
||||
|
||||
if (args.length) {
|
||||
text = ts.formatStringFromArgs(text, args);
|
||||
|
||||
@@ -1830,8 +1830,6 @@ namespace ts.server {
|
||||
if (this.serverMode !== LanguageServiceMode.Semantic) {
|
||||
return undefined;
|
||||
}
|
||||
// TODO: My code leaves deleted files as: the scriptinfo doesn't list a containing project, but the contianing ProjectService.openFiles still has the file
|
||||
// OR maybe vice versa
|
||||
Debug.assert(!isOpenScriptInfo(info) || this.openFiles.has(info.path));
|
||||
const projectRootPath = this.openFiles.get(info.path);
|
||||
const scriptInfo = Debug.checkDefined(this.getScriptInfo(info.path));
|
||||
@@ -3691,10 +3689,7 @@ namespace ts.server {
|
||||
|
||||
/* @internal */
|
||||
updateFileSystem(createdFiles: Iterator<protocol.FileSystemRequestArgs> | undefined, updatedFiles?: Iterator<protocol.FileSystemRequestArgs>, deletedFiles?: string[]) {
|
||||
// TODO: Maybe it is somehow gauche or verboten to use protocol types but the translation in applyChangesInOpenFiles seems stupid
|
||||
// 2. update vfs
|
||||
// I THINK that only vfs needs to update, because none of these files should be open.
|
||||
// (I guess files could update from the filesystem while they are still open, but that's something to solve at the end of prototyping I think)
|
||||
// TODO: Not sure it's OK to use protocol.FileSystemRequestArgs here
|
||||
const fs = this.host as TestFSWithWatch.VirtualServerHost;
|
||||
if (createdFiles) {
|
||||
let it;
|
||||
|
||||
@@ -1806,7 +1806,6 @@ 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
|
||||
*/
|
||||
export interface UpdateOpenRequest extends Request {
|
||||
command: CommandTypes.UpdateOpen;
|
||||
@@ -1836,14 +1835,17 @@ namespace ts.server.protocol {
|
||||
arguments: UpdateFileSystemRequestArgs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Arguments to UpdateFileSystemRequest. Tracks changes to non-opened files.
|
||||
*/
|
||||
export 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 */
|
||||
/** List of newly created or newly available files. */
|
||||
created: FileSystemRequestArgs[];
|
||||
/** Just-deleted files. Also needs to trigger and then remove file watchers (I think) */
|
||||
/** Names of just-deleted files. */
|
||||
deleted: string[];
|
||||
/** Needs to replace what file watchers would normally listen to */
|
||||
/** List of updated files. */
|
||||
updated: FileSystemRequestArgs[];
|
||||
}
|
||||
|
||||
@@ -1856,7 +1858,6 @@ namespace ts.server.protocol {
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
+12
-14
@@ -665,7 +665,6 @@ namespace ts.server {
|
||||
|
||||
export class Session<TMessage = string> implements EventSender {
|
||||
private readonly gcTimer: GcTimer;
|
||||
// TODO: This will need to be replaced too
|
||||
protected projectService: ProjectService;
|
||||
private changeSeq = 0;
|
||||
|
||||
@@ -674,7 +673,6 @@ namespace ts.server {
|
||||
private currentRequestId!: number;
|
||||
private errorCheck: MultistepOperation;
|
||||
|
||||
// TODO: Replace this one?
|
||||
protected host: ServerHost;
|
||||
private readonly cancellationToken: ServerCancellationToken;
|
||||
protected readonly typingsInstaller: ITypingsInstaller;
|
||||
@@ -2675,16 +2673,16 @@ namespace ts.server {
|
||||
[CommandNames.UpdateOpen]: (request: protocol.UpdateOpenRequest) => {
|
||||
this.changeSeq++;
|
||||
this.projectService.applyChangesInOpenFiles(
|
||||
request.arguments.openFiles && mapIterator(arrayIterator(request.arguments.openFiles), ({ file, fileContent, scriptKindName, projectRootPath }) => ({
|
||||
fileName: file,
|
||||
content: fileContent,
|
||||
scriptKind: scriptKindName,
|
||||
projectRootPath
|
||||
request.arguments.openFiles && mapIterator(arrayIterator(request.arguments.openFiles), file => ({
|
||||
fileName: file.file,
|
||||
content: file.fileContent,
|
||||
scriptKind: file.scriptKindName,
|
||||
projectRootPath: file.projectRootPath
|
||||
})),
|
||||
request.arguments.changedFiles && mapIterator(arrayIterator(request.arguments.changedFiles), ({ fileName, textChanges}) => ({
|
||||
fileName,
|
||||
changes: mapDefinedIterator(arrayReverseIterator(textChanges), change => {
|
||||
const scriptInfo = Debug.checkDefined(this.projectService.getScriptInfo(fileName));
|
||||
request.arguments.changedFiles && mapIterator(arrayIterator(request.arguments.changedFiles), file => ({
|
||||
fileName: file.fileName,
|
||||
changes: mapDefinedIterator(arrayReverseIterator(file.textChanges), change => {
|
||||
const scriptInfo = Debug.checkDefined(this.projectService.getScriptInfo(file.fileName));
|
||||
const start = scriptInfo.lineOffsetToPosition(change.start.line, change.start.offset);
|
||||
const end = scriptInfo.lineOffsetToPosition(change.end.line, change.end.offset);
|
||||
return start >= 0 ? { span: { start, length: end - start }, newText: change.newText } : undefined;
|
||||
@@ -2711,9 +2709,9 @@ namespace ts.server {
|
||||
[CommandNames.UpdateFileSystem]: (request: protocol.UpdateFileSystemRequest) => {
|
||||
this.changeSeq++;
|
||||
this.projectService.updateFileSystem(
|
||||
request.arguments.created && arrayIterator(request.arguments.created), // open
|
||||
request.arguments.updated && arrayIterator(request.arguments.updated), //change
|
||||
request.arguments.deleted, // close
|
||||
request.arguments.created && arrayIterator(request.arguments.created),
|
||||
request.arguments.updated && arrayIterator(request.arguments.updated),
|
||||
request.arguments.deleted,
|
||||
);
|
||||
return this.requiredResponse(/*response*/ true);
|
||||
},
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace ts.server {
|
||||
if (typeof process !== "undefined") {
|
||||
start(initializeNodeSystem(), require("os").platform());
|
||||
}
|
||||
// TODO: Learn how to pass arguments to server
|
||||
// TODO: Not sure this is right
|
||||
else if (findArgument("vfs")) {
|
||||
// Get args from first message
|
||||
const listener = (e: any) => {
|
||||
|
||||
Reference in New Issue
Block a user