Skip to content

Watch directories through polling when recursive options is not supported on the system #20207

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

Closed
wants to merge 11 commits into from
Closed
2 changes: 1 addition & 1 deletion Gulpfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ gulp.task(specMd, /*help*/ false, [word2mdJs], (done) => {
gulp.task("generate-spec", "Generates a Markdown version of the Language Specification", [specMd]);

gulp.task("clean", "Cleans the compiler output, declare files, and tests", [], () => {
return del([builtDirectory]);
return del([builtDirectory, processDiagnosticMessagesJs, generatedDiagnosticMessagesJSON, diagnosticInfoMapTs]);
});

gulp.task("useDebugMode", /*help*/ false, [], (done) => { useDebugMode = true; done(); });
Expand Down
3 changes: 3 additions & 0 deletions Jakefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,9 @@ task("default", ["local"]);
desc("Cleans the compiler output, declare files, and tests");
task("clean", function () {
jake.rmRf(builtDirectory);
jake.rmRf(processDiagnosticMessagesJs);
jake.rmRf(generatedDiagnosticMessagesJSON);
jake.rmRf(diagnosticInfoMapTs);
});

// Generate Markdown spec
Expand Down
20 changes: 1 addition & 19 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2025,7 +2025,7 @@ namespace ts {
export function getFileNamesFromConfigSpecs(spec: ConfigFileSpecs, basePath: string, options: CompilerOptions, host: ParseConfigHost, extraFileExtensions: ReadonlyArray<JsFileExtensionInfo> = []): ExpandResult {
basePath = normalizePath(basePath);

const keyMapper = host.useCaseSensitiveFileNames ? caseSensitiveKeyMapper : caseInsensitiveKeyMapper;
const keyMapper = host.useCaseSensitiveFileNames ? identity : toLowerCase;

// Literal file names (provided via the "files" array in tsconfig.json) are stored in a
// file map with a possibly case insensitive key. We use this map later when when including
Expand Down Expand Up @@ -2232,24 +2232,6 @@ namespace ts {
}
}

/**
* Gets a case sensitive key.
*
* @param key The original key.
*/
function caseSensitiveKeyMapper(key: string) {
return key;
}

/**
* Gets a case insensitive key.
*
* @param key The original key.
*/
function caseInsensitiveKeyMapper(key: string) {
return key.toLowerCase();
}

/**
* Produces a cleaned version of compiler options with personally identifiying info (aka, paths) removed.
* Also converts enum values back to strings.
Expand Down
51 changes: 48 additions & 3 deletions src/compiler/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ namespace ts {

/* @internal */
namespace ts {
export const emptyArray: never[] = [] as never[];

export function closeFileWatcher(watcher: FileWatcher) {
watcher.close();
}

/** Create a MapLike with good performance. */
function createDictionaryObject<T>(): MapLike<T> {
const map = Object.create(/*prototype*/ null); // tslint:disable-line:no-null-keyword
Expand Down Expand Up @@ -832,6 +838,44 @@ namespace ts {
return result;
}

/**
* Enumreates on two sorted arrays newItems and oldItems by invoking
* - inserted on items that are present in newItems but not in oldItems
* - deleted on items that are present in oldItems but not in newIterms
* - unchanged if provided on items that are present in both newItems and oldItems
*/
export function enumerateInsertsAndDeletes<T, U>(newItems: ReadonlyArray<T>, oldItems: ReadonlyArray<U>, comparer: (a: T, b: U) => Comparison, inserted: (newItem: T) => void, deleted: (oldItem: U) => void, unchanged?: (oldItem: U, newItem: T) => void) {
unchanged = unchanged || noop;
let newIndex = 0;
let oldIndex = 0;
const newLen = newItems.length;
const oldLen = oldItems.length;
while (newIndex < newLen && oldIndex < oldLen) {
const newItem = newItems[newIndex];
const oldItem = oldItems[oldIndex];
const compareResult = comparer(newItem, oldItem);
if (compareResult === Comparison.LessThan) {
inserted(newItem);
newIndex++;
}
else if (compareResult === Comparison.GreaterThan) {
deleted(oldItem);
oldIndex++;
}
else {
unchanged(oldItem, newItem);
newIndex++;
oldIndex++;
}
}
while (newIndex < newLen) {
inserted(newItems[newIndex++]);
}
while (oldIndex < oldLen) {
deleted(oldItems[oldIndex++]);
}
}

export function sum<T extends Record<K, number>, K extends string>(array: ReadonlyArray<T>, prop: K): number {
let result = 0;
for (const v of array) {
Expand Down Expand Up @@ -1398,6 +1442,9 @@ namespace ts {
/** Returns its argument. */
export function identity<T>(x: T) { return x; }

/** Returns the lower case string */
export function toLowerCase(x: string) { return x.toLowerCase(); }

/** Throws an error because a function is not implemented. */
export function notImplemented(): never {
throw new Error("Not implemented");
Expand Down Expand Up @@ -2871,9 +2918,7 @@ namespace ts {

export type GetCanonicalFileName = (fileName: string) => string;
export function createGetCanonicalFileName(useCaseSensitiveFileNames: boolean): GetCanonicalFileName {
return useCaseSensitiveFileNames
? ((fileName) => fileName)
: ((fileName) => fileName.toLowerCase());
return useCaseSensitiveFileNames ? identity : toLowerCase;
}

/**
Expand Down
Loading