sending diagnostics on file open

This commit is contained in:
Aiday Marlen Kyzy
2023-08-17 14:07:03 +02:00
parent b4801aeb02
commit 614bfb3d33
2 changed files with 29 additions and 25 deletions

View File

@@ -154,7 +154,6 @@ export class DiagnosticsManager extends Disposable {
private readonly _settings = new DiagnosticSettings();
private readonly _currentDiagnostics: vscode.DiagnosticCollection;
private readonly _pendingUpdates: ResourceMap<any>;
private readonly _telemetryReporter: TelemetryReporter;
private readonly _updateDelay = 50;
@@ -168,7 +167,30 @@ export class DiagnosticsManager extends Disposable {
this._pendingUpdates = new ResourceMap<any>(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<vscode.Diagnostic> {
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) {

View File

@@ -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();