Test lsp api
Currently ts lsp api in WIP, this way is only while it's in wip. Later it will change
Changes due to WIP
change path from you future build dir in files:
-
Change $BINDINGS_PATH variable library path in files
- bindings/src/Es2pandaNativeModule.ts in functions
registerNativeModuleLibraryName - bindings/src/InteropNativeModule.ts in the same function
registerNativeModuleLibraryName
- bindings/src/Es2pandaNativeModule.ts in functions
-
If you need to add new lsp method:
- add it into
.tssrc/Es2pandaNativeModule.ts check for example_getCurrentTokenValuemethod - add into
native/src/lsp.cppmethod with macro for exampleimpl_getCurrentTokenValue - check
lspNode.tsfile, whether you api's node exists. if not add here new class like other, with extendingLspNodeclass - add to
public.tsfile method which uses underhood c-api, and pass pointer (peer) to object constructor, after this file will be changed to separate lsp file
- add it into
Build:
target:
ninja ts_bindings
transpile tsbindings:
cd es2panda/bindings
npm i
npm run run
npm link
link with npm lib your code locally
npm link @es2panda/bindings
Usage
check lsp_api.ts file
import { Lsp } from "@es2panda/bindings"
let lsp = new Lsp()
let def = lsp.getDefinitionAtPosition("/path/to/panda/ets_frontend/ets2panda/foo/f2.ets", 70)
console.log(def)
let foo = lsp.getSemanticDiagnostics("/path/to/panda/ets_frontend/ets2panda/foo/f3.ets")
console.log(foo)
for tests we need add to devDeps in package.json
"@types/node": "^22.13.5"
in tsconfig.json add
"moduleResolution": "node",
"lib": [
"es2017"
]