Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 13.7k
Port #7486 to release 1.8#7513
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
3b55558708fb9735b972e4aba58c6ed14c2cfa83e95e74ebd4d0f488f13a9c77547f2f23184f5760c163b0fc9e0File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1217,10 +1217,45 @@ namespace ts.server { | ||
| } | ||
| else { | ||
| const project = this.createProject(configFilename, projectOptions); | ||
| let programSizeForNonTsFiles = 0; | ||
| // As the project openning might not be complete if there are too many files, | ||
| // therefore to surface the diagnostics we need to make sure the given client file is opened. | ||
| if (clientFileName) { | ||
| if (this.host.fileExists(clientFileName)) { | ||
| const currentClientFileInfo = this.openFile(clientFileName, /*openedByClient*/ true); | ||
| project.addRoot(currentClientFileInfo); | ||
| if (!hasTypeScriptFileExtension(currentClientFileInfo.fileName) && currentClientFileInfo.content) { | ||
| programSizeForNonTsFiles += currentClientFileInfo.content.length; | ||
| } | ||
| } | ||
| else { | ||
| return { errorMsg: "specified file " + clientFileName + " not found" }; | ||
| } | ||
| } | ||
| for (const rootFilename of projectOptions.files) { | ||
| if (rootFilename === clientFileName) { | ||
| continue; | ||
| } | ||
| if (this.host.fileExists(rootFilename)) { | ||
| const info = this.openFile(rootFilename, /*openedByClient*/ clientFileName == rootFilename); | ||
| project.addRoot(info); | ||
| if (projectOptions.compilerOptions.disableSizeLimit) { | ||
| const info = this.openFile(rootFilename, /*openedByClient*/ false); | ||
| project.addRoot(info); | ||
| } | ||
| else if (programSizeForNonTsFiles <= maxProgramSizeForNonTsFiles) { | ||
| const info = this.openFile(rootFilename, /*openedByClient*/ false); | ||
| project.addRoot(info); | ||
| if (!hasTypeScriptFileExtension(rootFilename)) { | ||
| programSizeForNonTsFiles += info.content.length; | ||
| } | ||
| } | ||
| else { | ||
| // The project size is too large. Stop loading the files on the server, | ||
| // and let the compiler issue an diagnostic via `createProgram`. | ||
| break; | ||
| } | ||
| } | ||
| else { | ||
| return { errorMsg: "specified file " + rootFilename + " not found" }; | ||
| @@ -1251,7 +1286,10 @@ namespace ts.server { | ||
| return error; | ||
| } | ||
| else { | ||
| const oldFileNames = project.compilerService.host.roots.map(info => info.fileName); | ||
| // if the project is too large, the root files might not have been all loaded if the total | ||
| // program size reached the upper limit. In that case project.projectOptions.files should | ||
| // be more precise. However this would only happen for configured project. | ||
| const oldFileNames = project.projectOptions ? project.projectOptions.files : project.compilerService.host.roots.map(info => info.fileName); | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just because Author There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This | ||
| const newFileNames = projectOptions.files; | ||
| const fileNamesToRemove = oldFileNames.filter(f => newFileNames.indexOf(f) < 0); | ||
| const fileNamesToAdd = newFileNames.filter(f => oldFileNames.indexOf(f) < 0); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the intent to just stop loading files at this point without issuing an error, and to let
createProgramissue the error when it adds up the file sizes? If so, add a comment here to explain this, so that future readers know why you are just breaking out of the loop without any kind of error.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, as I can't create a diagnostic within
editorServices.ts, the error returned here would be only used for logging. Adding a comment