mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-22 02:35:48 -05:00
Refactoring
This commit is contained in:
@@ -27,6 +27,8 @@ namespace ts.server {
|
||||
});
|
||||
}
|
||||
|
||||
export const maxProgramSizeForNonTsFiles = 20 * 1024 * 1024;
|
||||
|
||||
export class ScriptInfo {
|
||||
svc: ScriptVersionCache;
|
||||
children: ScriptInfo[] = []; // files referenced by this file
|
||||
@@ -384,7 +386,7 @@ namespace ts.server {
|
||||
constructor(
|
||||
public projectService: ProjectService,
|
||||
public projectOptions?: ProjectOptions,
|
||||
public languageServiceDiabled?: boolean) {
|
||||
public languageServiceDiabled = false) {
|
||||
if (projectOptions && projectOptions.files) {
|
||||
// If files are listed explicitly, allow all extensions
|
||||
projectOptions.compilerOptions.allowNonTsExtensions = true;
|
||||
@@ -430,7 +432,16 @@ namespace ts.server {
|
||||
|
||||
getFileNames() {
|
||||
if (this.languageServiceDiabled) {
|
||||
return this.projectOptions ? this.projectOptions.files : undefined;
|
||||
if (!this.projectOptions) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const fileNames: string[] = [];
|
||||
if (this.projectOptions && this.projectOptions.compilerOptions) {
|
||||
fileNames.push(getDefaultLibFilePath(this.projectOptions.compilerOptions));
|
||||
}
|
||||
ts.addRange(fileNames, this.projectOptions.files);
|
||||
return fileNames;
|
||||
}
|
||||
|
||||
const sourceFiles = this.program.getSourceFiles();
|
||||
@@ -1340,6 +1351,10 @@ namespace ts.server {
|
||||
|
||||
private exceedTotalNonTsFileSizeLimit(fileNames: string[]) {
|
||||
let totalNonTsFileSize = 0;
|
||||
if (!this.host.getFileSize) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const fileName of fileNames) {
|
||||
if (hasTypeScriptFileExtension(fileName)) {
|
||||
continue;
|
||||
@@ -1409,14 +1424,17 @@ namespace ts.server {
|
||||
return errors;
|
||||
}
|
||||
else {
|
||||
if (this.exceedTotalNonTsFileSizeLimit(projectOptions.files)) {
|
||||
if (this.exceedTotalNonTsFileSizeLimit(projectOptions.files) && projectOptions.compilerOptions && !projectOptions.compilerOptions.disableSizeLimit) {
|
||||
project.setProjectOptions(projectOptions);
|
||||
if (project.languageServiceDiabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
project.disableLanguageService();
|
||||
project.directoryWatcher.close();
|
||||
if (project.directoryWatcher) {
|
||||
project.directoryWatcher.close();
|
||||
project.directoryWatcher = undefined;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
3
src/server/protocol.d.ts
vendored
3
src/server/protocol.d.ts
vendored
@@ -123,6 +123,9 @@ declare namespace ts.server.protocol {
|
||||
* The list of normalized file name in the project, including 'lib.d.ts'
|
||||
*/
|
||||
fileNames?: string[];
|
||||
/**
|
||||
* Indicates if the project has a active language service instance
|
||||
*/
|
||||
languageServiceDisabled?: boolean;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user