From b6ef32346b7d563570f6741bfd526c23c8d34215 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 16 Apr 2015 16:35:48 -0700 Subject: [PATCH] Respond to code review comments --- src/compiler/diagnosticInformationMap.generated.ts | 2 +- src/compiler/diagnosticMessages.json | 2 +- src/compiler/program.ts | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 7c9d9b56c63..0b4200455b1 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -496,7 +496,7 @@ module ts { Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: DiagnosticCategory.Message, key: "Do not emit declarations for code that has an '@internal' annotation." }, Preserve_new_lines_when_emitting_code: { code: 6057, category: DiagnosticCategory.Message, key: "Preserve new-lines when emitting code." }, Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: DiagnosticCategory.Message, key: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." }, - File_0_is_not_under_rootDir_1_RootDir_is_expected_to_contain_all_source_files: { code: 6059, category: DiagnosticCategory.Error, key: "File '{0}' is not under rootDir '{1}'. RootDir is expected to contain all source files." }, + File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: DiagnosticCategory.Error, key: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 31fc9090a6f..38d8a43e4c1 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1972,7 +1972,7 @@ "category": "Message", "code": 6058 }, - "File '{0}' is not under rootDir '{1}'. RootDir is expected to contain all source files.": { + "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files.": { "category": "Error", "code": 6059 }, diff --git a/src/compiler/program.ts b/src/compiler/program.ts index e3fe08d04eb..0d0c5b16d32 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -453,7 +453,7 @@ module ts { } } - function computecommonSourceDirectory(sourceFiles: SourceFile[]): string { + function computeCommonSourceDirectory(sourceFiles: SourceFile[]): string { let commonPathComponents: string[]; let currentDirectory = host.getCurrentDirectory(); forEach(files, sourceFile => { @@ -465,7 +465,7 @@ module ts { let sourcePathComponents = getNormalizedPathComponents(sourceFile.fileName, currentDirectory); sourcePathComponents.pop(); // FileName is not part of directory if (commonPathComponents) { - for (let i = 0; i < Math.min(commonPathComponents.length, sourcePathComponents.length); i++) { + for (let i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { if (commonPathComponents[i] !== sourcePathComponents[i]) { if (i === 0) { diagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files)); @@ -486,8 +486,8 @@ module ts { else { // first file commonPathComponents = sourcePathComponents; + return; } - }); return getNormalizedPathFromPathComponents(commonPathComponents); @@ -495,15 +495,15 @@ module ts { function checkSourceFilesBelongToPath(soruceFiles: SourceFile[], rootDirectory: string): boolean { let allFilesBelongToPath = true; - if (files) { + if (soruceFiles) { let currentDirectory = host.getCurrentDirectory(); let absoluteRootDirectoryPath = host.getCanonicalFileName(getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var sourceFile of files) { + for (var sourceFile of soruceFiles) { if (!isDeclarationFile(sourceFile)) { let absoluteSourceFilePath = host.getCanonicalFileName(getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.File_0_is_not_under_rootDir_1_RootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir)); + diagnostics.add(createCompilerDiagnostic(Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir)); allFilesBelongToPath = false; } } @@ -581,7 +581,7 @@ module ts { } else { // Compute the commonSourceDirectory from the input files - commonSourceDirectory = computecommonSourceDirectory(files); + commonSourceDirectory = computeCommonSourceDirectory(files); } if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== directorySeparator) {