• Home
Name Date Size #Lines LOC

..--

native/22-Oct-2025-5,6224,592

src/22-Oct-2025-5,0844,088

test/22-Oct-2025-4,2914,025

.gitignoreD22-Oct-202594 88

.prettierignoreD22-Oct-2025662 2422

.prettierrc.jsonD22-Oct-2025180 1110

BUILD.gnD22-Oct-20259.7 KiB402375

CMakeLists.txtD22-Oct-2025632 1614

README.mdD22-Oct-20251.6 KiB6649

build_bindings.pyD22-Oct-20253.2 KiB9559

package.jsonD22-Oct-2025865 3029

tsconfig.jsonD22-Oct-2025533 2524

README.md

1# Test lsp api
2
3Currently ts lsp api in WIP, this way is only while it's in wip. Later it will change
4
5## Changes due to WIP
6
7change path from you future build dir in files:
8- Change $BINDINGS_PATH variable library path in files
9  1. bindings/src/Es2pandaNativeModule.ts in functions `registerNativeModuleLibraryName`
10  2. bindings/src/InteropNativeModule.ts in the same function `registerNativeModuleLibraryName`
11
12- If you need to add new lsp method:
13  1. add it into `.ts` src/Es2pandaNativeModule.ts check for example `_getCurrentTokenValue` method
14  2. add into `native/src/lsp.cpp` method with macro for example `impl_getCurrentTokenValue`
15  3. check `lspNode.ts` file, whether you api's node exists. if not add here new class like other, with extending `LspNode` class
16  4. add to `public.ts` file method which uses underhood c-api, and pass pointer (peer) to object constructor, after this file will be changed to separate lsp file
17
18## Build:
19target:
20```
21  ninja ts_bindings
22```
23
24transpile tsbindings:
25
26```
27  cd es2panda/bindings
28  npm i
29  npm run run
30  npm link
31```
32
33link with npm lib your code locally
34
35```
36  npm link @es2panda/bindings
37```
38
39## Usage
40
41check `lsp_api.ts` file
42```ts
43import { Lsp } from "@es2panda/bindings"
44let lsp = new Lsp()
45
46let def = lsp.getDefinitionAtPosition("/path/to/panda/ets_frontend/ets2panda/foo/f2.ets", 70)
47console.log(def)
48
49let foo = lsp.getSemanticDiagnostics("/path/to/panda/ets_frontend/ets2panda/foo/f3.ets")
50console.log(foo)
51```
52
53for tests we need add to devDeps in package.json
54```json
55  "@types/node": "^22.13.5"
56```
57
58in tsconfig.json add
59
60```json
61  "moduleResolution": "node",
62  "lib": [
63    "es2017"
64  ]
65```
66