Extract EventName to enum
This commit is contained in:
parent
39418ef040
commit
0184d2f90d
|
@ -72,3 +72,19 @@ export class DisplayPartKind {
|
||||||
public static readonly punctuation = 'punctuation';
|
public static readonly punctuation = 'punctuation';
|
||||||
public static readonly text = 'text';
|
public static readonly text = 'text';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum EventName {
|
||||||
|
syntaxDiag = 'syntaxDiag',
|
||||||
|
semanticDiag = 'semanticDiag',
|
||||||
|
suggestionDiag = 'suggestionDiag',
|
||||||
|
configFileDiag = 'configFileDiag',
|
||||||
|
telemetry = 'telemetry',
|
||||||
|
projectLanguageServiceState = 'projectLanguageServiceState',
|
||||||
|
projectsUpdatedInBackground = 'projectsUpdatedInBackground',
|
||||||
|
beginInstallTypes = 'beginInstallTypes',
|
||||||
|
endInstallTypes = 'endInstallTypes',
|
||||||
|
typesInstallerInitializationFailed = 'typesInstallerInitializationFailed',
|
||||||
|
surveyReady = 'surveyReady',
|
||||||
|
projectLoadingStart = 'projectLoadingStart',
|
||||||
|
projectLoadingFinish = 'projectLoadingFinish',
|
||||||
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import Tracer from './utils/tracer';
|
||||||
import { inferredProjectCompilerOptions, ProjectType } from './utils/tsconfig';
|
import { inferredProjectCompilerOptions, ProjectType } from './utils/tsconfig';
|
||||||
import { TypeScriptVersionManager } from './utils/versionManager';
|
import { TypeScriptVersionManager } from './utils/versionManager';
|
||||||
import { TypeScriptVersion, TypeScriptVersionProvider } from './utils/versionProvider';
|
import { TypeScriptVersion, TypeScriptVersionProvider } from './utils/versionProvider';
|
||||||
|
import { EventName } from './protocol.const';
|
||||||
|
|
||||||
const localize = nls.loadMessageBundle();
|
const localize = nls.loadMessageBundle();
|
||||||
|
|
||||||
|
@ -760,9 +761,9 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||||
|
|
||||||
private dispatchEvent(event: Proto.Event) {
|
private dispatchEvent(event: Proto.Event) {
|
||||||
switch (event.event) {
|
switch (event.event) {
|
||||||
case 'syntaxDiag':
|
case EventName.syntaxDiag:
|
||||||
case 'semanticDiag':
|
case EventName.semanticDiag:
|
||||||
case 'suggestionDiag':
|
case EventName.suggestionDiag:
|
||||||
// This event also roughly signals that projects have been loaded successfully (since the TS server is synchronous)
|
// This event also roughly signals that projects have been loaded successfully (since the TS server is synchronous)
|
||||||
this.loadingIndicator.reset();
|
this.loadingIndicator.reset();
|
||||||
|
|
||||||
|
@ -776,17 +777,17 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'configFileDiag':
|
case EventName.configFileDiag:
|
||||||
this._onConfigDiagnosticsReceived.fire(event as Proto.ConfigFileDiagnosticEvent);
|
this._onConfigDiagnosticsReceived.fire(event as Proto.ConfigFileDiagnosticEvent);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'telemetry':
|
case EventName.telemetry:
|
||||||
{
|
{
|
||||||
const body = (event as Proto.TelemetryEvent).body;
|
const body = (event as Proto.TelemetryEvent).body;
|
||||||
this.dispatchTelemetryEvent(body);
|
this.dispatchTelemetryEvent(body);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'projectLanguageServiceState':
|
case EventName.projectLanguageServiceState:
|
||||||
{
|
{
|
||||||
const body = (event as Proto.ProjectLanguageServiceStateEvent).body!;
|
const body = (event as Proto.ProjectLanguageServiceStateEvent).body!;
|
||||||
if (this.serverState.type === ServerState.Type.Running) {
|
if (this.serverState.type === ServerState.Type.Running) {
|
||||||
|
@ -795,33 +796,33 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||||
this._onProjectLanguageServiceStateChanged.fire(body);
|
this._onProjectLanguageServiceStateChanged.fire(body);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'projectsUpdatedInBackground':
|
case EventName.projectsUpdatedInBackground:
|
||||||
const body = (event as Proto.ProjectsUpdatedInBackgroundEvent).body;
|
const body = (event as Proto.ProjectsUpdatedInBackgroundEvent).body;
|
||||||
const resources = body.openFiles.map(file => this.toResource(file));
|
const resources = body.openFiles.map(file => this.toResource(file));
|
||||||
this.bufferSyncSupport.getErr(resources);
|
this.bufferSyncSupport.getErr(resources);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'beginInstallTypes':
|
case EventName.beginInstallTypes:
|
||||||
this._onDidBeginInstallTypings.fire((event as Proto.BeginInstallTypesEvent).body);
|
this._onDidBeginInstallTypings.fire((event as Proto.BeginInstallTypesEvent).body);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'endInstallTypes':
|
case EventName.endInstallTypes:
|
||||||
this._onDidEndInstallTypings.fire((event as Proto.EndInstallTypesEvent).body);
|
this._onDidEndInstallTypings.fire((event as Proto.EndInstallTypesEvent).body);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'typesInstallerInitializationFailed':
|
case EventName.typesInstallerInitializationFailed:
|
||||||
this._onTypesInstallerInitializationFailed.fire((event as Proto.TypesInstallerInitializationFailedEvent).body);
|
this._onTypesInstallerInitializationFailed.fire((event as Proto.TypesInstallerInitializationFailedEvent).body);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'surveyReady':
|
case EventName.surveyReady:
|
||||||
this._onSurveyReady.fire((event as Proto.SurveyReadyEvent).body);
|
this._onSurveyReady.fire((event as Proto.SurveyReadyEvent).body);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'projectLoadingStart':
|
case EventName.projectLoadingStart:
|
||||||
this.loadingIndicator.startedLoadingProject((event as Proto.ProjectLoadingStartEvent).body.projectName);
|
this.loadingIndicator.startedLoadingProject((event as Proto.ProjectLoadingStartEvent).body.projectName);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'projectLoadingFinish':
|
case EventName.projectLoadingFinish:
|
||||||
this.loadingIndicator.finishedLoadingProject((event as Proto.ProjectLoadingFinishEvent).body.projectName);
|
this.loadingIndicator.finishedLoadingProject((event as Proto.ProjectLoadingFinishEvent).body.projectName);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue