From 48fa75909c790845aa2432288e95a1db8000a2ee Mon Sep 17 00:00:00 2001 From: Kai Salmen Date: Wed, 23 Oct 2024 15:05:33 +0200 Subject: [PATCH] Move all code example files out of src into resources, plus small corrections --- index.html | 2 +- .../langium/langium-dsl}/example.langium | 0 .../langium/statemachine}/example-mod.statemachine | 0 .../langium/statemachine}/example.statemachine | 0 .../{src/python/client => resources/python}/bad.py | 0 .../{src/python/client => resources/python}/hello.py | 0 .../{src/python/client => resources/python}/hello2.py | 0 .../src/langium/langium-dsl/config/classicConfig.ts | 5 +---- .../src/langium/langium-dsl/config/extendedConfig.ts | 8 +++----- .../statemachine/config/wrapperStatemachineConfig.ts | 2 +- packages/examples/src/langium/statemachine/main-react.tsx | 2 +- packages/examples/src/langium/statemachine/main.ts | 4 ++-- packages/examples/src/python/client/config.ts | 3 --- packages/examples/src/python/client/main.ts | 4 ++-- packages/examples/src/python/client/reactPython.tsx | 2 +- packages/examples/src/ts/wrapperTs.ts | 1 - packages/examples/tsExtHost.html | 4 ++-- 17 files changed, 14 insertions(+), 23 deletions(-) rename packages/examples/{src/langium/langium-dsl/content => resources/langium/langium-dsl}/example.langium (100%) rename packages/examples/{src/langium/statemachine/content => resources/langium/statemachine}/example-mod.statemachine (100%) rename packages/examples/{src/langium/statemachine/content => resources/langium/statemachine}/example.statemachine (100%) rename packages/examples/{src/python/client => resources/python}/bad.py (100%) rename packages/examples/{src/python/client => resources/python}/hello.py (100%) rename packages/examples/{src/python/client => resources/python}/hello2.py (100%) diff --git a/index.html b/index.html index c1dbd2368..a18c8ef08 100644 --- a/index.html +++ b/index.html @@ -79,7 +79,7 @@

Multiple Languageclients


TypeScript

- TypeScript Extension Host Worker + TypeScript Extension Host Worker

Monaco Editor React

diff --git a/packages/examples/src/langium/langium-dsl/content/example.langium b/packages/examples/resources/langium/langium-dsl/example.langium similarity index 100% rename from packages/examples/src/langium/langium-dsl/content/example.langium rename to packages/examples/resources/langium/langium-dsl/example.langium diff --git a/packages/examples/src/langium/statemachine/content/example-mod.statemachine b/packages/examples/resources/langium/statemachine/example-mod.statemachine similarity index 100% rename from packages/examples/src/langium/statemachine/content/example-mod.statemachine rename to packages/examples/resources/langium/statemachine/example-mod.statemachine diff --git a/packages/examples/src/langium/statemachine/content/example.statemachine b/packages/examples/resources/langium/statemachine/example.statemachine similarity index 100% rename from packages/examples/src/langium/statemachine/content/example.statemachine rename to packages/examples/resources/langium/statemachine/example.statemachine diff --git a/packages/examples/src/python/client/bad.py b/packages/examples/resources/python/bad.py similarity index 100% rename from packages/examples/src/python/client/bad.py rename to packages/examples/resources/python/bad.py diff --git a/packages/examples/src/python/client/hello.py b/packages/examples/resources/python/hello.py similarity index 100% rename from packages/examples/src/python/client/hello.py rename to packages/examples/resources/python/hello.py diff --git a/packages/examples/src/python/client/hello2.py b/packages/examples/resources/python/hello2.py similarity index 100% rename from packages/examples/src/python/client/hello2.py rename to packages/examples/resources/python/hello2.py diff --git a/packages/examples/src/langium/langium-dsl/config/classicConfig.ts b/packages/examples/src/langium/langium-dsl/config/classicConfig.ts index 54ef2d407..88e5414b6 100644 --- a/packages/examples/src/langium/langium-dsl/config/classicConfig.ts +++ b/packages/examples/src/langium/langium-dsl/config/classicConfig.ts @@ -4,16 +4,14 @@ * ------------------------------------------------------------------------------------------ */ import getConfigurationServiceOverride from '@codingame/monaco-vscode-configuration-service-override'; -import getEditorServiceOverride from '@codingame/monaco-vscode-editor-service-override'; import getKeybindingsServiceOverride from '@codingame/monaco-vscode-keybindings-service-override'; -import { useOpenEditorStub } from 'monaco-editor-wrapper/vscode/services'; import { LogLevel } from 'vscode/services'; import { Logger } from 'monaco-languageclient/tools'; import { WrapperConfig } from 'monaco-editor-wrapper'; import { LangiumMonarchContent } from './langium.monarch.js'; import { loadLangiumWorker } from '../wrapperLangium.js'; -import code from '../content/example.langium?raw'; import { useWorkerFactory } from 'monaco-editor-wrapper/workerFactory'; +import code from '../../../../resources/langium/langium-dsl/example.langium?raw'; export const setupLangiumClientClassic = async (): Promise => { const langiumWorker = loadLangiumWorker(); @@ -22,7 +20,6 @@ export const setupLangiumClientClassic = async (): Promise => { vscodeApiConfig: { userServices: { ...getConfigurationServiceOverride(), - ...getEditorServiceOverride(useOpenEditorStub), ...getKeybindingsServiceOverride() } }, diff --git a/packages/examples/src/langium/langium-dsl/config/extendedConfig.ts b/packages/examples/src/langium/langium-dsl/config/extendedConfig.ts index 1f3ace3c3..da237ff5f 100644 --- a/packages/examples/src/langium/langium-dsl/config/extendedConfig.ts +++ b/packages/examples/src/langium/langium-dsl/config/extendedConfig.ts @@ -3,10 +3,9 @@ * Licensed under the MIT License. See LICENSE in the package root for license information. * ------------------------------------------------------------------------------------------ */ -import getEditorServiceOverride from '@codingame/monaco-vscode-editor-service-override'; import getKeybindingsServiceOverride from '@codingame/monaco-vscode-keybindings-service-override'; import '../../../../resources/vsix/github-vscode-theme.vsix'; -import { useOpenEditorStub } from 'monaco-editor-wrapper/vscode/services'; + import { BrowserMessageReader, BrowserMessageWriter } from 'vscode-languageclient/browser.js'; import { LogLevel } from 'vscode/services'; import { WrapperConfig } from 'monaco-editor-wrapper'; @@ -14,7 +13,7 @@ import { loadLangiumWorker } from '../wrapperLangium.js'; import { configureMonacoWorkers } from '../../../common/client/utils.js'; import langiumLanguageConfig from './langium.configuration.json?raw'; import langiumTextmateGrammar from './langium.tmLanguage.json?raw'; -import text from '../content/example.langium?raw'; +import text from '../../../../resources/langium/langium-dsl//example.langium?raw'; export const setupLangiumClientExtended = async (): Promise => { @@ -31,7 +30,6 @@ export const setupLangiumClientExtended = async (): Promise => { logLevel: LogLevel.Debug, vscodeApiConfig: { userServices: { - ...getEditorServiceOverride(useOpenEditorStub), ...getKeybindingsServiceOverride() }, userConfiguration: { @@ -55,7 +53,7 @@ export const setupLangiumClientExtended = async (): Promise => { extensions: [{ config: { name: 'langium-example', - publisher: 'monaco-editor-wrapper-examples', + publisher: 'TypeFox', version: '1.0.0', engines: { vscode: '*' diff --git a/packages/examples/src/langium/statemachine/config/wrapperStatemachineConfig.ts b/packages/examples/src/langium/statemachine/config/wrapperStatemachineConfig.ts index 85980c9fc..2c60278d3 100644 --- a/packages/examples/src/langium/statemachine/config/wrapperStatemachineConfig.ts +++ b/packages/examples/src/langium/statemachine/config/wrapperStatemachineConfig.ts @@ -76,7 +76,7 @@ export const createLangiumGlobalConfig = async (params: { extensions: [{ config: { name: 'statemachine-example', - publisher: 'monaco-editor-wrapper-examples', + publisher: 'TypeFox', version: '1.0.0', engines: { vscode: '*' diff --git a/packages/examples/src/langium/statemachine/main-react.tsx b/packages/examples/src/langium/statemachine/main-react.tsx index 46120724c..93547c786 100644 --- a/packages/examples/src/langium/statemachine/main-react.tsx +++ b/packages/examples/src/langium/statemachine/main-react.tsx @@ -8,7 +8,7 @@ import ReactDOM from 'react-dom/client'; import { MonacoEditorReactComp } from '@typefox/monaco-editor-react'; import { createLangiumGlobalConfig } from './config/wrapperStatemachineConfig.js'; import { loadStatemachineWorkerRegular } from './main.js'; -import text from './content/example.statemachine?raw'; +import text from '../../../resources/langium/statemachine/example.statemachine?raw'; export const runStatemachineReact = async () => { const wrapperConfig = await createLangiumGlobalConfig({ diff --git a/packages/examples/src/langium/statemachine/main.ts b/packages/examples/src/langium/statemachine/main.ts index 0c6e07024..6a35935ef 100644 --- a/packages/examples/src/langium/statemachine/main.ts +++ b/packages/examples/src/langium/statemachine/main.ts @@ -10,8 +10,8 @@ import { BrowserMessageReader, BrowserMessageWriter } from 'vscode-languageclien import { createLangiumGlobalConfig } from './config/wrapperStatemachineConfig.js'; import workerUrl from './worker/statemachine-server?worker&url'; import workerPortUrl from './worker/statemachine-server-port?worker&url'; -import text from './content/example.statemachine?raw'; -import textMod from './content/example-mod.statemachine?raw'; +import text from '../../../resources/langium/statemachine/example.statemachine?raw'; +import textMod from '../../../resources/langium/statemachine/example-mod.statemachine?raw'; const wrapper = new MonacoEditorLanguageClientWrapper(); const wrapper2 = new MonacoEditorLanguageClientWrapper(); diff --git a/packages/examples/src/python/client/config.ts b/packages/examples/src/python/client/config.ts index 29c253e02..8c7a54301 100644 --- a/packages/examples/src/python/client/config.ts +++ b/packages/examples/src/python/client/config.ts @@ -4,14 +4,12 @@ * ------------------------------------------------------------------------------------------ */ import * as vscode from 'vscode'; -import getEditorServiceOverride from '@codingame/monaco-vscode-editor-service-override'; import getKeybindingsServiceOverride from '@codingame/monaco-vscode-keybindings-service-override'; import '@codingame/monaco-vscode-python-default-extension'; import { LogLevel } from 'vscode/services'; import { MonacoLanguageClient } from 'monaco-languageclient'; import { createUrl } from 'monaco-languageclient/tools'; import { WrapperConfig } from 'monaco-editor-wrapper'; -import { useOpenEditorStub } from 'monaco-editor-wrapper/vscode/services'; import { toSocket, WebSocketMessageReader, WebSocketMessageWriter } from 'vscode-ws-jsonrpc'; import { configureMonacoWorkers } from '../../common/client/utils.js'; @@ -67,7 +65,6 @@ export const createUserConfig = (workspaceRoot: string, code: string, codeUri: s logLevel: LogLevel.Debug, vscodeApiConfig: { userServices: { - ...getEditorServiceOverride(useOpenEditorStub), ...getKeybindingsServiceOverride() }, userConfiguration: { diff --git a/packages/examples/src/python/client/main.ts b/packages/examples/src/python/client/main.ts index b63897b71..3b6c6c6d7 100644 --- a/packages/examples/src/python/client/main.ts +++ b/packages/examples/src/python/client/main.ts @@ -9,8 +9,8 @@ import '@codingame/monaco-vscode-python-default-extension'; import { RegisteredFileSystemProvider, registerFileSystemOverlay, RegisteredMemoryFile } from '@codingame/monaco-vscode-files-service-override'; import { MonacoEditorLanguageClientWrapper } from 'monaco-editor-wrapper'; import { createUserConfig } from './config.js'; -import helloPyCode from './hello.py?raw'; -import hello2PyCode from './hello2.py?raw'; +import helloPyCode from '../../../resources/python/hello.py?raw'; +import hello2PyCode from '../../../resources/python/hello2.py?raw'; export const runPythonWrapper = async () => { const helloPyUri = vscode.Uri.file('/workspace/hello.py'); diff --git a/packages/examples/src/python/client/reactPython.tsx b/packages/examples/src/python/client/reactPython.tsx index a43b6258d..77c961653 100644 --- a/packages/examples/src/python/client/reactPython.tsx +++ b/packages/examples/src/python/client/reactPython.tsx @@ -10,7 +10,7 @@ import ReactDOM from 'react-dom/client'; import { MonacoEditorReactComp } from '@typefox/monaco-editor-react'; import { MonacoEditorLanguageClientWrapper, TextChanges } from 'monaco-editor-wrapper'; import { createUserConfig } from './config.js'; -import badPyCode from './bad.py?raw'; +import badPyCode from '../../../resources/python/bad.py?raw'; export const runPythonReact = async () => { const badPyUri = vscode.Uri.file('/workspace/bad.py'); diff --git a/packages/examples/src/ts/wrapperTs.ts b/packages/examples/src/ts/wrapperTs.ts index 79d2c3161..1e8cdca56 100644 --- a/packages/examples/src/ts/wrapperTs.ts +++ b/packages/examples/src/ts/wrapperTs.ts @@ -5,7 +5,6 @@ import * as vscode from 'vscode'; import getKeybindingsServiceOverride from '@codingame/monaco-vscode-keybindings-service-override'; -import '@codingame/monaco-vscode-theme-defaults-default-extension'; import '@codingame/monaco-vscode-typescript-basics-default-extension'; import '@codingame/monaco-vscode-typescript-language-features-default-extension'; import { LogLevel } from 'vscode/services'; diff --git a/packages/examples/tsExtHost.html b/packages/examples/tsExtHost.html index bae94b2d6..2dc5fb760 100644 --- a/packages/examples/tsExtHost.html +++ b/packages/examples/tsExtHost.html @@ -4,12 +4,12 @@ - Monaco Editor Wrapper TypeScript Example + TypeScript Extension Host Worker -

Monaco Editor Wrapper TypeScript Example

+

TypeScript Extension Host Worker