diff --git a/extensions/typescript-language-features/src/languageFeatures/diagnostics.ts b/extensions/typescript-language-features/src/languageFeatures/diagnostics.ts index 5981e63ea6e..515ee7889fb 100644 --- a/extensions/typescript-language-features/src/languageFeatures/diagnostics.ts +++ b/extensions/typescript-language-features/src/languageFeatures/diagnostics.ts @@ -154,7 +154,6 @@ export class DiagnosticsManager extends Disposable { private readonly _settings = new DiagnosticSettings(); private readonly _currentDiagnostics: vscode.DiagnosticCollection; private readonly _pendingUpdates: ResourceMap; - private readonly _telemetryReporter: TelemetryReporter; private readonly _updateDelay = 50; @@ -168,7 +167,30 @@ export class DiagnosticsManager extends Disposable { this._pendingUpdates = new ResourceMap(undefined, { onCaseInsensitiveFileSystem }); this._currentDiagnostics = this._register(vscode.languages.createDiagnosticCollection(owner)); - this._telemetryReporter = telemetryReporter; + this._register(vscode.workspace.onDidOpenTextDocument((document) => { + const diagnostics = this.getDiagnostics(document.uri); + const diagnoticCodes = diagnostics.reduce(function (result: number[], d: vscode.Diagnostic) { + const code = d.code; + if (typeof code === 'string' || typeof code === 'number') { + result.push(Number(code)); + } else if (code !== undefined) { + result.push(Number(code.value)); + } + return result; + }, []).sort(); + /* __GDPR__ + "typescript.diagnostics" : { + "owner": "@aiday-mar", + "diagnosticCodes" : { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" }, + "${include}": [ + "${TypeScriptCommonProperties}" + ] + } + */ + telemetryReporter.logTelemetry('typescript.diagnostics', { + diagnoticCodes: diagnoticCodes.join(', ') + }); + })); } public override dispose() { @@ -242,29 +264,7 @@ export class DiagnosticsManager extends Disposable { } public getDiagnostics(file: vscode.Uri): ReadonlyArray { - const diagnostics = this._currentDiagnostics.get(file) || []; - const diagnoticCodes = diagnostics.reduce(function (result: number[], d: vscode.Diagnostic) { - const code = d.code; - if (typeof code === 'string' || typeof code === 'number') { - result.push(Number(code)); - } else if (code !== undefined) { - result.push(Number(code.value)); - } - return result; - }, []).sort(); - /* __GDPR__ - "typescript.diagnostics" : { - "owner": "@aiday-mar", - "diagnosticCodes" : { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" }, - "${include}": [ - "${TypeScriptCommonProperties}" - ] - } - */ - this._telemetryReporter.logTelemetry('typescript.diagnostics', { - diagnoticCodes: diagnoticCodes.join(', ') - }); - return diagnostics; + return this._currentDiagnostics.get(file) || []; } private scheduleDiagnosticsUpdate(file: vscode.Uri) { diff --git a/extensions/typescript-language-features/src/typescriptServiceClient.ts b/extensions/typescript-language-features/src/typescriptServiceClient.ts index c165f82db40..e9e303e5b4f 100644 --- a/extensions/typescript-language-features/src/typescriptServiceClient.ts +++ b/extensions/typescript-language-features/src/typescriptServiceClient.ts @@ -468,6 +468,9 @@ export default class TypeScriptServiceClient extends Disposable implements IType } this.serviceExited(!this.isRestarting); this.isRestarting = false; + + // TODO: on handle exit, we need to send the typescript errors that we have accumulated + console.log('on handle exit'); }); handle.onEvent(event => this.dispatchEvent(event)); @@ -579,6 +582,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType }; } + // TODO: service exited will close the client service, is this the one that we need to monitor? private serviceExited(restart: boolean): void { this.loadingIndicator.reset();