mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Disable checkJS survey (#29830)
* Disable checkJS survey * Completely remove survey infrastructure * Re-instate the protocol part of SurveyReady
This commit is contained in:
parent
2dfb6202ed
commit
17d16d1bbb
@ -7,7 +7,6 @@ namespace ts.server {
|
||||
export const ProjectsUpdatedInBackgroundEvent = "projectsUpdatedInBackground";
|
||||
export const ProjectLoadingStartEvent = "projectLoadingStart";
|
||||
export const ProjectLoadingFinishEvent = "projectLoadingFinish";
|
||||
export const SurveyReady = "surveyReady";
|
||||
export const LargeFileReferencedEvent = "largeFileReferenced";
|
||||
export const ConfigFileDiagEvent = "configFileDiag";
|
||||
export const ProjectLanguageServiceStateEvent = "projectLanguageServiceState";
|
||||
@ -30,11 +29,6 @@ namespace ts.server {
|
||||
data: { project: Project; };
|
||||
}
|
||||
|
||||
export interface SurveyReady {
|
||||
eventName: typeof SurveyReady;
|
||||
data: { surveyId: string; };
|
||||
}
|
||||
|
||||
export interface LargeFileReferencedEvent {
|
||||
eventName: typeof LargeFileReferencedEvent;
|
||||
data: { file: string; fileSize: number; maxFileSize: number; };
|
||||
@ -146,7 +140,6 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
export type ProjectServiceEvent = LargeFileReferencedEvent |
|
||||
SurveyReady |
|
||||
ProjectsUpdatedInBackgroundEvent |
|
||||
ProjectLoadingStartEvent |
|
||||
ProjectLoadingFinishEvent |
|
||||
@ -518,9 +511,6 @@ namespace ts.server {
|
||||
/** Tracks projects that we have already sent telemetry for. */
|
||||
private readonly seenProjects = createMap<true>();
|
||||
|
||||
/** Tracks projects that we have already sent survey events for. */
|
||||
private readonly seenSurveyProjects = createMap<true>();
|
||||
|
||||
/*@internal*/
|
||||
readonly watchFactory: WatchFactory<WatchType, Project>;
|
||||
|
||||
@ -722,14 +712,6 @@ namespace ts.server {
|
||||
this.eventHandler(event);
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
sendSurveyReadyEvent(surveyId: string) {
|
||||
if (!this.eventHandler) {
|
||||
return;
|
||||
}
|
||||
this.eventHandler({ eventName: SurveyReady, data: { surveyId } });
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
sendLargeFileReferencedEvent(file: string, fileSize: number) {
|
||||
if (!this.eventHandler) {
|
||||
@ -1611,20 +1593,6 @@ namespace ts.server {
|
||||
return project;
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
sendSurveyReady(project: ExternalProject | ConfiguredProject): void {
|
||||
if (this.seenSurveyProjects.has(project.projectName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (project.getCompilerOptions().checkJs !== undefined) {
|
||||
const name = "checkJs";
|
||||
this.logger.info(`Survey ${name} is ready`);
|
||||
this.sendSurveyReadyEvent(name);
|
||||
this.seenSurveyProjects.set(project.projectName, true);
|
||||
}
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
sendProjectTelemetry(project: ExternalProject | ConfiguredProject): void {
|
||||
if (this.seenProjects.has(project.projectName)) {
|
||||
|
||||
@ -1431,7 +1431,6 @@ namespace ts.server {
|
||||
}
|
||||
this.projectService.sendProjectLoadingFinishEvent(this);
|
||||
this.projectService.sendProjectTelemetry(this);
|
||||
this.projectService.sendSurveyReady(this);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1627,7 +1626,6 @@ namespace ts.server {
|
||||
updateGraph() {
|
||||
const result = super.updateGraph();
|
||||
this.projectService.sendProjectTelemetry(this);
|
||||
this.projectService.sendSurveyReady(this);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -610,10 +610,6 @@ namespace ts.server {
|
||||
diagnostics: bakedDiags
|
||||
}, ConfigFileDiagEvent);
|
||||
break;
|
||||
case SurveyReady:
|
||||
const { surveyId } = event.data;
|
||||
this.event<protocol.SurveyReadyEventBody>({ surveyId }, SurveyReady);
|
||||
break;
|
||||
case ProjectLanguageServiceStateEvent: {
|
||||
const eventName: protocol.ProjectLanguageServiceStateEventName = ProjectLanguageServiceStateEvent;
|
||||
this.event<protocol.ProjectLanguageServiceStateEventBody>({
|
||||
|
||||
@ -109,7 +109,6 @@
|
||||
"unittests/tsserver/events/projectLanguageServiceState.ts",
|
||||
"unittests/tsserver/events/projectLoading.ts",
|
||||
"unittests/tsserver/events/projectUpdatedInBackground.ts",
|
||||
"unittests/tsserver/events/surveyReady.ts",
|
||||
"unittests/tsserver/externalProjects.ts",
|
||||
"unittests/tsserver/forceConsistentCasingInFileNames.ts",
|
||||
"unittests/tsserver/formatSettings.ts",
|
||||
|
||||
@ -1,111 +0,0 @@
|
||||
namespace ts.projectSystem {
|
||||
describe("unittests:: tsserver:: events:: SurveyReady", () => {
|
||||
function createSessionWithEventHandler(host: TestServerHost) {
|
||||
const { session, events: surveyEvents } = createSessionWithEventTracking<server.SurveyReady>(host, server.SurveyReady);
|
||||
|
||||
return { session, verifySurveyReadyEvent };
|
||||
|
||||
function verifySurveyReadyEvent(numberOfEvents: number) {
|
||||
assert.equal(surveyEvents.length, numberOfEvents);
|
||||
const expectedEvents = numberOfEvents === 0 ? [] : [{
|
||||
eventName: server.SurveyReady,
|
||||
data: { surveyId: "checkJs" }
|
||||
}];
|
||||
assert.deepEqual(surveyEvents, expectedEvents);
|
||||
}
|
||||
}
|
||||
|
||||
it("doesn't log an event when checkJs isn't set", () => {
|
||||
const projectRoot = "/user/username/projects/project";
|
||||
const file: File = {
|
||||
path: `${projectRoot}/src/file.ts`,
|
||||
content: "export var y = 10;"
|
||||
};
|
||||
const tsconfig: File = {
|
||||
path: `${projectRoot}/tsconfig.json`,
|
||||
content: JSON.stringify({ compilerOptions: {} }),
|
||||
};
|
||||
const host = createServerHost([file, tsconfig]);
|
||||
const { session, verifySurveyReadyEvent } = createSessionWithEventHandler(host);
|
||||
const service = session.getProjectService();
|
||||
openFilesForSession([file], session);
|
||||
checkNumberOfProjects(service, { configuredProjects: 1 });
|
||||
const project = service.configuredProjects.get(tsconfig.path)!;
|
||||
checkProjectActualFiles(project, [file.path, tsconfig.path]);
|
||||
|
||||
verifySurveyReadyEvent(0);
|
||||
});
|
||||
|
||||
it("logs an event when checkJs is set", () => {
|
||||
const projectRoot = "/user/username/projects/project";
|
||||
const file: File = {
|
||||
path: `${projectRoot}/src/file.ts`,
|
||||
content: "export var y = 10;"
|
||||
};
|
||||
const tsconfig: File = {
|
||||
path: `${projectRoot}/tsconfig.json`,
|
||||
content: JSON.stringify({ compilerOptions: { checkJs: true } }),
|
||||
};
|
||||
const host = createServerHost([file, tsconfig]);
|
||||
const { session, verifySurveyReadyEvent } = createSessionWithEventHandler(host);
|
||||
openFilesForSession([file], session);
|
||||
|
||||
verifySurveyReadyEvent(1);
|
||||
});
|
||||
|
||||
it("logs an event when checkJs is set, only the first time", () => {
|
||||
const projectRoot = "/user/username/projects/project";
|
||||
const file: File = {
|
||||
path: `${projectRoot}/src/file.ts`,
|
||||
content: "export var y = 10;"
|
||||
};
|
||||
const rando: File = {
|
||||
path: `/rando/calrissian.ts`,
|
||||
content: "export function f() { }"
|
||||
};
|
||||
const tsconfig: File = {
|
||||
path: `${projectRoot}/tsconfig.json`,
|
||||
content: JSON.stringify({ compilerOptions: { checkJs: true } }),
|
||||
};
|
||||
const host = createServerHost([file, tsconfig]);
|
||||
const { session, verifySurveyReadyEvent } = createSessionWithEventHandler(host);
|
||||
openFilesForSession([file], session);
|
||||
|
||||
verifySurveyReadyEvent(1);
|
||||
|
||||
closeFilesForSession([file], session);
|
||||
openFilesForSession([rando], session);
|
||||
openFilesForSession([file], session);
|
||||
|
||||
verifySurveyReadyEvent(1);
|
||||
});
|
||||
|
||||
it("logs an event when checkJs is set after closing and reopening", () => {
|
||||
const projectRoot = "/user/username/projects/project";
|
||||
const file: File = {
|
||||
path: `${projectRoot}/src/file.ts`,
|
||||
content: "export var y = 10;"
|
||||
};
|
||||
const rando: File = {
|
||||
path: `/rando/calrissian.ts`,
|
||||
content: "export function f() { }"
|
||||
};
|
||||
const tsconfig: File = {
|
||||
path: `${projectRoot}/tsconfig.json`,
|
||||
content: JSON.stringify({}),
|
||||
};
|
||||
const host = createServerHost([file, tsconfig]);
|
||||
const { session, verifySurveyReadyEvent } = createSessionWithEventHandler(host);
|
||||
openFilesForSession([file], session);
|
||||
|
||||
verifySurveyReadyEvent(0);
|
||||
|
||||
closeFilesForSession([file], session);
|
||||
openFilesForSession([rando], session);
|
||||
host.writeFile(tsconfig.path, JSON.stringify({ compilerOptions: { checkJs: true } }));
|
||||
openFilesForSession([file], session);
|
||||
|
||||
verifySurveyReadyEvent(1);
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -8357,7 +8357,6 @@ declare namespace ts.server {
|
||||
const ProjectsUpdatedInBackgroundEvent = "projectsUpdatedInBackground";
|
||||
const ProjectLoadingStartEvent = "projectLoadingStart";
|
||||
const ProjectLoadingFinishEvent = "projectLoadingFinish";
|
||||
const SurveyReady = "surveyReady";
|
||||
const LargeFileReferencedEvent = "largeFileReferenced";
|
||||
const ConfigFileDiagEvent = "configFileDiag";
|
||||
const ProjectLanguageServiceStateEvent = "projectLanguageServiceState";
|
||||
@ -8382,12 +8381,6 @@ declare namespace ts.server {
|
||||
project: Project;
|
||||
};
|
||||
}
|
||||
interface SurveyReady {
|
||||
eventName: typeof SurveyReady;
|
||||
data: {
|
||||
surveyId: string;
|
||||
};
|
||||
}
|
||||
interface LargeFileReferencedEvent {
|
||||
eventName: typeof LargeFileReferencedEvent;
|
||||
data: {
|
||||
@ -8472,7 +8465,7 @@ declare namespace ts.server {
|
||||
interface OpenFileInfo {
|
||||
readonly checkJs: boolean;
|
||||
}
|
||||
type ProjectServiceEvent = LargeFileReferencedEvent | SurveyReady | ProjectsUpdatedInBackgroundEvent | ProjectLoadingStartEvent | ProjectLoadingFinishEvent | ConfigFileDiagEvent | ProjectLanguageServiceStateEvent | ProjectInfoTelemetryEvent | OpenFileInfoTelemetryEvent;
|
||||
type ProjectServiceEvent = LargeFileReferencedEvent | ProjectsUpdatedInBackgroundEvent | ProjectLoadingStartEvent | ProjectLoadingFinishEvent | ConfigFileDiagEvent | ProjectLanguageServiceStateEvent | ProjectInfoTelemetryEvent | OpenFileInfoTelemetryEvent;
|
||||
type ProjectServiceEventHandler = (event: ProjectServiceEvent) => void;
|
||||
interface SafeList {
|
||||
[name: string]: {
|
||||
@ -8589,8 +8582,6 @@ declare namespace ts.server {
|
||||
readonly syntaxOnly?: boolean;
|
||||
/** Tracks projects that we have already sent telemetry for. */
|
||||
private readonly seenProjects;
|
||||
/** Tracks projects that we have already sent survey events for. */
|
||||
private readonly seenSurveyProjects;
|
||||
constructor(opts: ProjectServiceOptions);
|
||||
toPath(fileName: string): Path;
|
||||
private loadTypesMap;
|
||||
|
||||
@ -1 +1 @@
|
||||
Subproject commit 40bdb4eadabc9fbed7d83e3f26817a931c0763b6
|
||||
Subproject commit 6b9706810b55af326a93b9aa59cb17815a30bb32
|
||||
@ -1 +1 @@
|
||||
Subproject commit 67f1c4877ee1090b66d468a847caccca411a6f82
|
||||
Subproject commit 6e0de0812231c3a48387d398d092418749aa39f1
|
||||
@ -1 +1 @@
|
||||
Subproject commit 10282ea20648b465caec6448849f24fc34e1ba3e
|
||||
Subproject commit a28f44f613276446fb764dec7fab38b7cff8a07c
|
||||
Loading…
x
Reference in New Issue
Block a user