This repository has been archived by the owner on Mar 22, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce capability to configue a MessagePort for the language client
- Update to vitest v1 - Move initServices to LanguageClientWrapper
- Loading branch information
Showing
18 changed files
with
950 additions
and
1,239 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
packages/examples/src/langium/worker/startLanguageServer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
import { startLanguageServer, EmptyFileSystem } from 'langium'; | ||
import { BrowserMessageReader, BrowserMessageWriter, createConnection } from 'vscode-languageserver/browser.js'; | ||
import { createStatemachineServices } from 'langium-statemachine-dsl/out/language-server/statemachine-module.js'; | ||
|
||
export const start = (port: MessagePort | DedicatedWorkerGlobalScope, name: string) => { | ||
console.log(`Starting ${name}...`); | ||
/* browser specific setup code */ | ||
const messageReader = new BrowserMessageReader(port); | ||
const messageWriter = new BrowserMessageWriter(port); | ||
|
||
const connection = createConnection(messageReader, messageWriter); | ||
|
||
// Inject the shared services and language-specific services | ||
const { shared } = createStatemachineServices({ connection, ...EmptyFileSystem }); | ||
|
||
// Start the language server with the shared services | ||
startLanguageServer(shared); | ||
}; |
15 changes: 15 additions & 0 deletions
15
packages/examples/src/langium/worker/statemachine-server-port.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { start } from './startLanguageServer.js'; | ||
|
||
declare const self: DedicatedWorkerGlobalScope; | ||
|
||
self.onmessage = async (event: MessageEvent) => { | ||
const data = event.data; | ||
if (data.port) { | ||
start(data.port, 'statemachine-server-port'); | ||
|
||
setTimeout(() => { | ||
// test independen communication | ||
self.postMessage('started'); | ||
}, 1000); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { start } from './startLanguageServer.js'; | ||
|
||
declare const self: DedicatedWorkerGlobalScope; | ||
|
||
start(self, 'statemachine-server'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.