wasm-idle 0.7.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +760 -81
- package/dist/index.d.ts +4 -9
- package/dist/index.js +2 -4
- package/dist/playground/applicationAssets.d.ts +4 -0
- package/dist/playground/applicationAssets.js +277 -0
- package/dist/playground/assemblyscript.d.ts +41 -0
- package/dist/playground/assemblyscript.js +630 -0
- package/dist/playground/assetBridge.d.ts +18 -7
- package/dist/playground/assetBridge.js +824 -100
- package/dist/playground/assets.d.ts +813 -19
- package/dist/playground/assets.js +2096 -156
- package/dist/playground/awk.d.ts +5 -0
- package/dist/playground/awk.js +60 -0
- package/dist/playground/bash.d.ts +53 -0
- package/dist/playground/bash.js +1096 -0
- package/dist/playground/bashWorkerProtocol.d.ts +88 -0
- package/dist/playground/bashWorkerProtocol.js +135 -0
- package/dist/playground/bqn.d.ts +5 -0
- package/dist/playground/bqn.js +57 -0
- package/dist/playground/bqnPreflight.d.ts +26 -0
- package/dist/playground/bqnPreflight.js +399 -0
- package/dist/playground/c3.d.ts +15 -0
- package/dist/playground/c3.js +154 -0
- package/dist/playground/clang.d.ts +35 -19
- package/dist/playground/clang.js +241 -52
- package/dist/playground/clangAssetIntegrity.d.ts +32 -0
- package/dist/playground/clangAssetIntegrity.js +8 -0
- package/dist/playground/clojurescript.d.ts +5 -0
- package/dist/playground/clojurescript.js +59 -0
- package/dist/playground/clojurescriptPreflight.d.ts +26 -0
- package/dist/playground/clojurescriptPreflight.js +383 -0
- package/dist/playground/cobol.d.ts +46 -0
- package/dist/playground/cobol.js +703 -0
- package/dist/playground/d.d.ts +47 -0
- package/dist/playground/d.js +644 -0
- package/dist/playground/dOuterAssets.d.ts +16 -0
- package/dist/playground/dOuterAssets.js +163 -0
- package/dist/playground/dotnet.d.ts +99 -0
- package/dist/playground/dotnet.js +1131 -0
- package/dist/playground/duckdb.d.ts +36 -0
- package/dist/playground/duckdb.js +542 -0
- package/dist/playground/elixir.d.ts +18 -10
- package/dist/playground/elixir.js +630 -96
- package/dist/playground/elixirAssets.d.ts +6 -0
- package/dist/playground/elixirAssets.js +33 -0
- package/dist/playground/executionObservation.d.ts +22 -0
- package/dist/playground/executionObservation.js +65 -0
- package/dist/playground/forth.d.ts +5 -0
- package/dist/playground/forth.js +53 -0
- package/dist/playground/forthPreflight.d.ts +24 -0
- package/dist/playground/forthPreflight.js +198 -0
- package/dist/playground/fortran.d.ts +47 -0
- package/dist/playground/fortran.js +651 -0
- package/dist/playground/fortranAssets.d.ts +6 -0
- package/dist/playground/fortranAssets.js +27 -0
- package/dist/playground/gleam.d.ts +6 -0
- package/dist/playground/gleam.js +33 -0
- package/dist/playground/go.d.ts +17 -11
- package/dist/playground/go.js +376 -72
- package/dist/playground/goDebugInstrumentation.d.ts +1 -0
- package/dist/playground/goDebugInstrumentation.js +229 -0
- package/dist/playground/haskell.d.ts +44 -0
- package/dist/playground/haskell.js +678 -0
- package/dist/playground/haskellAssets.d.ts +24 -0
- package/dist/playground/haskellAssets.js +93 -0
- package/dist/playground/index.d.ts +1 -1
- package/dist/playground/index.js +360 -111
- package/dist/playground/j.d.ts +5 -0
- package/dist/playground/j.js +60 -0
- package/dist/playground/jPreflight.d.ts +26 -0
- package/dist/playground/jPreflight.js +372 -0
- package/dist/playground/janet.d.ts +5 -0
- package/dist/playground/janet.js +64 -0
- package/dist/playground/java.d.ts +24 -10
- package/dist/playground/java.js +706 -84
- package/dist/playground/javaSource.d.ts +5 -0
- package/dist/playground/javaSource.js +16 -0
- package/dist/playground/javaStdin.d.ts +1 -1
- package/dist/playground/javaStdin.js +13 -4
- package/dist/playground/julia.d.ts +5 -0
- package/dist/playground/julia.js +64 -0
- package/dist/playground/lfortran.d.ts +8 -0
- package/dist/playground/lfortran.js +30 -0
- package/dist/playground/lfortranAssets.d.ts +21 -0
- package/dist/playground/lfortranAssets.js +118 -0
- package/dist/playground/lisp.d.ts +45 -0
- package/dist/playground/lisp.js +640 -0
- package/dist/playground/lispAssets.d.ts +9 -0
- package/dist/playground/lispAssets.js +74 -0
- package/dist/playground/lldbManifest.d.ts +3 -0
- package/dist/playground/lldbManifest.js +155 -0
- package/dist/playground/lldbSession.d.ts +115 -0
- package/dist/playground/lldbSession.js +1347 -0
- package/dist/playground/loadingProgress.d.ts +16 -0
- package/dist/playground/loadingProgress.js +166 -0
- package/dist/playground/lua.d.ts +44 -0
- package/dist/playground/lua.js +630 -0
- package/dist/playground/nim.d.ts +5 -0
- package/dist/playground/nim.js +76 -0
- package/dist/playground/objectivec.d.ts +39 -0
- package/dist/playground/objectivec.js +288 -0
- package/dist/playground/ocaml.d.ts +28 -10
- package/dist/playground/ocaml.js +815 -253
- package/dist/playground/octave.d.ts +43 -0
- package/dist/playground/octave.js +783 -0
- package/dist/playground/options.d.ts +19 -40
- package/dist/playground/options.js +2 -1
- package/dist/playground/pascal.d.ts +5 -0
- package/dist/playground/pascal.js +60 -0
- package/dist/playground/perl.d.ts +5 -0
- package/dist/playground/perl.js +61 -0
- package/dist/playground/php.d.ts +44 -0
- package/dist/playground/php.js +665 -0
- package/dist/playground/prolog.d.ts +6 -0
- package/dist/playground/prolog.js +75 -0
- package/dist/playground/python.d.ts +20 -14
- package/dist/playground/python.js +445 -101
- package/dist/playground/pythonPackageLock.d.ts +6 -0
- package/dist/playground/pythonPackageLock.js +56 -0
- package/dist/playground/r.d.ts +44 -0
- package/dist/playground/r.js +637 -0
- package/dist/playground/ruby.d.ts +46 -0
- package/dist/playground/ruby.js +732 -0
- package/dist/playground/rubyAssets.d.ts +23 -0
- package/dist/playground/rubyAssets.js +68 -0
- package/dist/playground/rubyTestPreflight.d.ts +2 -0
- package/dist/playground/rubyTestPreflight.js +18 -0
- package/dist/playground/runtimeModule.d.ts +1 -0
- package/dist/playground/runtimeModule.js +5 -0
- package/dist/playground/rust.d.ts +44 -13
- package/dist/playground/rust.js +714 -76
- package/dist/playground/rustExecutableGraph.d.ts +85 -0
- package/dist/playground/rustExecutableGraph.js +946 -0
- package/dist/playground/rustWorkerLimits.d.ts +17 -0
- package/dist/playground/rustWorkerLimits.js +34 -0
- package/dist/playground/sandbox.d.ts +16 -10
- package/dist/playground/sharedBuffer.d.ts +6 -0
- package/dist/playground/sharedBuffer.js +12 -0
- package/dist/playground/sqlite.d.ts +38 -0
- package/dist/playground/sqlite.js +550 -0
- package/dist/playground/staticRuntimeModuleVersion.d.ts +1 -0
- package/dist/playground/staticRuntimeModuleVersion.js +2 -0
- package/dist/playground/staticRuntimePreflight.d.ts +13 -0
- package/dist/playground/staticRuntimePreflight.js +231 -0
- package/dist/playground/staticRuntimePreflightExecute.d.ts +8 -0
- package/dist/playground/staticRuntimePreflightExecute.js +66 -0
- package/dist/playground/staticRuntimePreflightProtocol.d.ts +68 -0
- package/dist/playground/staticRuntimePreflightProtocol.js +339 -0
- package/dist/playground/staticStdinRing.d.ts +45 -0
- package/dist/playground/staticStdinRing.js +158 -0
- package/dist/playground/staticWorkerRuntime.d.ts +154 -0
- package/dist/playground/staticWorkerRuntime.js +1917 -0
- package/dist/playground/stdinBuffer.d.ts +9 -7
- package/dist/playground/stdinBuffer.js +9 -18
- package/dist/playground/swift.d.ts +5 -0
- package/dist/playground/swift.js +17 -0
- package/dist/playground/tcl.d.ts +5 -0
- package/dist/playground/tcl.js +62 -0
- package/dist/playground/teavmConfig.d.ts +1 -1
- package/dist/playground/teavmConfig.js +2 -2
- package/dist/playground/tinygo.d.ts +48 -18
- package/dist/playground/tinygo.js +1202 -329
- package/dist/playground/tinygoExecutableGraph.d.ts +44 -0
- package/dist/playground/tinygoExecutableGraph.js +449 -0
- package/dist/playground/typescript.d.ts +55 -0
- package/dist/playground/typescript.js +924 -0
- package/dist/playground/wasm.d.ts +43 -0
- package/dist/playground/wasm.js +608 -0
- package/dist/playground/wasmAwkVersion.d.ts +59 -0
- package/dist/playground/wasmAwkVersion.js +31 -0
- package/dist/playground/wasmBashVersion.d.ts +63 -0
- package/dist/playground/wasmBashVersion.js +36 -0
- package/dist/playground/wasmBqnVersion.d.ts +24 -0
- package/dist/playground/wasmBqnVersion.js +24 -0
- package/dist/playground/wasmC3Version.d.ts +20 -0
- package/dist/playground/wasmC3Version.js +21 -0
- package/dist/playground/wasmClojureScriptVersion.d.ts +21 -0
- package/dist/playground/wasmClojureScriptVersion.js +21 -0
- package/dist/playground/wasmDIntegrity.d.ts +15 -0
- package/dist/playground/wasmDIntegrity.js +15 -0
- package/dist/playground/wasmDVersion.d.ts +1 -0
- package/dist/playground/wasmDVersion.js +1 -0
- package/dist/playground/wasmDebugVersion.d.ts +6 -0
- package/dist/playground/wasmDebugVersion.js +6 -0
- package/dist/playground/wasmDotnetVersion.d.ts +1 -0
- package/dist/playground/wasmDotnetVersion.js +1 -0
- package/dist/playground/wasmElixirVersion.d.ts +21 -1
- package/dist/playground/wasmElixirVersion.js +21 -1
- package/dist/playground/wasmForthVersion.d.ts +18 -0
- package/dist/playground/wasmForthVersion.js +18 -0
- package/dist/playground/wasmFortranExecutionAssets.d.ts +15 -0
- package/dist/playground/wasmFortranExecutionAssets.js +15 -0
- package/dist/playground/wasmFortranVersion.d.ts +1 -0
- package/dist/playground/wasmFortranVersion.js +1 -0
- package/dist/playground/wasmGleamVersion.d.ts +5 -0
- package/dist/playground/wasmGleamVersion.js +5 -0
- package/dist/playground/wasmGoVersion.d.ts +1 -1
- package/dist/playground/wasmGoVersion.js +1 -1
- package/dist/playground/wasmHaskellVersion.d.ts +1 -0
- package/dist/playground/wasmHaskellVersion.js +1 -0
- package/dist/playground/wasmJVersion.d.ts +24 -0
- package/dist/playground/wasmJVersion.js +24 -0
- package/dist/playground/wasmJanetVersion.d.ts +53 -0
- package/dist/playground/wasmJanetVersion.js +30 -0
- package/dist/playground/wasmJuliaVersion.d.ts +71 -0
- package/dist/playground/wasmJuliaVersion.js +39 -0
- package/dist/playground/wasmLfortranVersion.d.ts +28 -0
- package/dist/playground/wasmLfortranVersion.js +29 -0
- package/dist/playground/wasmLispVersion.d.ts +1 -0
- package/dist/playground/wasmLispVersion.js +1 -0
- package/dist/playground/wasmLuaVersion.d.ts +1 -0
- package/dist/playground/wasmLuaVersion.js +1 -0
- package/dist/playground/wasmNimVersion.d.ts +125 -0
- package/dist/playground/wasmNimVersion.js +66 -0
- package/dist/playground/wasmObjectiveCVersion.d.ts +27 -0
- package/dist/playground/wasmObjectiveCVersion.js +27 -0
- package/dist/playground/wasmOcamlVersion.d.ts +12 -1
- package/dist/playground/wasmOcamlVersion.js +12 -1
- package/dist/playground/wasmOctaveVersion.d.ts +1 -0
- package/dist/playground/wasmOctaveVersion.js +1 -0
- package/dist/playground/wasmPascalVersion.d.ts +61 -0
- package/dist/playground/wasmPascalVersion.js +34 -0
- package/dist/playground/wasmPerlVersion.d.ts +71 -0
- package/dist/playground/wasmPerlVersion.js +39 -0
- package/dist/playground/wasmPrologVersion.d.ts +31 -0
- package/dist/playground/wasmPrologVersion.js +31 -0
- package/dist/playground/wasmRVersion.d.ts +1 -0
- package/dist/playground/wasmRVersion.js +1 -0
- package/dist/playground/wasmRustVersion.d.ts +1306 -1
- package/dist/playground/wasmRustVersion.js +1458 -1
- package/dist/playground/wasmSwiftVersion.d.ts +1 -0
- package/dist/playground/wasmSwiftVersion.js +1 -0
- package/dist/playground/wasmTclVersion.d.ts +85 -0
- package/dist/playground/wasmTclVersion.js +46 -0
- package/dist/playground/wasmTinyGoVersion.d.ts +98 -1
- package/dist/playground/wasmTinyGoVersion.js +107 -1
- package/dist/playground/wasmTypeScriptVersion.d.ts +5 -0
- package/dist/playground/wasmTypeScriptVersion.js +5 -0
- package/dist/playground/wasmWatVersion.d.ts +1 -0
- package/dist/playground/wasmWatVersion.js +1 -0
- package/dist/playground/wasmZigVersion.d.ts +13 -0
- package/dist/playground/wasmZigVersion.js +13 -0
- package/dist/playground/wat.d.ts +44 -0
- package/dist/playground/wat.js +622 -0
- package/dist/playground/worker/assemblyscript.js +339 -0
- package/dist/playground/worker/assets.d.ts +7 -0
- package/dist/playground/worker/assets.js +288 -39
- package/dist/playground/worker/bash.js +338 -0
- package/dist/playground/worker/bashNestedBootstrap.d.ts +6 -0
- package/dist/playground/worker/bashNestedBootstrap.js +59 -0
- package/dist/playground/worker/bashRuntime.d.ts +89 -0
- package/dist/playground/worker/bashRuntime.js +982 -0
- package/dist/playground/worker/clang.js +92 -13
- package/dist/playground/worker/cobol.js +107 -0
- package/dist/playground/worker/d.js +199 -0
- package/dist/playground/worker/dotnet.js +141 -0
- package/dist/playground/worker/duckdb.d.ts +1 -0
- package/dist/playground/worker/duckdb.js +136 -0
- package/dist/playground/worker/elixir.js +307 -41
- package/dist/playground/worker/fortran.d.ts +1 -0
- package/dist/playground/worker/fortran.js +295 -0
- package/dist/playground/worker/go.js +246 -40
- package/dist/playground/worker/haskell.d.ts +7 -0
- package/dist/playground/worker/haskell.js +465 -0
- package/dist/playground/worker/java.js +59 -20
- package/dist/playground/worker/lisp.d.ts +1 -0
- package/dist/playground/worker/lisp.js +195 -0
- package/dist/playground/worker/lua.d.ts +1 -0
- package/dist/playground/worker/lua.js +163 -0
- package/dist/playground/worker/objectivec.d.ts +1 -0
- package/dist/playground/worker/objectivec.js +10 -0
- package/dist/playground/worker/ocaml.js +206 -58
- package/dist/playground/worker/php.d.ts +1 -0
- package/dist/playground/worker/php.js +261 -0
- package/dist/playground/worker/python.js +201 -44
- package/dist/playground/worker/r.d.ts +1 -0
- package/dist/playground/worker/r.js +192 -0
- package/dist/playground/worker/ruby.d.ts +1 -0
- package/dist/playground/worker/ruby.js +248 -0
- package/dist/playground/worker/runtimeAssetFetch.d.ts +15 -0
- package/dist/playground/worker/runtimeAssetFetch.js +375 -0
- package/dist/playground/worker/rust.js +546 -20
- package/dist/playground/worker/sqlite.d.ts +1 -0
- package/dist/playground/worker/sqlite.js +112 -0
- package/dist/playground/worker/staticRuntimePreflight.d.ts +1 -0
- package/dist/playground/worker/staticRuntimePreflight.js +56 -0
- package/dist/playground/worker/tinygo.js +34 -9
- package/dist/playground/worker/typescript.d.ts +1 -0
- package/dist/playground/worker/typescript.js +251 -0
- package/dist/playground/worker/wasm.d.ts +1 -0
- package/dist/playground/worker/wasm.js +273 -0
- package/dist/playground/worker/wat.d.ts +1 -0
- package/dist/playground/worker/wat.js +188 -0
- package/dist/playground/worker/zig.d.ts +8 -0
- package/dist/playground/worker/zig.js +578 -0
- package/dist/playground/workerProgress.d.ts +15 -0
- package/dist/playground/workerProgress.js +72 -0
- package/dist/playground/workerSession.d.ts +28 -0
- package/dist/playground/workerSession.js +164 -0
- package/dist/playground/zig.d.ts +46 -0
- package/dist/playground/zig.js +690 -0
- package/dist/playground/zigAssets.d.ts +6 -0
- package/dist/playground/zigAssets.js +49 -0
- package/package.json +234 -105
- package/dist/clang/app.d.ts +0 -75
- package/dist/clang/app.js +0 -744
- package/dist/clang/apply.d.ts +0 -2
- package/dist/clang/apply.js +0 -11
- package/dist/clang/color.d.ts +0 -3
- package/dist/clang/color.js +0 -3
- package/dist/clang/encode.d.ts +0 -4
- package/dist/clang/encode.js +0 -20
- package/dist/clang/error.d.ts +0 -14
- package/dist/clang/error.js +0 -27
- package/dist/clang/gccCompat.d.ts +0 -15
- package/dist/clang/gccCompat.js +0 -767
- package/dist/clang/index.d.ts +0 -85
- package/dist/clang/index.js +0 -1077
- package/dist/clang/memory/index.d.ts +0 -4
- package/dist/clang/memory/index.js +0 -4
- package/dist/clang/memory/memFs.d.ts +0 -35
- package/dist/clang/memory/memFs.js +0 -132
- package/dist/clang/memory/memory.d.ts +0 -22
- package/dist/clang/memory/memory.js +0 -73
- package/dist/clang/memory/tar.d.ts +0 -2
- package/dist/clang/memory/tar.js +0 -59
- package/dist/clang/url.d.ts +0 -4
- package/dist/clang/url.js +0 -5
- package/dist/clang/wasm.d.ts +0 -4
- package/dist/clang/wasm.js +0 -50
- package/dist/clangd/config.d.ts +0 -18
- package/dist/clangd/config.js +0 -14
- package/dist/clangd/jsonStream.d.ts +0 -9
- package/dist/clangd/jsonStream.js +0 -48
- package/dist/clangd/session.d.ts +0 -18
- package/dist/clangd/session.js +0 -112
- package/dist/clangd/worker.js +0 -131
- package/dist/debug/controller.svelte.d.ts +0 -43
- package/dist/debug/controller.svelte.js +0 -268
- package/dist/debug/editor/index.d.ts +0 -2
- package/dist/debug/editor/index.js +0 -1
- package/dist/debug/editor/monaco.d.ts +0 -26
- package/dist/debug/editor/monaco.js +0 -128
- package/dist/debug/expression.d.ts +0 -26
- package/dist/debug/expression.js +0 -547
- package/dist/debug/index.d.ts +0 -8
- package/dist/debug/index.js +0 -5
- package/dist/debug/language/cpp.d.ts +0 -2
- package/dist/debug/language/cpp.js +0 -7
- package/dist/debug/language/index.d.ts +0 -3
- package/dist/debug/language/index.js +0 -2
- package/dist/debug/language/python.d.ts +0 -2
- package/dist/debug/language/python.js +0 -14
- package/dist/debug/language/types.d.ts +0 -6
- package/dist/debug/locals.d.ts +0 -2
- package/dist/debug/locals.js +0 -8
- package/dist/lsp/cpp/server.d.ts +0 -2
- package/dist/lsp/cpp/server.js +0 -68
- package/dist/lsp/index.d.ts +0 -5
- package/dist/lsp/index.js +0 -4
- package/dist/lsp/python/main.worker.js +0 -92
- package/dist/lsp/python/package/arcturus_python_lsp/__init__.py +0 -3
- package/dist/lsp/python/package/arcturus_python_lsp/server.py +0 -462
- package/dist/lsp/python/server.d.ts +0 -2
- package/dist/lsp/python/server.js +0 -54
- package/dist/lsp/registry.d.ts +0 -2
- package/dist/lsp/registry.js +0 -12
- package/dist/lsp/runtime.d.ts +0 -5
- package/dist/lsp/runtime.js +0 -31
- package/dist/lsp/types.d.ts +0 -17
- package/dist/terminal/Terminal.svelte +0 -422
- package/dist/terminal/Terminal.svelte.d.ts +0 -26
- package/dist/terminal/index.d.ts +0 -7
- package/dist/terminal/index.js +0 -5
- package/dist/terminal/plugin/index.d.ts +0 -9
- package/dist/terminal/plugin/index.js +0 -19
- package/dist/terminal/theme.d.ts +0 -49
- package/dist/terminal/theme.js +0 -49
- package/dist/terminal/types.d.ts +0 -18
- package/dist/utils/vscodeJsonrpcBrowser.d.ts +0 -5
- package/dist/utils/vscodeJsonrpcBrowser.js +0 -4
- /package/dist/{clangd/worker.d.ts → playground/worker/assemblyscript.d.ts} +0 -0
- /package/dist/{debug/language/types.js → playground/worker/bash.d.ts} +0 -0
- /package/dist/{lsp/python/main.worker.d.ts → playground/worker/cobol.d.ts} +0 -0
- /package/dist/{lsp/types.js → playground/worker/d.d.ts} +0 -0
- /package/dist/{terminal/types.js → playground/worker/dotnet.d.ts} +0 -0
package/dist/lsp/cpp/server.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { resolveCppLanguageServerRuntimeAssetConfig } from '../runtime';
|
|
2
|
-
import ClangdWorker from '../../clangd/worker?worker';
|
|
3
|
-
import { WorkerAssetBridge } from '../../playground/assetBridge';
|
|
4
|
-
import { BrowserMessageReader, BrowserMessageWriter } from '../../utils/vscodeJsonrpcBrowser';
|
|
5
|
-
const currentUrl = () => globalThis.location?.href || '';
|
|
6
|
-
async function createServer(assetConfig) {
|
|
7
|
-
let resolveReady = () => { };
|
|
8
|
-
let rejectReady = (_error) => { };
|
|
9
|
-
const ready = new Promise((resolve, reject) => {
|
|
10
|
-
resolveReady = resolve;
|
|
11
|
-
rejectReady = reject;
|
|
12
|
-
});
|
|
13
|
-
const worker = new ClangdWorker();
|
|
14
|
-
const assetBridge = new WorkerAssetBridge(worker, 'clangd', assetConfig);
|
|
15
|
-
const cleanup = () => {
|
|
16
|
-
worker.removeEventListener('message', readyListener);
|
|
17
|
-
worker.removeEventListener('error', errorListener);
|
|
18
|
-
};
|
|
19
|
-
const readyListener = (event) => {
|
|
20
|
-
if (assetBridge.handleMessage(event))
|
|
21
|
-
return;
|
|
22
|
-
switch (event.data?.type) {
|
|
23
|
-
case 'ready': {
|
|
24
|
-
cleanup();
|
|
25
|
-
resolveReady();
|
|
26
|
-
break;
|
|
27
|
-
}
|
|
28
|
-
case 'error': {
|
|
29
|
-
cleanup();
|
|
30
|
-
rejectReady(new Error(event.data?.message || 'clangd failed to initialize'));
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
const errorListener = (event) => {
|
|
36
|
-
cleanup();
|
|
37
|
-
rejectReady(event.error || new Error(event.message || 'clangd worker failed'));
|
|
38
|
-
};
|
|
39
|
-
worker.addEventListener('message', readyListener);
|
|
40
|
-
worker.addEventListener('error', errorListener);
|
|
41
|
-
worker.postMessage({
|
|
42
|
-
type: 'init',
|
|
43
|
-
baseUrl: assetConfig.baseUrl,
|
|
44
|
-
assets: {
|
|
45
|
-
baseUrl: assetConfig.baseUrl,
|
|
46
|
-
useAssetBridge: assetConfig.useAssetBridge
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
await ready;
|
|
50
|
-
return worker;
|
|
51
|
-
}
|
|
52
|
-
export async function getCppLanguageServer(options) {
|
|
53
|
-
const assetConfig = resolveCppLanguageServerRuntimeAssetConfig(options, currentUrl());
|
|
54
|
-
const worker = await createServer(assetConfig);
|
|
55
|
-
const reader = new BrowserMessageReader(worker);
|
|
56
|
-
const writer = new BrowserMessageWriter(worker);
|
|
57
|
-
return {
|
|
58
|
-
transport: { reader, writer },
|
|
59
|
-
syncFile: (path) => {
|
|
60
|
-
worker.postMessage({ type: 'sync-file', name: path });
|
|
61
|
-
},
|
|
62
|
-
dispose: () => {
|
|
63
|
-
worker.terminate();
|
|
64
|
-
reader.dispose();
|
|
65
|
-
writer.dispose();
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
}
|
package/dist/lsp/index.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { getEditorLanguageServer } from './registry';
|
|
2
|
-
export { resolveCppLanguageServerBaseUrl, resolveCppLanguageServerRuntimeAssetConfig, resolvePythonLanguageServerBaseUrl } from './runtime';
|
|
3
|
-
export { getCppLanguageServer } from './cpp/server';
|
|
4
|
-
export { getPythonLanguageServer } from './python/server';
|
|
5
|
-
export type { EditorLanguageServerHandle, EditorLanguageServerRuntimeOptions } from './types';
|
package/dist/lsp/index.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export { getEditorLanguageServer } from './registry';
|
|
2
|
-
export { resolveCppLanguageServerBaseUrl, resolveCppLanguageServerRuntimeAssetConfig, resolvePythonLanguageServerBaseUrl } from './runtime';
|
|
3
|
-
export { getCppLanguageServer } from './cpp/server';
|
|
4
|
-
export { getPythonLanguageServer } from './python/server';
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/// <reference lib="WebWorker" />
|
|
2
|
-
import { loadPyodide } from 'pyodide';
|
|
3
|
-
import packageInitSource from './package/arcturus_python_lsp/__init__.py?raw';
|
|
4
|
-
import packageServerSource from './package/arcturus_python_lsp/server.py?raw';
|
|
5
|
-
let pyodide = null;
|
|
6
|
-
let bridge = null;
|
|
7
|
-
let initPromise = null;
|
|
8
|
-
let configuredPyodideBaseUrl = '/pyodide/';
|
|
9
|
-
function toErrorMessage(error) {
|
|
10
|
-
return error instanceof Error ? error.message : String(error);
|
|
11
|
-
}
|
|
12
|
-
function normalizeBaseUrl(baseUrl) {
|
|
13
|
-
return baseUrl.endsWith('/') ? baseUrl : `${baseUrl}/`;
|
|
14
|
-
}
|
|
15
|
-
function emitTransportMessage(payload) {
|
|
16
|
-
try {
|
|
17
|
-
self.postMessage(JSON.parse(payload));
|
|
18
|
-
}
|
|
19
|
-
catch (error) {
|
|
20
|
-
console.error('Failed to emit Python LSP payload', error, payload);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function installPythonServerPackage(currentPyodide) {
|
|
24
|
-
currentPyodide.FS.mkdirTree('/arcturus_lsp/arcturus_python_lsp');
|
|
25
|
-
currentPyodide.FS.writeFile('/arcturus_lsp/arcturus_python_lsp/__init__.py', packageInitSource);
|
|
26
|
-
currentPyodide.FS.writeFile('/arcturus_lsp/arcturus_python_lsp/server.py', packageServerSource);
|
|
27
|
-
}
|
|
28
|
-
async function bootstrapPythonBridge(pyodideBaseUrl) {
|
|
29
|
-
if (bridge)
|
|
30
|
-
return;
|
|
31
|
-
if (initPromise)
|
|
32
|
-
return initPromise;
|
|
33
|
-
initPromise = (async () => {
|
|
34
|
-
self.postMessage({ type: 'progress', stage: 'load-pyodide' });
|
|
35
|
-
pyodide = await loadPyodide({ indexURL: normalizeBaseUrl(pyodideBaseUrl) });
|
|
36
|
-
pyodide.registerJsModule('arcturus_lsp_bridge', {
|
|
37
|
-
emit: emitTransportMessage
|
|
38
|
-
});
|
|
39
|
-
await pyodide.loadPackage('jedi');
|
|
40
|
-
installPythonServerPackage(pyodide);
|
|
41
|
-
await pyodide.runPythonAsync(`
|
|
42
|
-
import sys
|
|
43
|
-
|
|
44
|
-
if "/arcturus_lsp" not in sys.path:
|
|
45
|
-
sys.path.insert(0, "/arcturus_lsp")
|
|
46
|
-
|
|
47
|
-
from arcturus_python_lsp import create_bridge
|
|
48
|
-
|
|
49
|
-
_arcturus_python_lsp_bridge = create_bridge()
|
|
50
|
-
`);
|
|
51
|
-
const bridgeProxy = pyodide.globals.get('_arcturus_python_lsp_bridge');
|
|
52
|
-
bridge = (payload) => {
|
|
53
|
-
bridgeProxy(payload);
|
|
54
|
-
};
|
|
55
|
-
self.postMessage({ type: 'ready' });
|
|
56
|
-
})().catch((error) => {
|
|
57
|
-
const message = toErrorMessage(error);
|
|
58
|
-
console.error('Python LSP bootstrap failed', error);
|
|
59
|
-
self.postMessage({ type: 'error', error: message });
|
|
60
|
-
initPromise = null;
|
|
61
|
-
bridge = null;
|
|
62
|
-
throw error;
|
|
63
|
-
});
|
|
64
|
-
return initPromise;
|
|
65
|
-
}
|
|
66
|
-
self.addEventListener('message', (event) => {
|
|
67
|
-
const payload = event.data;
|
|
68
|
-
if (!payload || typeof payload !== 'object')
|
|
69
|
-
return;
|
|
70
|
-
if (payload.type === 'init') {
|
|
71
|
-
configuredPyodideBaseUrl =
|
|
72
|
-
typeof payload.pyodideBaseUrl === 'string' ? payload.pyodideBaseUrl : '/pyodide/';
|
|
73
|
-
void bootstrapPythonBridge(configuredPyodideBaseUrl).catch((error) => {
|
|
74
|
-
console.error('Failed to initialize Python LSP worker', error);
|
|
75
|
-
});
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
if ('type' in payload)
|
|
79
|
-
return;
|
|
80
|
-
const serialized = JSON.stringify(payload);
|
|
81
|
-
if (bridge) {
|
|
82
|
-
bridge(serialized);
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
void bootstrapPythonBridge(configuredPyodideBaseUrl)
|
|
86
|
-
.then(() => {
|
|
87
|
-
bridge?.(serialized);
|
|
88
|
-
})
|
|
89
|
-
.catch((error) => {
|
|
90
|
-
console.error('Failed to forward LSP message to Python bridge', error);
|
|
91
|
-
});
|
|
92
|
-
});
|
|
@@ -1,462 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import ast
|
|
4
|
-
import json
|
|
5
|
-
from pathlib import Path
|
|
6
|
-
from urllib.parse import unquote, urlparse
|
|
7
|
-
|
|
8
|
-
from jedi import Project, Script
|
|
9
|
-
|
|
10
|
-
from arcturus_lsp_bridge import emit
|
|
11
|
-
|
|
12
|
-
SERVER_NAME = "arcturus-python-lsp"
|
|
13
|
-
SERVER_VERSION = "0.2.0"
|
|
14
|
-
WORKSPACE_ROOT = "/workspace"
|
|
15
|
-
|
|
16
|
-
TEXT_DOCUMENT_SYNC_FULL = 1
|
|
17
|
-
DIAGNOSTIC_SEVERITY_ERROR = 1
|
|
18
|
-
|
|
19
|
-
COMPLETION_ITEM_KIND = {
|
|
20
|
-
"text": 1,
|
|
21
|
-
"method": 2,
|
|
22
|
-
"function": 3,
|
|
23
|
-
"constructor": 4,
|
|
24
|
-
"field": 5,
|
|
25
|
-
"variable": 6,
|
|
26
|
-
"class": 7,
|
|
27
|
-
"interface": 8,
|
|
28
|
-
"module": 9,
|
|
29
|
-
"property": 10,
|
|
30
|
-
"unit": 11,
|
|
31
|
-
"value": 12,
|
|
32
|
-
"enum": 13,
|
|
33
|
-
"keyword": 14,
|
|
34
|
-
"snippet": 15,
|
|
35
|
-
"color": 16,
|
|
36
|
-
"file": 17,
|
|
37
|
-
"reference": 18,
|
|
38
|
-
"folder": 19,
|
|
39
|
-
"enumMember": 20,
|
|
40
|
-
"constant": 21,
|
|
41
|
-
"struct": 22,
|
|
42
|
-
"event": 23,
|
|
43
|
-
"operator": 24,
|
|
44
|
-
"typeParameter": 25,
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
SYMBOL_KIND = {
|
|
48
|
-
"file": 1,
|
|
49
|
-
"module": 2,
|
|
50
|
-
"namespace": 3,
|
|
51
|
-
"package": 4,
|
|
52
|
-
"class": 5,
|
|
53
|
-
"method": 6,
|
|
54
|
-
"property": 7,
|
|
55
|
-
"field": 8,
|
|
56
|
-
"constructor": 9,
|
|
57
|
-
"enum": 10,
|
|
58
|
-
"interface": 11,
|
|
59
|
-
"function": 12,
|
|
60
|
-
"variable": 13,
|
|
61
|
-
"constant": 14,
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
COMPLETION_KIND_MAP = {
|
|
65
|
-
"module": COMPLETION_ITEM_KIND["module"],
|
|
66
|
-
"class": COMPLETION_ITEM_KIND["class"],
|
|
67
|
-
"instance": COMPLETION_ITEM_KIND["variable"],
|
|
68
|
-
"function": COMPLETION_ITEM_KIND["function"],
|
|
69
|
-
"param": COMPLETION_ITEM_KIND["variable"],
|
|
70
|
-
"path": COMPLETION_ITEM_KIND["file"],
|
|
71
|
-
"keyword": COMPLETION_ITEM_KIND["keyword"],
|
|
72
|
-
"statement": COMPLETION_ITEM_KIND["keyword"],
|
|
73
|
-
"property": COMPLETION_ITEM_KIND["property"],
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
SYMBOL_KIND_MAP = {
|
|
77
|
-
"module": SYMBOL_KIND["module"],
|
|
78
|
-
"class": SYMBOL_KIND["class"],
|
|
79
|
-
"function": SYMBOL_KIND["function"],
|
|
80
|
-
"statement": SYMBOL_KIND["variable"],
|
|
81
|
-
"instance": SYMBOL_KIND["variable"],
|
|
82
|
-
"param": SYMBOL_KIND["variable"],
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
def _uri_to_path(uri: str) -> str:
|
|
87
|
-
if uri.startswith("file://"):
|
|
88
|
-
return unquote(urlparse(uri).path)
|
|
89
|
-
|
|
90
|
-
parsed = urlparse(uri)
|
|
91
|
-
if parsed.scheme and parsed.path:
|
|
92
|
-
return unquote(parsed.path)
|
|
93
|
-
|
|
94
|
-
return uri
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
def _path_to_uri(path: Path) -> str:
|
|
98
|
-
return path.as_posix()
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
class Document:
|
|
102
|
-
def __init__(
|
|
103
|
-
self,
|
|
104
|
-
uri: str,
|
|
105
|
-
source: str,
|
|
106
|
-
version: int | None = None,
|
|
107
|
-
language_id: str | None = None,
|
|
108
|
-
) -> None:
|
|
109
|
-
self.uri = uri
|
|
110
|
-
self.source = source
|
|
111
|
-
self.version = version
|
|
112
|
-
self.language_id = language_id
|
|
113
|
-
self.path = _uri_to_path(uri)
|
|
114
|
-
|
|
115
|
-
@property
|
|
116
|
-
def lines(self) -> list[str]:
|
|
117
|
-
lines = self.source.splitlines(True)
|
|
118
|
-
return lines or [""]
|
|
119
|
-
|
|
120
|
-
def offset_at(self, position: dict) -> int:
|
|
121
|
-
line = max(int(position.get("line", 0)), 0)
|
|
122
|
-
character = max(int(position.get("character", 0)), 0)
|
|
123
|
-
lines = self.lines
|
|
124
|
-
if line >= len(lines):
|
|
125
|
-
return len(self.source)
|
|
126
|
-
|
|
127
|
-
offset = sum(len(lines[idx]) for idx in range(line))
|
|
128
|
-
return offset + min(character, len(lines[line]))
|
|
129
|
-
|
|
130
|
-
def apply_change(self, change: dict) -> None:
|
|
131
|
-
if "range" not in change or change["range"] is None:
|
|
132
|
-
self.source = change.get("text", "")
|
|
133
|
-
return
|
|
134
|
-
|
|
135
|
-
change_range = change["range"]
|
|
136
|
-
start = self.offset_at(change_range["start"])
|
|
137
|
-
end = self.offset_at(change_range["end"])
|
|
138
|
-
self.source = self.source[:start] + change.get("text", "") + self.source[end:]
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
class ArcturusPythonLsp:
|
|
142
|
-
def __init__(self) -> None:
|
|
143
|
-
self.workspace_root = WORKSPACE_ROOT
|
|
144
|
-
Path(self.workspace_root).mkdir(parents=True, exist_ok=True)
|
|
145
|
-
self.project = Project(
|
|
146
|
-
path=self.workspace_root,
|
|
147
|
-
smart_sys_path=True,
|
|
148
|
-
load_unsafe_extensions=False,
|
|
149
|
-
)
|
|
150
|
-
self.documents: dict[str, Document] = {}
|
|
151
|
-
self.shutdown_requested = False
|
|
152
|
-
|
|
153
|
-
def handle(self, payload: str) -> None:
|
|
154
|
-
message = json.loads(payload)
|
|
155
|
-
if message.get("jsonrpc") != "2.0":
|
|
156
|
-
return
|
|
157
|
-
|
|
158
|
-
method = message.get("method")
|
|
159
|
-
if not method:
|
|
160
|
-
return
|
|
161
|
-
|
|
162
|
-
if "id" in message:
|
|
163
|
-
self._handle_request(message["id"], method, message.get("params") or {})
|
|
164
|
-
else:
|
|
165
|
-
self._handle_notification(method, message.get("params") or {})
|
|
166
|
-
|
|
167
|
-
def _emit(self, body: dict) -> None:
|
|
168
|
-
emit(json.dumps(body))
|
|
169
|
-
|
|
170
|
-
def _respond(self, msg_id, result=None, error: dict | None = None) -> None:
|
|
171
|
-
response = {"jsonrpc": "2.0", "id": msg_id}
|
|
172
|
-
if error is not None:
|
|
173
|
-
response["error"] = error
|
|
174
|
-
else:
|
|
175
|
-
response["result"] = result
|
|
176
|
-
self._emit(response)
|
|
177
|
-
|
|
178
|
-
def _notify(self, method: str, params: dict) -> None:
|
|
179
|
-
self._emit({"jsonrpc": "2.0", "method": method, "params": params})
|
|
180
|
-
|
|
181
|
-
def _refresh_project(self, root_uri: str | None) -> None:
|
|
182
|
-
if root_uri:
|
|
183
|
-
self.workspace_root = _uri_to_path(root_uri)
|
|
184
|
-
|
|
185
|
-
Path(self.workspace_root).mkdir(parents=True, exist_ok=True)
|
|
186
|
-
self.project = Project(
|
|
187
|
-
path=self.workspace_root,
|
|
188
|
-
smart_sys_path=True,
|
|
189
|
-
load_unsafe_extensions=False,
|
|
190
|
-
)
|
|
191
|
-
|
|
192
|
-
def _document(self, uri: str) -> Document:
|
|
193
|
-
return self.documents[uri]
|
|
194
|
-
|
|
195
|
-
def _mirror_document(self, uri: str) -> None:
|
|
196
|
-
document = self._document(uri)
|
|
197
|
-
path = Path(document.path)
|
|
198
|
-
path.parent.mkdir(parents=True, exist_ok=True)
|
|
199
|
-
path.write_text(document.source, encoding="utf-8")
|
|
200
|
-
|
|
201
|
-
def _script(self, uri: str) -> Script:
|
|
202
|
-
document = self._document(uri)
|
|
203
|
-
return Script(code=document.source, path=document.path, project=self.project)
|
|
204
|
-
|
|
205
|
-
def _range_for_name(self, name) -> dict | None:
|
|
206
|
-
if name.line is None or name.column is None:
|
|
207
|
-
return None
|
|
208
|
-
|
|
209
|
-
return {
|
|
210
|
-
"start": {"line": name.line - 1, "character": name.column},
|
|
211
|
-
"end": {"line": name.line - 1, "character": name.column + len(name.name)},
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
def _location_for_name(self, name, fallback_uri: str) -> dict | None:
|
|
215
|
-
range_value = self._range_for_name(name)
|
|
216
|
-
if range_value is None:
|
|
217
|
-
return None
|
|
218
|
-
|
|
219
|
-
module_path = getattr(name, "module_path", None)
|
|
220
|
-
uri = fallback_uri
|
|
221
|
-
if module_path is not None:
|
|
222
|
-
uri = _path_to_uri(Path(module_path))
|
|
223
|
-
|
|
224
|
-
return {"uri": uri, "range": range_value}
|
|
225
|
-
|
|
226
|
-
def _completion_kind(self, name_type: str) -> int:
|
|
227
|
-
return COMPLETION_KIND_MAP.get(name_type, COMPLETION_ITEM_KIND["text"])
|
|
228
|
-
|
|
229
|
-
def _symbol_kind(self, name_type: str) -> int:
|
|
230
|
-
return SYMBOL_KIND_MAP.get(name_type, SYMBOL_KIND["variable"])
|
|
231
|
-
|
|
232
|
-
def _publish_diagnostics(self, uri: str) -> None:
|
|
233
|
-
document = self._document(uri)
|
|
234
|
-
diagnostics: list[dict] = []
|
|
235
|
-
|
|
236
|
-
try:
|
|
237
|
-
ast.parse(document.source, filename=document.path)
|
|
238
|
-
except SyntaxError as error:
|
|
239
|
-
line = max((error.lineno or 1) - 1, 0)
|
|
240
|
-
column = max((error.offset or 1) - 1, 0)
|
|
241
|
-
diagnostics.append(
|
|
242
|
-
{
|
|
243
|
-
"range": {
|
|
244
|
-
"start": {"line": line, "character": column},
|
|
245
|
-
"end": {"line": line, "character": column + 1},
|
|
246
|
-
},
|
|
247
|
-
"severity": DIAGNOSTIC_SEVERITY_ERROR,
|
|
248
|
-
"source": SERVER_NAME,
|
|
249
|
-
"message": error.msg or "Syntax error",
|
|
250
|
-
}
|
|
251
|
-
)
|
|
252
|
-
|
|
253
|
-
self._notify(
|
|
254
|
-
"textDocument/publishDiagnostics",
|
|
255
|
-
{"uri": uri, "diagnostics": diagnostics},
|
|
256
|
-
)
|
|
257
|
-
|
|
258
|
-
def _hover_text(self, definitions) -> str | None:
|
|
259
|
-
chunks: list[str] = []
|
|
260
|
-
for definition in definitions:
|
|
261
|
-
description = getattr(definition, "description", "") or definition.name
|
|
262
|
-
doc = definition.docstring(raw=False).strip()
|
|
263
|
-
block = description if not doc else f"{description}\n\n{doc}"
|
|
264
|
-
if block and block not in chunks:
|
|
265
|
-
chunks.append(block)
|
|
266
|
-
|
|
267
|
-
if not chunks:
|
|
268
|
-
return None
|
|
269
|
-
|
|
270
|
-
return "\n\n---\n\n".join(chunks)
|
|
271
|
-
|
|
272
|
-
def _initialize(self, params: dict) -> dict:
|
|
273
|
-
root_uri = params.get("rootUri")
|
|
274
|
-
if not root_uri and params.get("workspaceFolders"):
|
|
275
|
-
root_uri = params["workspaceFolders"][0].get("uri")
|
|
276
|
-
self._refresh_project(root_uri)
|
|
277
|
-
return {
|
|
278
|
-
"capabilities": {
|
|
279
|
-
"textDocumentSync": TEXT_DOCUMENT_SYNC_FULL,
|
|
280
|
-
"completionProvider": {
|
|
281
|
-
"triggerCharacters": [".", "(", "[", '"', "'"],
|
|
282
|
-
"resolveProvider": False,
|
|
283
|
-
},
|
|
284
|
-
"hoverProvider": True,
|
|
285
|
-
"definitionProvider": True,
|
|
286
|
-
"documentSymbolProvider": True,
|
|
287
|
-
"signatureHelpProvider": {"triggerCharacters": ["(", ","]},
|
|
288
|
-
},
|
|
289
|
-
"serverInfo": {"name": SERVER_NAME, "version": SERVER_VERSION},
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
def _shutdown(self):
|
|
293
|
-
self.shutdown_requested = True
|
|
294
|
-
return None
|
|
295
|
-
|
|
296
|
-
def _completion(self, params: dict) -> dict:
|
|
297
|
-
position = params["position"]
|
|
298
|
-
completions = self._script(params["textDocument"]["uri"]).complete(
|
|
299
|
-
line=position["line"] + 1,
|
|
300
|
-
column=position["character"],
|
|
301
|
-
)
|
|
302
|
-
items = []
|
|
303
|
-
for completion in completions:
|
|
304
|
-
item = {
|
|
305
|
-
"label": completion.name_with_symbols or completion.name,
|
|
306
|
-
"kind": self._completion_kind(completion.type),
|
|
307
|
-
"detail": completion.type,
|
|
308
|
-
"insertText": completion.complete or completion.name,
|
|
309
|
-
}
|
|
310
|
-
doc = completion.docstring(raw=False).strip()
|
|
311
|
-
if doc:
|
|
312
|
-
item["documentation"] = doc
|
|
313
|
-
items.append(item)
|
|
314
|
-
return {"isIncomplete": False, "items": items}
|
|
315
|
-
|
|
316
|
-
def _signature_help(self, params: dict) -> dict | None:
|
|
317
|
-
position = params["position"]
|
|
318
|
-
signatures = self._script(params["textDocument"]["uri"]).get_signatures(
|
|
319
|
-
line=position["line"] + 1,
|
|
320
|
-
column=position["character"],
|
|
321
|
-
)
|
|
322
|
-
if not signatures:
|
|
323
|
-
return None
|
|
324
|
-
|
|
325
|
-
items = []
|
|
326
|
-
for signature in signatures:
|
|
327
|
-
items.append(
|
|
328
|
-
{
|
|
329
|
-
"label": signature.to_string(),
|
|
330
|
-
"documentation": signature.docstring(raw=False).strip() or None,
|
|
331
|
-
"parameters": [
|
|
332
|
-
{"label": parameter.to_string()} for parameter in signature.params
|
|
333
|
-
],
|
|
334
|
-
}
|
|
335
|
-
)
|
|
336
|
-
|
|
337
|
-
return {"signatures": items, "activeSignature": 0, "activeParameter": 0}
|
|
338
|
-
|
|
339
|
-
def _hover(self, params: dict) -> dict | None:
|
|
340
|
-
position = params["position"]
|
|
341
|
-
definitions = self._script(params["textDocument"]["uri"]).infer(
|
|
342
|
-
line=position["line"] + 1,
|
|
343
|
-
column=position["character"],
|
|
344
|
-
)
|
|
345
|
-
hover_text = self._hover_text(definitions)
|
|
346
|
-
if not hover_text:
|
|
347
|
-
return None
|
|
348
|
-
return {"contents": {"kind": "markdown", "value": hover_text}}
|
|
349
|
-
|
|
350
|
-
def _definition(self, params: dict) -> list[dict] | None:
|
|
351
|
-
position = params["position"]
|
|
352
|
-
definitions = self._script(params["textDocument"]["uri"]).goto(
|
|
353
|
-
line=position["line"] + 1,
|
|
354
|
-
column=position["character"],
|
|
355
|
-
follow_imports=True,
|
|
356
|
-
follow_builtin_imports=True,
|
|
357
|
-
)
|
|
358
|
-
locations = [
|
|
359
|
-
location
|
|
360
|
-
for location in (
|
|
361
|
-
self._location_for_name(definition, params["textDocument"]["uri"])
|
|
362
|
-
for definition in definitions
|
|
363
|
-
)
|
|
364
|
-
if location is not None
|
|
365
|
-
]
|
|
366
|
-
return locations or None
|
|
367
|
-
|
|
368
|
-
def _document_symbols(self, params: dict) -> list[dict]:
|
|
369
|
-
names = self._script(params["textDocument"]["uri"]).get_names(
|
|
370
|
-
all_scopes=True,
|
|
371
|
-
definitions=True,
|
|
372
|
-
references=False,
|
|
373
|
-
)
|
|
374
|
-
symbols = []
|
|
375
|
-
for name in names:
|
|
376
|
-
location = self._location_for_name(name, params["textDocument"]["uri"])
|
|
377
|
-
if location is None:
|
|
378
|
-
continue
|
|
379
|
-
symbols.append(
|
|
380
|
-
{
|
|
381
|
-
"name": name.name,
|
|
382
|
-
"kind": self._symbol_kind(name.type),
|
|
383
|
-
"location": location,
|
|
384
|
-
"containerName": getattr(name, "full_name", None) or name.name,
|
|
385
|
-
}
|
|
386
|
-
)
|
|
387
|
-
return symbols
|
|
388
|
-
|
|
389
|
-
def _handle_request(self, msg_id, method: str, params: dict) -> None:
|
|
390
|
-
try:
|
|
391
|
-
handlers = {
|
|
392
|
-
"initialize": self._initialize,
|
|
393
|
-
"shutdown": self._shutdown,
|
|
394
|
-
"textDocument/completion": self._completion,
|
|
395
|
-
"textDocument/signatureHelp": self._signature_help,
|
|
396
|
-
"textDocument/hover": self._hover,
|
|
397
|
-
"textDocument/definition": self._definition,
|
|
398
|
-
"textDocument/documentSymbol": self._document_symbols,
|
|
399
|
-
}
|
|
400
|
-
handler = handlers.get(method)
|
|
401
|
-
if handler is None:
|
|
402
|
-
self._respond(
|
|
403
|
-
msg_id,
|
|
404
|
-
error={"code": -32601, "message": f"Method not found: {method}"},
|
|
405
|
-
)
|
|
406
|
-
return
|
|
407
|
-
self._respond(msg_id, result=handler(params))
|
|
408
|
-
except Exception as error:
|
|
409
|
-
self._respond(
|
|
410
|
-
msg_id,
|
|
411
|
-
error={"code": -32603, "message": str(error) or "Internal server error"},
|
|
412
|
-
)
|
|
413
|
-
|
|
414
|
-
def _handle_notification(self, method: str, params: dict) -> None:
|
|
415
|
-
try:
|
|
416
|
-
if method == "initialized":
|
|
417
|
-
return
|
|
418
|
-
if method == "exit":
|
|
419
|
-
self.shutdown_requested = True
|
|
420
|
-
return
|
|
421
|
-
if method == "textDocument/didOpen":
|
|
422
|
-
text_document = params["textDocument"]
|
|
423
|
-
self.documents[text_document["uri"]] = Document(
|
|
424
|
-
uri=text_document["uri"],
|
|
425
|
-
source=text_document.get("text", ""),
|
|
426
|
-
version=text_document.get("version"),
|
|
427
|
-
language_id=text_document.get("languageId"),
|
|
428
|
-
)
|
|
429
|
-
self._mirror_document(text_document["uri"])
|
|
430
|
-
self._publish_diagnostics(text_document["uri"])
|
|
431
|
-
return
|
|
432
|
-
if method == "textDocument/didChange":
|
|
433
|
-
text_document = params["textDocument"]
|
|
434
|
-
document = self._document(text_document["uri"])
|
|
435
|
-
for change in params.get("contentChanges", []):
|
|
436
|
-
document.apply_change(change)
|
|
437
|
-
document.version = text_document.get("version")
|
|
438
|
-
self._mirror_document(text_document["uri"])
|
|
439
|
-
self._publish_diagnostics(text_document["uri"])
|
|
440
|
-
return
|
|
441
|
-
if method == "textDocument/didSave":
|
|
442
|
-
text_document = params["textDocument"]
|
|
443
|
-
document = self._document(text_document["uri"])
|
|
444
|
-
if "text" in params and params["text"] is not None:
|
|
445
|
-
document.source = params["text"]
|
|
446
|
-
self._mirror_document(text_document["uri"])
|
|
447
|
-
self._publish_diagnostics(text_document["uri"])
|
|
448
|
-
return
|
|
449
|
-
if method == "textDocument/didClose":
|
|
450
|
-
text_document = params["textDocument"]
|
|
451
|
-
self.documents.pop(text_document["uri"], None)
|
|
452
|
-
self._notify(
|
|
453
|
-
"textDocument/publishDiagnostics",
|
|
454
|
-
{"uri": text_document["uri"], "diagnostics": []},
|
|
455
|
-
)
|
|
456
|
-
except Exception:
|
|
457
|
-
return
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
def create_bridge():
|
|
461
|
-
server = ArcturusPythonLsp()
|
|
462
|
-
return server.handle
|