提交 39c64727 编写于 作者: M Matt Bierner

Convert dispatchEvent to switch

上级 4e5a574a
......@@ -730,35 +730,52 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
}
private dispatchEvent(event: Proto.Event) {
if (event.event === 'syntaxDiag') {
this.host.syntaxDiagnosticsReceived(event as Proto.DiagnosticEvent);
} else if (event.event === 'semanticDiag') {
this.host.semanticDiagnosticsReceived(event as Proto.DiagnosticEvent);
} else if (event.event === 'configFileDiag') {
this.host.configFileDiagnosticsReceived(event as Proto.ConfigFileDiagnosticEvent);
} else if (event.event === 'telemetry') {
const telemetryData = (event as Proto.TelemetryEvent).body;
this.dispatchTelemetryEvent(telemetryData);
} else if (event.event === 'projectLanguageServiceState') {
const data = (event as Proto.ProjectLanguageServiceStateEvent).body;
if (data) {
this._onProjectLanguageServiceStateChanged.fire(data);
}
} else if (event.event === 'beginInstallTypes') {
const data = (event as Proto.BeginInstallTypesEvent).body;
if (data) {
this._onDidBeginInstallTypings.fire(data);
}
} else if (event.event === 'endInstallTypes') {
const data = (event as Proto.EndInstallTypesEvent).body;
if (data) {
this._onDidEndInstallTypings.fire(data);
}
} else if (event.event === 'typesInstallerInitializationFailed') {
const data = (event as Proto.TypesInstallerInitializationFailedEvent).body;
if (data) {
this._onTypesInstallerInitializationFailed.fire(data);
}
switch (event.event) {
case 'syntaxDiag':
this.host.syntaxDiagnosticsReceived(event as Proto.DiagnosticEvent);
break;
case 'semanticDiag':
this.host.semanticDiagnosticsReceived(event as Proto.DiagnosticEvent);
break;
case 'configFileDiag':
this.host.configFileDiagnosticsReceived(event as Proto.ConfigFileDiagnosticEvent);
break;
case 'telemetry':
const telemetryData = (event as Proto.TelemetryEvent).body;
this.dispatchTelemetryEvent(telemetryData);
break;
case 'projectLanguageServiceState':
if (event.body) {
const data = (event as Proto.ProjectLanguageServiceStateEvent).body;
this._onProjectLanguageServiceStateChanged.fire(data);
}
break;
case 'beginInstallTypes':
if (event.body) {
const data = (event as Proto.BeginInstallTypesEvent).body;
this._onDidBeginInstallTypings.fire(data);
}
break;
case 'endInstallTypes':
if (event.body) {
const data = (event as Proto.EndInstallTypesEvent).body;
this._onDidEndInstallTypings.fire(data);
}
break;
case 'typesInstallerInitializationFailed':
if (event.body) {
const data = (event as Proto.TypesInstallerInitializationFailedEvent).body;
this._onTypesInstallerInitializationFailed.fire(data);
}
break;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册