Allow --withIncrementalVerifier to pass on commandline to tsserver to run incremental verification

This commit is contained in:
Sheetal Nandi
2024-03-25 16:16:28 -07:00
parent d4b8ff6918
commit c7e47ca80e
17 changed files with 55 additions and 20 deletions
+3 -3
View File
@@ -1,3 +1,6 @@
import {
incrementalVerifier,
} from "../incrementalVerifier/verifier";
import * as collections from "./_namespaces/collections";
import * as fakes from "./_namespaces/fakes";
import {
@@ -11,9 +14,6 @@ import {
} from "./_namespaces/ts";
import * as vfs from "./_namespaces/vfs";
import * as vpath from "./_namespaces/vpath";
import {
incrementalVerifier,
} from "./incrementalUtils";
import {
patchServiceForStateBaseline,
} from "./projectServiceStateLogger";
+2 -1
View File
@@ -13,7 +13,8 @@
{ "path": "../jsTyping" },
{ "path": "../server" },
{ "path": "../typingsInstallerCore" },
{ "path": "../deprecatedCompat" }
{ "path": "../deprecatedCompat" },
{ "path": "../incrementalVerifier" }
],
"include": ["**/*"]
@@ -0,0 +1,4 @@
/* Generated file to emulate the ts.server namespace. */
export * from "../../jsTyping/_namespaces/ts.server";
export * from "../../server/_namespaces/ts.server";
@@ -0,0 +1,9 @@
/* Generated file to emulate the ts namespace. */
export * from "../../compiler/_namespaces/ts";
export * from "../../jsTyping/_namespaces/ts";
export * from "../../services/_namespaces/ts";
export * from "../../server/_namespaces/ts";
export * from "../verifier";
import * as server from "./ts.server";
export { server };
+10
View File
@@ -0,0 +1,10 @@
{
"extends": "../tsconfig-base",
"references": [
{ "path": "../compiler" },
{ "path": "../jsTyping" },
{ "path": "../services" },
{ "path": "../server" }
],
"include": ["**/*"]
}
@@ -1,5 +1,6 @@
import * as ts from "./_namespaces/ts";
/** @internal */
export function reportDocumentRegistryStats(documentRegistry: ts.DocumentRegistry) {
const str: string[] = [];
documentRegistry.getBuckets().forEach((bucketEntries, key) => {
@@ -193,12 +194,14 @@ function getProgramStructure(program: ts.Program | undefined) {
return baseline.join("\n");
}
/** @internal */
export function verifyProgramStructure(expectedProgram: ts.Program, actualProgram: ts.Program, projectName: string) {
const actual = getProgramStructure(actualProgram);
const expected = getProgramStructure(expectedProgram);
ts.Debug.assert(actual === expected, `Program verification:: ${projectName}`);
}
/** @internal */
export function verifyResolutionCache(
actual: ts.ResolutionCache,
actualProgram: ts.Program,
@@ -583,11 +586,13 @@ function onProjectCreation(project: ts.server.Project) {
(project as ts.ResolutionCacheHost).afterResolveSingleModuleNameWithoutWatching = afterResolveSingleModuleNameWithoutWatching;
}
/** @internal */
export interface IncrementalVerifierCallbacks {
beforeVerification?(): any;
afterVerification?(dataFromBefore: any): void;
}
/** @internal */
export function incrementalVerifier(service: ts.server.ProjectService) {
service.verifyDocumentRegistry = withIncrementalVerifierCallbacks(service, verifyDocumentRegistry);
service.verifyProgram = withIncrementalVerifierCallbacks(service, verifyProgram);
+1
View File
@@ -15,6 +15,7 @@
{ "path": "../server" },
{ "path": "../typingsInstallerCore" },
{ "path": "../deprecatedCompat" },
{ "path": "../incrementalVerifier" },
{ "path": "../harness" }
],
"include": ["**/*"]
+1 -1
View File
@@ -1,7 +1,7 @@
import {
verifyProgramStructure,
verifyResolutionCache,
} from "../../../harness/incrementalUtils";
} from "../../../incrementalVerifier/verifier";
import {
patchHostForBuildInfoReadWrite,
} from "../../_namespaces/fakes";
+3 -3
View File
@@ -1,6 +1,3 @@
import {
incrementalVerifier,
} from "../../../harness/incrementalUtils";
import {
patchServiceForStateBaseline,
} from "../../../harness/projectServiceStateLogger";
@@ -8,6 +5,9 @@ import {
createLoggerWithInMemoryLogs,
LoggerWithInMemoryLogs,
} from "../../../harness/tsserverLogger";
import {
incrementalVerifier,
} from "../../../incrementalVerifier/verifier";
import * as Harness from "../../_namespaces/Harness";
import * as ts from "../../_namespaces/ts";
import {
@@ -1,9 +1,9 @@
import {
incrementalVerifier,
} from "../../../../harness/incrementalUtils";
import {
createHasErrorMessageLogger,
} from "../../../../harness/tsserverLogger";
import {
incrementalVerifier,
} from "../../../../incrementalVerifier/verifier";
import * as Harness from "../../../_namespaces/Harness";
import * as ts from "../../../_namespaces/ts";
import {
@@ -1,9 +1,9 @@
import {
IncrementalVerifierCallbacks,
} from "../../../harness/incrementalUtils";
import {
LoggerWithInMemoryLogs,
} from "../../../harness/tsserverLogger";
import {
IncrementalVerifierCallbacks,
} from "../../../incrementalVerifier/verifier";
import * as ts from "../../_namespaces/ts";
import {
jsonToReadableText,
@@ -1,6 +1,6 @@
import {
reportDocumentRegistryStats,
} from "../../../harness/incrementalUtils";
} from "../../../incrementalVerifier/verifier";
import * as ts from "../../_namespaces/ts";
import {
jsonToReadableText,
+3 -3
View File
@@ -2,13 +2,13 @@ import {
expect,
} from "chai";
import {
incrementalVerifier,
} from "../../../harness/incrementalUtils";
import {
createHasErrorMessageLogger,
nullLogger,
} from "../../../harness/tsserverLogger";
import {
incrementalVerifier,
} from "../../../incrementalVerifier/verifier";
import * as Harness from "../../_namespaces/Harness";
import * as ts from "../../_namespaces/ts";
+1
View File
@@ -7,6 +7,7 @@
{ "path": "./deprecatedCompat" },
{ "path": "./executeCommandLine" },
{ "path": "./harness" },
{ "path": "./incrementalVerifier" },
{ "path": "./jsTyping" },
{ "path": "./server" },
{ "path": "./services" },
+3 -1
View File
@@ -8,6 +8,7 @@ import {
FileWatcher,
getDirectoryPath,
getRootLength,
incrementalVerifier,
LanguageServiceMode,
MapLike,
noop,
@@ -30,7 +31,6 @@ import {
StartInput,
StartSessionOptions,
} from "./common";
interface LogOptions {
file?: string;
detailLevel?: ts.server.LogLevel;
@@ -589,6 +589,7 @@ function startNodeSession(options: StartSessionOptions, logger: ts.server.Logger
logger,
canUseEvents: true,
typesMapLocation,
incrementalVerifier: withIncrementalVerifier ? incrementalVerifier : undefined,
});
this.eventPort = eventPort;
@@ -689,6 +690,7 @@ function startNodeSession(options: StartSessionOptions, logger: ts.server.Logger
const validateDefaultNpmLocation = ts.server.hasArgument(ts.server.Arguments.ValidateDefaultNpmLocation);
const disableAutomaticTypingAcquisition = ts.server.hasArgument("--disableAutomaticTypingAcquisition");
const useNodeIpc = ts.server.hasArgument("--useNodeIpc");
const withIncrementalVerifier = ts.server.hasArgument("--withIncrementalVerifier");
const telemetryEnabled = ts.server.hasArgument(ts.server.Arguments.EnableTelemetry);
const commandLineTraceDir = ts.server.findArgument("--traceDirectory");
const traceDir = commandLineTraceDir
+1
View File
@@ -4,5 +4,6 @@ export * from "../../compiler/_namespaces/ts";
export * from "../../jsTyping/_namespaces/ts";
export * from "../../services/_namespaces/ts";
export * from "../../server/_namespaces/ts";
export * from "../../incrementalVerifier/_namespaces/ts";
import * as server from "./ts.server";
export { server };
+2 -1
View File
@@ -6,7 +6,8 @@
{ "path": "../compiler" },
{ "path": "../jsTyping" },
{ "path": "../services" },
{ "path": "../server" }
{ "path": "../server" },
{ "path": "../incrementalVerifier" }
],
"include": ["**/*"]
}