Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Make useFsEvents as default strategy for the watching#50366

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
sheetalkamat merged 10 commits intomainfromdefaultFsWatch
Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
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
PrevPrevious commit
NextNext commit
Some refactoring
  • Loading branch information
@sheetalkamat
sheetalkamat committedAug 18, 2022
commit4d753d30ce4e28c7f259313ae11a95bfffd207dd
57 changes: 24 additions & 33 deletionssrc/compiler/sys.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,8 +35,7 @@ namespace ts {

export type FileWatcherCallback = (fileName: string, eventKind: FileWatcherEventKind, modifiedTime?: Date) => void;
export type DirectoryWatcherCallback = (fileName: string) => void;
/*@internal*/
export interface WatchedFile {
interface WatchedFile {
readonly fileName: string;
readonly callback: FileWatcherCallback;
mtime: Date;
Expand DownExpand Up@@ -81,8 +80,7 @@ namespace ts {
/* @internal */
export let unchangedPollThresholds = createPollingIntervalBasedLevels(defaultChunkLevels);

/* @internal */
export function setCustomPollingValues(system: System) {
function setCustomPollingValues(system: System) {
if (!system.getEnvironmentVariable) {
return;
}
Expand DownExpand Up@@ -189,31 +187,28 @@ namespace ts {
}
}

/* @internal */
export function createDynamicPriorityPollingWatchFile(host: {
interface WatchedFileWithUnchangedPolls extends WatchedFileWithIsClosed {
unchangedPolls: number;
}
function createDynamicPriorityPollingWatchFile(host: {
getModifiedTime: NonNullable<System["getModifiedTime"]>;
setTimeout: NonNullable<System["setTimeout"]>;
}): HostWatchFile {
interface WatchedFile extends ts.WatchedFile {
isClosed?: boolean;
unchangedPolls: number;
}

interface PollingIntervalQueue extends Array<WatchedFile> {
interface PollingIntervalQueue extends Array<WatchedFileWithUnchangedPolls> {
pollingInterval: PollingInterval;
pollIndex: number;
pollScheduled: boolean;
}

const watchedFiles:WatchedFile[] = [];
const changedFilesInLastPoll:WatchedFile[] = [];
const watchedFiles:WatchedFileWithUnchangedPolls[] = [];
const changedFilesInLastPoll:WatchedFileWithUnchangedPolls[] = [];
const lowPollingIntervalQueue = createPollingIntervalQueue(PollingInterval.Low);
const mediumPollingIntervalQueue = createPollingIntervalQueue(PollingInterval.Medium);
const highPollingIntervalQueue = createPollingIntervalQueue(PollingInterval.High);
return watchFile;

function watchFile(fileName: string, callback: FileWatcherCallback, defaultPollingInterval: PollingInterval): FileWatcher {
const file:WatchedFile = {
const file:WatchedFileWithUnchangedPolls = {
fileName,
callback,
unchangedPolls: 0,
Expand All@@ -233,7 +228,7 @@ namespace ts {
}

function createPollingIntervalQueue(pollingInterval: PollingInterval): PollingIntervalQueue {
const queue = [] asWatchedFile[] as PollingIntervalQueue;
const queue = [] asWatchedFileWithUnchangedPolls[] as PollingIntervalQueue;
queue.pollingInterval = pollingInterval;
queue.pollIndex = 0;
queue.pollScheduled = false;
Expand DownExpand Up@@ -265,7 +260,7 @@ namespace ts {
}
}

function pollQueue(queue: (WatchedFile | undefined)[], pollingInterval: PollingInterval, pollIndex: number, chunkSize: number) {
function pollQueue(queue: (WatchedFileWithUnchangedPolls | undefined)[], pollingInterval: PollingInterval, pollIndex: number, chunkSize: number) {
return pollWatchedFileQueue(
host,
queue,
Expand All@@ -274,7 +269,7 @@ namespace ts {
onWatchFileStat
);

function onWatchFileStat(watchedFile:WatchedFile, pollIndex: number, fileChanged: boolean) {
function onWatchFileStat(watchedFile:WatchedFileWithUnchangedPolls, pollIndex: number, fileChanged: boolean) {
if (fileChanged) {
watchedFile.unchangedPolls = 0;
// Changed files go to changedFilesInLastPoll queue
Expand DownExpand Up@@ -311,12 +306,12 @@ namespace ts {
}
}

function addToPollingIntervalQueue(file:WatchedFile, pollingInterval: PollingInterval) {
function addToPollingIntervalQueue(file:WatchedFileWithUnchangedPolls, pollingInterval: PollingInterval) {
pollingIntervalQueue(pollingInterval).push(file);
scheduleNextPollIfNotAlreadyScheduled(pollingInterval);
}

function addChangedFileToLowPollingIntervalQueue(file:WatchedFile) {
function addChangedFileToLowPollingIntervalQueue(file:WatchedFileWithUnchangedPolls) {
changedFilesInLastPoll.push(file);
scheduleNextPollIfNotAlreadyScheduled(PollingInterval.Low);
}
Expand DownExpand Up@@ -423,8 +418,7 @@ namespace ts {
}
}

/* @internal */
export function createSingleFileWatcherPerName(
function createSingleFileWatcherPerName(
watchFile: HostWatchFile,
useCaseSensitiveFileNames: boolean
): HostWatchFile {
Expand DownExpand Up@@ -474,8 +468,7 @@ namespace ts {
/**
* Returns true if file status changed
*/
/*@internal*/
export function onWatchedFileStat(watchedFile: WatchedFile, modifiedTime: Date): boolean {
function onWatchedFileStat(watchedFile: WatchedFile, modifiedTime: Date): boolean {
const oldTime = watchedFile.mtime.getTime();
const newTime = modifiedTime.getTime();
if (oldTime !== newTime) {
Expand DownExpand Up@@ -512,8 +505,7 @@ namespace ts {
curSysLog = logger;
}

/*@internal*/
export interface RecursiveDirectoryWatcherHost {
interface RecursiveDirectoryWatcherHost {
watchDirectory: HostWatchDirectory;
useCaseSensitiveFileNames: boolean;
getCurrentDirectory: System["getCurrentDirectory"];
Expand All@@ -529,8 +521,7 @@ namespace ts {
* that means if this is recursive watcher, watch the children directories as well
* (eg on OS that dont support recursive watch using fs.watch use fs.watchFile)
*/
/*@internal*/
export function createDirectoryWatcherSupportingRecursive({
function createDirectoryWatcherSupportingRecursive({
watchDirectory,
useCaseSensitiveFileNames,
getCurrentDirectory,
Expand DownExpand Up@@ -792,8 +783,7 @@ namespace ts {
Directory,
}

/*@internal*/
export function createFileWatcherCallback(callback: FsWatchCallback): FileWatcherCallback {
function createFileWatcherCallback(callback: FsWatchCallback): FileWatcherCallback {
return (_fileName, eventKind, modifiedTime) => callback(eventKind === FileWatcherEventKind.Changed ? "change" : "rename", "", modifiedTime);
}

Expand DownExpand Up@@ -854,7 +844,7 @@ namespace ts {
/*@internal*/
export interface CreateSystemWatchFunctions {
// Polling watch file
pollingWatchFile: HostWatchFile;
pollingWatchFileWorker: HostWatchFile;
// For dynamic polling watch file
getModifiedTime: NonNullable<System["getModifiedTime"]>;
setTimeout: NonNullable<System["setTimeout"]>;
Expand All@@ -878,7 +868,7 @@ namespace ts {

/*@internal*/
export function createSystemWatchFunctions({
pollingWatchFile,
pollingWatchFileWorker,
getModifiedTime,
setTimeout,
clearTimeout,
Expand All@@ -896,6 +886,7 @@ namespace ts {
inodeWatching,
sysLog,
}: CreateSystemWatchFunctions): { watchFile: HostWatchFile; watchDirectory: HostWatchDirectory; } {
const pollingWatchFile = createSingleFileWatcherPerName(pollingWatchFileWorker, useCaseSensitiveFileNames);
let dynamicPollingWatchFile: HostWatchFile | undefined;
let fixedChunkSizePollingWatchFile: HostWatchFile | undefined;
let nonPollingWatchFile: HostWatchFile | undefined;
Expand DownExpand Up@@ -1445,7 +1436,7 @@ namespace ts {
const fsSupportsRecursiveFsWatch = isNode4OrLater && (process.platform === "win32" || process.platform === "darwin");
const getCurrentDirectory = memoize(() => process.cwd());
const { watchFile, watchDirectory } = createSystemWatchFunctions({
pollingWatchFile: createSingleFileWatcherPerName(fsWatchFileWorker, useCaseSensitiveFileNames),
pollingWatchFileWorker:fsWatchFileWorker,
getModifiedTime,
setTimeout,
clearTimeout,
Expand Down
8 changes: 1 addition & 7 deletionssrc/harness/virtualFileSystemWithWatch.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -308,7 +308,6 @@ interface Array<T> { length: number; [n: number]: T; }`

export enum Tsc_WatchFile {
DynamicPolling = "DynamicPriorityPolling",
SingleFileWatcherPerName = "SingleFileWatcherPerName"
}

export enum Tsc_WatchDirectory {
Expand DownExpand Up@@ -386,12 +385,7 @@ interface Array<T> { length: number; [n: number]: T; }`
// We dont have polling watch file
// it is essentially fsWatch but lets get that separate from fsWatch and
// into watchedFiles for easier testing
pollingWatchFile: tscWatchFile === Tsc_WatchFile.SingleFileWatcherPerName ?
createSingleFileWatcherPerName(
this.watchFileWorker.bind(this),
this.useCaseSensitiveFileNames
) :
this.watchFileWorker.bind(this),
pollingWatchFileWorker: this.watchFileWorker.bind(this),
getModifiedTime: this.getModifiedTime.bind(this),
setTimeout: this.setTimeout.bind(this),
clearTimeout: this.clearTimeout.bind(this),
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp