-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathNotificationService.ts
More file actions
93 lines (74 loc) · 3.15 KB
/
NotificationService.ts
File metadata and controls
93 lines (74 loc) · 3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// Copyright 2022 - 2025 The MathWorks, Inc.
import { GenericNotificationHandler, Disposable } from 'vscode-languageserver/node'
import ClientConnection from '../ClientConnection'
export enum Notification {
// Connection Status Updates
MatlabConnectionClientUpdate = 'matlab/connection/update/client',
MatlabConnectionServerUpdate = 'matlab/connection/update/server',
// Errors
MatlabLaunchFailed = 'matlab/launchfailed',
MatlabFeatureUnavailable = 'feature/needsmatlab',
MatlabFeatureUnavailableNoMatlab = 'feature/needsmatlab/nomatlab',
// MATLAB Version Deprecation
MatlabVersionDeprecation = 'matlab/version/deprecation',
// Execution
MatlabRequestInstance = 'matlab/request',
TerminalCompletionRequest = 'TerminalCompletionRequest',
TerminalCompletionResponse = 'TerminalCompletionResponse',
MVMEvalRequest = 'evalRequest',
MVMEvalComplete = 'evalResponse',
MVMFevalRequest = 'fevalRequest',
MVMFevalComplete = 'fevalResponse',
MVMSetBreakpointRequest = 'setBreakpointRequest',
MVMSetBreakpointComplete = 'setBreakpointResponse',
MVMClearBreakpointRequest = 'clearBreakpointRequest',
MVMClearBreakpointComplete = 'clearBreakpointResponse',
MVMText = 'text',
MVMClc = 'clc',
MVMPromptChange = 'mvmPromptChange',
MVMInterruptRequest = 'interruptRequest',
MVMUnpauseRequest = 'unpauseRequest',
MVMStateChange = 'mvmStateChange',
DebuggingStateChange = 'DebuggingStateChange',
DebugAdaptorRequest = 'DebugAdaptorRequest',
DebugAdaptorResponse = 'DebugAdaptorResponse',
DebugAdaptorEvent = 'DebugAdaptorEvent',
// Telemetry
LogTelemetryData = 'telemetry/logdata',
// MATLAB File Sections Updates
MatlabSections = 'matlab/sections',
// Licensing
LicensingServerUrl = 'licensing/server/url',
LicensingData = 'licensing/data',
LicensingDelete = 'licensing/delete',
LicensingError = 'licensing/error',
}
class NotificationService {
private static instance: NotificationService
public static getInstance (): NotificationService {
if (NotificationService.instance == null) {
NotificationService.instance = new NotificationService()
}
return NotificationService.instance
}
/**
* Sends a notification to the language client
*
* @param name The name of the notification
* @param params Any parameters to send with the notification
*/
sendNotification (name: string, params?: unknown): void {
void ClientConnection.getConnection().sendNotification(name, params)
}
/**
* Registers a notification listener for the specified notification name.
*
* @param name - The name of the notification to listen for.
* @param callback - The callback function that will be invoked when the notification is received.
* @returns A disposable object that can be used to unregister the notification listener.
*/
registerNotificationListener (name: string, callback: GenericNotificationHandler): Disposable {
return ClientConnection.getConnection().onNotification(name, callback)
}
}
export default NotificationService.getInstance()