diff --git a/lib/tsserver.js b/lib/tsserver.js index 77348ce6e8aaf..ed62dd90686ef 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -42743,9 +42743,10 @@ var ts; this.host = host; this.project = project; this.ls = null; - this.filenameToScript = {}; this.roots = []; - this.resolvedModuleNames = ts.createFileMap(ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames)); + var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); + this.resolvedModuleNames = ts.createFileMap(getCanonicalFileName); + this.filenameToScript = ts.createFileMap(getCanonicalFileName); this.moduleResolutionHost = { fileExists: function (fileName) { return _this.fileExists(fileName); }, readFile: function (fileName) { return _this.host.readFile(fileName); } @@ -42824,33 +42825,29 @@ var ts; }; LSHost.prototype.removeReferencedFile = function (info) { if (!info.isOpen) { - this.filenameToScript[info.fileName] = undefined; + this.filenameToScript.remove(info.fileName); this.resolvedModuleNames.remove(info.fileName); } }; LSHost.prototype.getScriptInfo = function (filename) { - var scriptInfo = ts.lookUp(this.filenameToScript, filename); + var scriptInfo = this.filenameToScript.get(filename); if (!scriptInfo) { scriptInfo = this.project.openReferencedFile(filename); if (scriptInfo) { - this.filenameToScript[scriptInfo.fileName] = scriptInfo; + this.filenameToScript.set(scriptInfo.fileName, scriptInfo); } } - else { - } return scriptInfo; }; LSHost.prototype.addRoot = function (info) { - var scriptInfo = ts.lookUp(this.filenameToScript, info.fileName); - if (!scriptInfo) { - this.filenameToScript[info.fileName] = info; + if (!this.filenameToScript.contains(info.fileName)) { + this.filenameToScript.set(info.fileName, info); this.roots.push(info); } }; LSHost.prototype.removeRoot = function (info) { - var scriptInfo = ts.lookUp(this.filenameToScript, info.fileName); - if (scriptInfo) { - this.filenameToScript[info.fileName] = undefined; + if (!this.filenameToScript.contains(info.fileName)) { + this.filenameToScript.remove(info.fileName); this.roots = copyListRemovingItem(info, this.roots); this.resolvedModuleNames.remove(info.fileName); } @@ -42890,7 +42887,7 @@ var ts; return this.host.directoryExists(path); }; LSHost.prototype.lineToTextSpan = function (filename, line) { - var script = this.filenameToScript[filename]; + var script = this.filenameToScript.get(filename); var index = script.snap().index; var lineInfo = index.lineNumberToInfo(line + 1); var len; @@ -42904,13 +42901,13 @@ var ts; return ts.createTextSpan(lineInfo.offset, len); }; LSHost.prototype.lineOffsetToPosition = function (filename, line, offset) { - var script = this.filenameToScript[filename]; + var script = this.filenameToScript.get(filename); var index = script.snap().index; var lineInfo = index.lineNumberToInfo(line); return (lineInfo.offset + offset - 1); }; LSHost.prototype.positionToLineOffset = function (filename, position) { - var script = this.filenameToScript[filename]; + var script = this.filenameToScript.get(filename); var index = script.snap().index; var lineOffset = index.charOffsetToLineNumberAndPos(position); return { line: lineOffset.line, offset: lineOffset.offset + 1 };