Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API fixes #172

Merged
merged 1 commit into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions applications/klighd-vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,16 @@ function isLanguageClient(client: unknown): client is LanguageClient {
// Therefore, they are two different classes internally.

// To work around this, we ensure that it is an object and check the object
// for the existence of a few methods.

const wantedMethod = ['onReady', 'sendNotification', 'onNotification', 'sendRequest', 'onRequest']
// for the existence of a few methods that are used in this extension.

const wantedMethod = [
'needsStart',
'onDidChangeState',
'onNotification',
'onRequest',
'sendNotification',
'sendRequest',
]

const isObject = typeof client === 'object' && client !== null
const hasWantedMethods = wantedMethod.every(
Expand Down
19 changes: 10 additions & 9 deletions applications/klighd-vscode/src/webview-endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* http://rtsys.informatik.uni-kiel.de/kieler
*
* Copyright 2023 by
* Copyright 2023-2024 by
* + Kiel University
* + Department of Computer Science
* + Real-Time and Embedded Systems Group
Expand Down Expand Up @@ -57,14 +57,6 @@ export class KlighDWebviewEndpoint extends WebviewEndpoint {
this.messenger.onRequest(
LspRequest,
async (request) => {
// Catch any diagram/accept action and call the registered action handlers.
if (request.method === 'diagram/accept' && isActionMessage(request.params)) {
const { action } = request.params
const handlers = this.klighdActionHandlers.get(request.params.action.kind)
if (handlers) {
handlers.forEach((handler) => handler(action))
}
}
const result: any =
request.params === undefined
? await this.languageClient.sendRequest(request.method)
Expand All @@ -81,6 +73,15 @@ export class KlighDWebviewEndpoint extends WebviewEndpoint {
this.messenger.onNotification(
LspNotification,
(notification) => {
// Catch any diagram/accept action and call the registered action handlers.
if (notification.method === 'diagram/accept' && isActionMessage(notification.params)) {
const { action } = notification.params
const handlers = this.klighdActionHandlers.get(notification.params.action.kind)
if (handlers) {
handlers.forEach((handler) => handler(action))
// TODO: if one of the handlers says the action does not need to be forwarded to the server, do not forward it.
}
}
this.languageClient.sendNotification(notification.method, notification.params)
},
{ sender: this.messageParticipant }
Expand Down
Loading