Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
4d3cff1
Add upper limit for the program size, fix readDirectory for the symli…
zhengbli Mar 11, 2016
b155fa8
Add comments
zhengbli Mar 12, 2016
a3aa000
CR feedback / Change upper limit / Add disableSizeLimit compiler option
zhengbli Mar 14, 2016
a6a466c
online and offline CR feedback
zhengbli Mar 15, 2016
d4eb3b8
Don't count current opened client file if it's TS file
zhengbli Mar 15, 2016
a839d93
Merge branch 'master' of https://github.com/Microsoft/TypeScript into…
zhengbli Mar 17, 2016
225e3b4
Speed up file searching
zhengbli Mar 17, 2016
c8e0b00
Make language service optional for a project
zhengbli Mar 17, 2016
d7e1d34
Merge branch 'master' of https://github.com/Microsoft/TypeScript into…
zhengbli Mar 18, 2016
cb46f16
Fix failed tests
zhengbli Mar 18, 2016
74e3d7b
Fix project updateing issue after editing config file
zhengbli Mar 18, 2016
1b76294
Merge branch 'master' of https://github.com/Microsoft/TypeScript into…
zhengbli Mar 24, 2016
5c9ce9e
Merge branch 'master' of https://github.com/Microsoft/TypeScript into…
zhengbli Mar 28, 2016
94d44ad
Merge branch 'master' of https://github.com/Microsoft/TypeScript into…
zhengbli Jun 9, 2016
d387050
Fix merging issues and multiple project scenario
zhengbli Jun 9, 2016
4383f1a
Refactoring
zhengbli Jun 9, 2016
e41b10b
add test and spit commandLineParser changes to another PR
zhengbli Jun 10, 2016
3354436
Merge branch 'master' of https://github.com/Microsoft/TypeScript into…
zhengbli Jun 15, 2016
550d912
Refactor code to make if statements cheaper
zhengbli Jun 15, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refactoring
  • Loading branch information
zhengbli committed Jun 9, 2016
commit 4383f1a15f43a99286a2bdf0b35cde83e7bb3e1e
2 changes: 1 addition & 1 deletion src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ namespace ts {
description: Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon
},
{
name: "disableSizeLimit",
name: "disableProjectSizeLimit",
type: "boolean"
},
{
Expand Down
4 changes: 0 additions & 4 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2984,9 +2984,5 @@
"Unknown typing option '{0}'.": {
"category": "Error",
"code": 17010
},
"Too many JavaScript files in the project. Consider specifying the 'exclude' setting in project configuration to limit included source folders. The likely folder to exclude is '{0}'. To disable the project size limit, set the 'disableSizeLimit' compiler option to 'true'.": {
"category": "Error",
"code": 17012
}
}
38 changes: 2 additions & 36 deletions src/compiler/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ namespace ts {
/* @internal */ export let emitTime = 0;
/* @internal */ export let ioReadTime = 0;
/* @internal */ export let ioWriteTime = 0;
/* @internal */ export const maxProgramSizeForNonTsFiles = 20 * 1024 * 1024;

/** The version of the TypeScript compiler release */

const emptyArray: any[] = [];

Expand All @@ -19,6 +16,7 @@ namespace ts {
"node_modules/@types/",
];

/** The version of the TypeScript compiler release */
export const version = "1.9.0";

export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean): string {
Expand Down Expand Up @@ -1059,8 +1057,6 @@ namespace ts {
let diagnosticsProducingTypeChecker: TypeChecker;
let noDiagnosticsTypeChecker: TypeChecker;
let classifiableNames: Map<string>;
let programSizeLimitExceeded = false;
let programSizeForNonTsFiles = 0;

let resolvedTypeReferenceDirectives: Map<ResolvedTypeReferenceDirective> = {};
let fileProcessingDiagnostics = createDiagnosticCollection();
Expand Down Expand Up @@ -1166,11 +1162,6 @@ namespace ts {

return program;

function exceedProgramSizeLimit() {
return !options.disableSizeLimit && programSizeLimitExceeded;
}


function getCommonSourceDirectory() {
if (typeof commonSourceDirectory === "undefined") {
if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) {
Expand Down Expand Up @@ -1219,7 +1210,6 @@ namespace ts {
(oldOptions.noLib !== options.noLib) ||
(oldOptions.jsx !== options.jsx) ||
(oldOptions.allowJs !== options.allowJs) ||
(oldOptions.disableSizeLimit !== options.disableSizeLimit) ||
(oldOptions.rootDir !== options.rootDir) ||
(oldOptions.typesSearchPaths !== options.typesSearchPaths) ||
(oldOptions.configFilePath !== options.configFilePath) ||
Expand Down Expand Up @@ -1838,7 +1828,7 @@ namespace ts {
}
}

if (diagnostic && !exceedProgramSizeLimit()) {
if (diagnostic) {
if (refFile !== undefined && refEnd !== undefined && refPos !== undefined) {
fileProcessingDiagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos, diagnostic, ...diagnosticArgument));
}
Expand Down Expand Up @@ -1871,11 +1861,6 @@ namespace ts {
return file;
}

const isNonTsFile = !hasTypeScriptFileExtension(fileName);
if (isNonTsFile && exceedProgramSizeLimit()) {
return undefined;
}

// We haven't looked for this file, do so now and cache result
const file = host.getSourceFile(fileName, options.target, hostErrorMessage => {
if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) {
Expand All @@ -1887,25 +1872,6 @@ namespace ts {
}
});

if (!options.disableSizeLimit && file && file.text && !hasTypeScriptFileExtension(file.fileName)) {
programSizeForNonTsFiles += file.text.length;
if (programSizeForNonTsFiles > maxProgramSizeForNonTsFiles) {
// If the program size limit was reached when processing a file, this file is
// likely in the problematic folder than contains too many files.
// Normally the folder is one level down from the commonSourceDirectory, for example,
// if the commonSourceDirectory is "/src/", and the last processed path was "/src/node_modules/a/b.js",
// we should show in the error message "/src/node_modules/".
const commonSourceDirectory = getCommonSourceDirectory();
let rootLevelDirectory = path.substring(0, Math.max(commonSourceDirectory.length, path.indexOf(directorySeparator, commonSourceDirectory.length)));
if (rootLevelDirectory[rootLevelDirectory.length - 1] !== directorySeparator) {
rootLevelDirectory += directorySeparator;
}
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Too_many_JavaScript_files_in_the_project_Consider_specifying_the_exclude_setting_in_project_configuration_to_limit_included_source_folders_The_likely_folder_to_exclude_is_0_To_disable_the_project_size_limit_set_the_disableSizeLimit_compiler_option_to_true, rootLevelDirectory));
programSizeLimitExceeded = true;
return undefined;
}
}

filesByName.set(path, file);
if (file) {
file.path = path;
Expand Down
26 changes: 22 additions & 4 deletions src/server/editorServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this !projectOptions.compilerOptions.disableSizeLimit to the beginning.

project.setProjectOptions(projectOptions);
if (project.languageServiceDiabled) {
return;
}

project.disableLanguageService();
project.directoryWatcher.close();
if (project.directoryWatcher) {
project.directoryWatcher.close();
project.directoryWatcher = undefined;
}
return;
}

Expand Down
3 changes: 3 additions & 0 deletions src/server/protocol.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down