From 2acd98e03e8059554a57d455b38025ddc0b5233a Mon Sep 17 00:00:00 2001 From: Yui T Date: Thu, 4 Sep 2014 15:08:50 -0700 Subject: [PATCH] Minor spelling and spacing fix --- src/compiler/core.ts | 10 +++++----- src/compiler/parser.ts | 16 ++++++++-------- src/services/services.ts | 15 ++++++++------- src/services/shims.ts | 1 + tests/cases/fourslash/fourslash.ts | 8 ++++---- 5 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 7bc9c7e16b2..432ae6ab8cd 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -383,7 +383,7 @@ module ts { return [path.substr(0, rootLength)].concat(normalizedParts); } - export function getNormalizedPathComponents(path: string, getCurrentDirectory: ()=>string) { + export function getNormalizedPathComponents(path: string, getCurrentDirectory: () => string) { var path = normalizeSlashes(path); var rootLength = getRootLength(path); if (rootLength == 0) { @@ -396,7 +396,7 @@ module ts { return normalizedPathComponents(path, rootLength); } - export function getNormalizedPathFromPathCompoments(pathComponents: string[]) { + export function getNormalizedPathFromPathComponents(pathComponents: string[]) { if (pathComponents && pathComponents.length) { return pathComponents[0] + pathComponents.slice(1).join(directorySeparator); } @@ -444,7 +444,7 @@ module ts { } } - function getNormalizedPathOrUrlComponents(pathOrUrl: string, getCurrentDirectory: ()=>string) { + function getNormalizedPathOrUrlComponents(pathOrUrl: string, getCurrentDirectory: () => string) { if (isUrl(pathOrUrl)) { return getNormalizedPathComponentsOfUrl(pathOrUrl); } @@ -457,7 +457,7 @@ module ts { var pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, getCurrentDirectory); var directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, getCurrentDirectory); if (directoryComponents.length > 1 && directoryComponents[directoryComponents.length - 1] === "") { - // If the directory path given was of type test/cases/ then we really need components of directry to be only till its name + // If the directory path given was of type test/cases/ then we really need components of directory to be only till its name // that is ["test", "cases", ""] needs to be actually ["test", "cases"] directoryComponents.length--; } @@ -483,7 +483,7 @@ module ts { } // Cant find the relative path, get the absolute path - var absolutePath = getNormalizedPathFromPathCompoments(pathComponents); + var absolutePath = getNormalizedPathFromPathComponents(pathComponents); if (isAbsolutePathAnUrl && isRootedDiskPath(absolutePath)) { absolutePath = "file:///" + absolutePath; } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 64ac4683267..9e254936a6f 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -3817,11 +3817,11 @@ module ts { // Each file contributes into common source file path if (!(sourceFile.flags & NodeFlags.DeclarationFile) && !fileExtensionIs(sourceFile.filename, ".js")) { - var sourcePathCompoments = getNormalizedPathComponents(sourceFile.filename, host.getCurrentDirectory); - sourcePathCompoments.pop(); // FileName is not part of directory + var sourcePathComponents = getNormalizedPathComponents(sourceFile.filename, host.getCurrentDirectory); + sourcePathComponents.pop(); // FileName is not part of directory if (commonPathComponents) { - for (var i = 0; i < Math.min(commonPathComponents.length, sourcePathCompoments.length); i++) { - if (commonPathComponents[i] !== sourcePathCompoments[i]) { + for (var i = 0; i < Math.min(commonPathComponents.length, sourcePathComponents.length); i++) { + if (commonPathComponents[i] !== sourcePathComponents[i]) { if (i === 0) { errors.push(createCompilerDiagnostic(Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files)); return; @@ -3834,18 +3834,18 @@ module ts { } // If the fileComponent path completely matched and less than already found update the length - if (sourcePathCompoments.length < commonPathComponents.length) { - commonPathComponents.length = sourcePathCompoments.length; + if (sourcePathComponents.length < commonPathComponents.length) { + commonPathComponents.length = sourcePathComponents.length; } } else { // first file - commonPathComponents = sourcePathCompoments; + commonPathComponents = sourcePathComponents; } } }); - commonSourceDirectory = getNormalizedPathFromPathCompoments(commonPathComponents); + commonSourceDirectory = getNormalizedPathFromPathComponents(commonPathComponents); if (commonSourceDirectory) { // Make sure directory path ends with directory separator so this string can directly // used to replace with "" to get the relative path of the source file and the relative path doesn't diff --git a/src/services/services.ts b/src/services/services.ts index 5be6e29ff6f..afa3f200b6c 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1393,7 +1393,7 @@ module ts { var documentRegistry = documentRegistry; var cancellationToken = new CancellationTokenObject(host.getCancellationToken()); var activeCompletionSession: CompletionSession; // The current active completion session, used to get the completion entry details - var writter: (filename: string, data: string, writebyteordermark: boolean) => void = undefined; + var writer: (filename: string, data: string, writeByteOrderMark: boolean) => void = undefined; // Check if the localized messages json is set, otherwise query the host for it if (!TypeScript.LocalizedDiagnosticMessages) { @@ -1423,8 +1423,8 @@ module ts { return host.getDefaultLibFilename(); }, writeFile: (filename, data, writeByteOrderMark) => { - if (writter) { - writter(filename, data, writeByteOrderMark); + if (writer) { + writer(filename, data, writeByteOrderMark); return; } throw Error("Error occurs: Invalid invocation to writeFile"); @@ -2840,6 +2840,7 @@ module ts { } } } + function containErrors(diagnostics: Diagnostic[]): boolean { var hasError = forEach(diagnostics, diagnostic => diagnostic.category === DiagnosticCategory.Error); return hasError; @@ -2855,8 +2856,8 @@ module ts { emitOutputResult: undefined, }; - // Initialize writter for CompilerHost.writeFile - writter = function (fileName: string, data: string, writeByteOrderMark: boolean) { + // Initialize writer for CompilerHost.writeFile + writer = function (fileName: string, data: string, writeByteOrderMark: boolean) { var outputFile: OutputFile = { name: fileName, writeByteOrderMark: writeByteOrderMark, @@ -2893,8 +2894,8 @@ module ts { emitResult.emitOutputResult = EmitOutputResult.Succeeded; } - // Reset writter back to underfined to make sure that we produce an error message if CompilerHost.writeFile method is called when we are not in an emitting stage - this.writter = undefined; + // Reset writer back to underfined to make sure that we produce an error message if CompilerHost.writeFile method is called when we are not in an emitting stage + this.writer = undefined; return emitResult; } diff --git a/src/services/shims.ts b/src/services/shims.ts index 2e19db2815a..bf2c5f9b6f2 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -368,6 +368,7 @@ module ts { getDefaultLibFilename(): string { return this.shimHost.getDefaultLibFilename(); } + getCurrentDirectory(): string { return this.shimHost.getCurrentDirectory(); } diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 91bce54525a..d724b75e80e 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -46,10 +46,10 @@ enum TypingFidelity { // We have to duplicate EmitOutputResult from Services.ts to expose the enum to getEmitOutput testcases in fourslah enum EmitOutputResult { - Succeeded, - FailedBecauseOfSyntaxErrors, - FailedBecauseOfCompilerOptionsErrors, - FailedToGenerateDeclarationsBecauseOfSemanticErrors + Succeeded, + FailedBecauseOfSyntaxErrors, + FailedBecauseOfCompilerOptionsErrors, + FailedToGenerateDeclarationsBecauseOfSemanticErrors } module FourSlashInterface {