Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 6 additions & 6 deletions src/compiler/sys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ function createDynamicPriorityPollingWatchFile(host: {
return queue;
}

function pollPollingIntervalQueue(queue: PollingIntervalQueue) {
function pollPollingIntervalQueue(_timeoutType: string, queue: PollingIntervalQueue) {
queue.pollIndex = pollQueue(queue, queue.pollingInterval, queue.pollIndex, pollingChunkSize[queue.pollingInterval]);
// Set the next polling index and timeout
if (queue.length) {
Expand All @@ -298,12 +298,12 @@ function createDynamicPriorityPollingWatchFile(host: {
}
}

function pollLowPollingIntervalQueue(queue: PollingIntervalQueue) {
function pollLowPollingIntervalQueue(_timeoutType: string, queue: PollingIntervalQueue) {
// Always poll complete list of changedFilesInLastPoll
pollQueue(changedFilesInLastPoll, PollingInterval.Low, /*pollIndex*/ 0, changedFilesInLastPoll.length);

// Finally do the actual polling of the queue
pollPollingIntervalQueue(queue);
pollPollingIntervalQueue(_timeoutType, queue);
// Schedule poll if there are files in changedFilesInLastPoll but no files in the actual queue
// as pollPollingIntervalQueue wont schedule for next poll
if (!queue.pollScheduled && changedFilesInLastPoll.length) {
Expand Down Expand Up @@ -374,7 +374,7 @@ function createDynamicPriorityPollingWatchFile(host: {
}

function scheduleNextPoll(pollingInterval: PollingInterval) {
pollingIntervalQueue(pollingInterval).pollScheduled = host.setTimeout(pollingInterval === PollingInterval.Low ? pollLowPollingIntervalQueue : pollPollingIntervalQueue, pollingInterval, pollingIntervalQueue(pollingInterval));
pollingIntervalQueue(pollingInterval).pollScheduled = host.setTimeout(pollingInterval === PollingInterval.Low ? pollLowPollingIntervalQueue : pollPollingIntervalQueue, pollingInterval, pollingInterval === PollingInterval.Low ? "pollLowPollingIntervalQueue" : "pollPollingIntervalQueue", pollingIntervalQueue(pollingInterval));
}
}

Expand Down Expand Up @@ -465,7 +465,7 @@ function createFixedChunkSizePollingWatchFile(host: {

function scheduleNextPoll() {
if (!watchedFiles.length || pollScheduled) return;
pollScheduled = host.setTimeout(pollQueue, PollingInterval.High);
pollScheduled = host.setTimeout(pollQueue, PollingInterval.High, "pollQueue");
}
}

Expand Down Expand Up @@ -713,7 +713,7 @@ function createDirectoryWatcherSupportingRecursive({
clearTimeout(timerToUpdateChildWatches);
timerToUpdateChildWatches = undefined;
}
timerToUpdateChildWatches = setTimeout(onTimerToUpdateChildWatches, 1000);
timerToUpdateChildWatches = setTimeout(onTimerToUpdateChildWatches, 1000, "timerToUpdateChildWatches");
}

function onTimerToUpdateChildWatches() {
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/tsbuildPublic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2258,10 +2258,10 @@ function scheduleBuildInvalidatedProject<T extends BuilderProgram>(state: Soluti
if (state.timerToBuildInvalidatedProject) {
hostWithWatch.clearTimeout(state.timerToBuildInvalidatedProject);
}
state.timerToBuildInvalidatedProject = hostWithWatch.setTimeout(buildNextInvalidatedProject, time, state, changeDetected);
state.timerToBuildInvalidatedProject = hostWithWatch.setTimeout(buildNextInvalidatedProject, time, "timerToBuildInvalidatedProject", state, changeDetected);
}

function buildNextInvalidatedProject<T extends BuilderProgram>(state: SolutionBuilderState<T>, changeDetected: boolean) {
function buildNextInvalidatedProject<T extends BuilderProgram>(_timeoutType: string, state: SolutionBuilderState<T>, changeDetected: boolean) {
performance.mark("SolutionBuilder::beforeBuild");
const buildOrder = buildNextInvalidatedProjectWorker(state, changeDetected);
performance.mark("SolutionBuilder::afterBuild");
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/watchPublic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ export function createWatchProgram<T extends BuilderProgram>(host: WatchCompiler
}
const pending = clearInvalidateResolutionsOfFailedLookupLocations();
writeLog(`Scheduling invalidateFailedLookup${pending ? ", Cancelled earlier one" : ""}`);
timerToInvalidateFailedLookupResolutions = host.setTimeout(invalidateResolutionsOfFailedLookup, 250);
timerToInvalidateFailedLookupResolutions = host.setTimeout(invalidateResolutionsOfFailedLookup, 250, "timerToInvalidateFailedLookupResolutions");
}

function invalidateResolutionsOfFailedLookup() {
Expand All @@ -825,7 +825,7 @@ export function createWatchProgram<T extends BuilderProgram>(host: WatchCompiler
host.clearTimeout(timerToUpdateProgram);
}
writeLog("Scheduling update");
timerToUpdateProgram = host.setTimeout(updateProgramWithWatchStatus, 250);
timerToUpdateProgram = host.setTimeout(updateProgramWithWatchStatus, 250, "timerToUpdateProgram");
}

function scheduleProgramReload() {
Expand Down
20 changes: 10 additions & 10 deletions src/server/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,8 @@ export function formatMessage<T extends protocol.Message>(msg: T, logger: Logger
* Allows to schedule next step in multistep operation
*/
interface NextStep {
immediate(action: () => void): void;
delay(ms: number, action: () => void): void;
immediate(actionType: string, action: () => void): void;
delay(actionType: string, ms: number, action: () => void): void;
}

/**
Expand Down Expand Up @@ -371,22 +371,22 @@ class MultistepOperation implements NextStep {
this.setImmediateId(undefined);
}

public immediate(action: () => void) {
public immediate(actionType: string, action: () => void) {
const requestId = this.requestId!;
Debug.assert(requestId === this.operationHost.getCurrentRequestId(), "immediate: incorrect request id");
this.setImmediateId(this.operationHost.getServerHost().setImmediate(() => {
this.immediateId = undefined;
this.operationHost.executeWithRequestId(requestId, () => this.executeAction(action));
}));
}, actionType));
}

public delay(ms: number, action: () => void) {
public delay(actionType: string, ms: number, action: () => void) {
const requestId = this.requestId!;
Debug.assert(requestId === this.operationHost.getCurrentRequestId(), "delay: incorrect request id");
this.setTimerHandle(this.operationHost.getServerHost().setTimeout(() => {
this.timerHandle = undefined;
this.operationHost.executeWithRequestId(requestId, () => this.executeAction(action));
}, ms));
}, ms, actionType));
}

private executeAction(action: (next: NextStep) => void) {
Expand Down Expand Up @@ -1271,7 +1271,7 @@ export class Session<TMessage = string> implements EventSender {
const goNext = () => {
index++;
if (checkList.length > index) {
next.delay(followMs, checkOne);
next.delay("checkOne", followMs, checkOne);
}
};
const checkOne = () => {
Expand Down Expand Up @@ -1308,7 +1308,7 @@ export class Session<TMessage = string> implements EventSender {
goNext();
return;
}
next.immediate(() => {
next.immediate("semanticCheck", () => {
this.semanticCheck(fileName, project);
if (this.changeSeq !== seq) {
return;
Expand All @@ -1318,15 +1318,15 @@ export class Session<TMessage = string> implements EventSender {
goNext();
return;
}
next.immediate(() => {
next.immediate("suggestionCheck", () => {
this.suggestionCheck(fileName, project);
goNext();
});
});
};

if (checkList.length > index && this.changeSeq === seq) {
next.delay(ms, checkOne);
next.delay("checkOne", ms, checkOne);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/server/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class ThrottledOperations {
this.host.clearTimeout(pendingTimeout);
}
// schedule new operation, pass arguments
this.pendingTimeouts.set(operationId, this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb));
this.pendingTimeouts.set(operationId, this.host.setTimeout(ThrottledOperations.run, delay, operationId, this, cb));
if (this.logger) {
this.logger.info(`Scheduled: ${operationId}${pendingTimeout ? ", Cancelled earlier one" : ""}`);
}
Expand All @@ -47,7 +47,7 @@ export class ThrottledOperations {
return this.pendingTimeouts.delete(operationId);
}

private static run(self: ThrottledOperations, operationId: string, cb: () => void) {
private static run(operationId: string, self: ThrottledOperations, cb: () => void) {
perfLogger?.logStartScheduledOperation(operationId);
self.pendingTimeouts.delete(operationId);
if (self.logger) {
Expand Down
13 changes: 4 additions & 9 deletions src/testRunner/unittests/tsbuildWatch/configFileErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@ import { verifyTscWatch } from "../tscWatch/helpers";
import {
createWatchedSystem,
libFile,
TestServerHost,
} from "../virtualFileSystemWithWatch";

describe("unittests:: tsbuildWatch:: watchMode:: configFileErrors:: reports syntax errors in config file", () => {
function build(sys: TestServerHost) {
sys.checkTimeoutQueueLengthAndRun(1); // build the project
sys.checkTimeoutQueueLength(0);
}
verifyTscWatch({
scenario: "configFileErrors",
subScenario: "reports syntax errors in config file",
Expand Down Expand Up @@ -41,25 +36,25 @@ describe("unittests:: tsbuildWatch:: watchMode:: configFileErrors:: reports synt
caption: "reports syntax errors after change to config file",
edit: sys => sys.replaceFileText(`/user/username/projects/myproject/tsconfig.json`, ",", `,
"declaration": true,`),
timeouts: build,
timeouts: sys => sys.runQueuedTimeoutCallbacks(), // build the project
},
{
caption: "reports syntax errors after change to ts file",
edit: sys => sys.replaceFileText(`/user/username/projects/myproject/a.ts`, "foo", "fooBar"),
timeouts: build,
timeouts: sys => sys.runQueuedTimeoutCallbacks(), // build the project
},
{
caption: "reports error when there is no change to tsconfig file",
edit: sys => sys.replaceFileText(`/user/username/projects/myproject/tsconfig.json`, "", ""),
timeouts: build,
timeouts: sys => sys.runQueuedTimeoutCallbacks(), // build the project
},
{
caption: "builds after fixing config file errors",
edit: sys => sys.writeFile(`/user/username/projects/myproject/tsconfig.json`, JSON.stringify({
compilerOptions: { composite: true, declaration: true },
files: ["a.ts", "b.ts"]
})),
timeouts: build,
timeouts: sys => sys.runQueuedTimeoutCallbacks(), // build the project
}
]
});
Expand Down
10 changes: 3 additions & 7 deletions src/testRunner/unittests/tsbuildWatch/demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ describe("unittests:: tsbuildWatch:: watchMode:: with demo project", () => {
caption: "Fix error",
edit: sys => sys.writeFile(coreFiles[0].path, coreFiles[0].content),
timeouts: sys => {
sys.checkTimeoutQueueLengthAndRun(1); // build core
sys.checkTimeoutQueueLengthAndRun(1); // build animals, zoo and solution
sys.checkTimeoutQueueLength(0);
sys.runQueuedTimeoutCallbacks(); // build core
sys.runQueuedTimeoutCallbacks(); // build animals, zoo and solution
},
}
]
Expand All @@ -80,10 +79,7 @@ ${coreFiles[1].content}`);
import * as A from '../animals';
${coreFiles[1].content}`),
// build core
timeouts: sys => {
sys.checkTimeoutQueueLengthAndRun(1);
sys.checkTimeoutQueueLength(0);
},
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
}
]
});
Expand Down
5 changes: 1 addition & 4 deletions src/testRunner/unittests/tsbuildWatch/moduleResolution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,7 @@ describe("unittests:: tsbuildWatch:: watchMode:: moduleResolution", () => {
{
caption: "Append text",
edit: sys => sys.appendFile(`/user/username/projects/myproject/project1/index.ts`, "const bar = 10;"),
timeouts: sys => {
sys.checkTimeoutQueueLengthAndRun(1); // build project1 and solution
sys.checkTimeoutQueueLength(0);
}
timeouts: sys => sys.runQueuedTimeoutCallbacks(), // build project1 and solution
},
]
});
Expand Down
10 changes: 2 additions & 8 deletions src/testRunner/unittests/tsbuildWatch/noEmit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,13 @@ describe("unittests:: tsbuildWatch:: watchMode:: with noEmit", () => {
caption: "No change",
edit: sys => sys.writeFile(`/user/username/projects/myproject/a.js`, sys.readFile(`/user/username/projects/myproject/a.js`)!),
// build project
timeouts: sys => {
sys.checkTimeoutQueueLengthAndRun(1);
sys.checkTimeoutQueueLength(0);
},
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
},
{
caption: "change",
edit: sys => sys.writeFile(`/user/username/projects/myproject/a.js`, "const x = 10;"),
// build project
timeouts: sys => {
sys.checkTimeoutQueueLengthAndRun(1);
sys.checkTimeoutQueueLength(0);
},
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
},
],
baselineIncremental: true
Expand Down
10 changes: 2 additions & 8 deletions src/testRunner/unittests/tsbuildWatch/noEmitOnError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,15 @@ describe("unittests:: tsbuildWatch:: watchMode:: with noEmitOnError", () => {
caption,
edit: sys => sys.writeFile(`/user/username/projects/noEmitOnError/src/main.ts`, content),
// build project
timeouts: sys => {
sys.checkTimeoutQueueLengthAndRun(1);
sys.checkTimeoutQueueLength(0);
},
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
};
}

const noChange: TscWatchCompileChange = {
caption: "No change",
edit: sys => sys.writeFile(`/user/username/projects/noEmitOnError/src/main.ts`, sys.readFile(`/user/username/projects/noEmitOnError/src/main.ts`)!),
// build project
timeouts: sys => {
sys.checkTimeoutQueueLengthAndRun(1);
sys.checkTimeoutQueueLength(0);
},
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
};
verifyTscWatch({
scenario: "noEmitOnError",
Expand Down
Loading