Skip to content

Commit 8775463

Browse files
Update api and general refactoring (#127)
* Deprecate api endpoint * Switch npm version to v24 lts * Update eslint dependency version * Refactoring * Move languages to separate file * re enabled getTreeForUri * Make get tree synchronous again
1 parent 0796cd2 commit 8775463

File tree

13 files changed

+469
-401
lines changed

13 files changed

+469
-401
lines changed

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v25.0.0
1+
v24.14.0

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
All notable changes to the "vscode-parse-tree" extension will be documented in this file.
44

5+
## 0.51.0 (12 Mar 2026)
6+
7+
Removed deprecated api endpoints:
8+
9+
- `getLanguage` - Replaced by `createQuery`
10+
- `getNodeAtLocation` - No direct replacement. Use scm queries and `createQuery` instead.
11+
- `registerLanguage` - No replacement. We don't believe anyone is using this.
12+
513
## 0.33.0 (22 Apr 2025)
614

715
### Enhancements

README.md

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Parse tree
22

3-
Exposes an api function that can be used to get a parse tree node for a given file location.
3+
Exposes an api function that can be used to get a parse tree for a given file.
44

55
## Usage
66

@@ -13,25 +13,13 @@ if (parseTreeExtension == null) {
1313
throw new Error("Depends on pokey.parse-tree extension");
1414
}
1515

16-
const { getNodeAtLocation } = await parseTreeExtension.activate();
16+
const { loadLanguage } = await parseTreeExtension.activate();
1717
```
1818

1919
Don't forget to add an `extensionDependencies`-entry to `package.json` as
2020
described in
2121
https://code.visualstudio.com/api/references/vscode-api#extensions.
2222

23-
### Parsing a custom language
24-
25-
If you'd like to add support for a new language, see the [Adding a new language](#adding-a-new-language) section below. Alternatively, your extension can register a custom language with this extension. Although this is not the preferred way to add a new language, it can be convenient when you have a parser that you don't believe belongs in the main extension.
26-
27-
Parsing your own language is as simple as registering your `languageId` with an absolute path to your `.wasm` file:
28-
29-
```ts
30-
const { registerLanguage } = await parseTreeExtension.activate();
31-
32-
registerLanguage(languageId, wasmPath);
33-
```
34-
3523
## Contributing
3624

3725
### Setup
@@ -43,7 +31,7 @@ registerLanguage(languageId, wasmPath);
4331
It's straightforward to add any [language with a tree-sitter grammar](https://tree-sitter.github.io/tree-sitter/).
4432

4533
1. Add a dependency on the npm package for that language in [tree-sitter-wasms](https://github.com/cursorless-dev/tree-sitter-wasms)
46-
2. Add a language to the dictionary at the top of `./src/extension.ts`
34+
2. Add a language to the map in [`languages.ts`](./src/languages.ts)
4735
3. Add a reference to `onLanguage:yourlang` to the [activationEvents section of package.json](package.json). `yourlang` must be a [VSCode language identifier](https://code.visualstudio.com/docs/languages/identifiers).
4836
4. Run `npm install` and `npm run compile`, then hit `F5` in VSCode, with this project open, to test your changes.
4937
5. Submit a PR!

0 commit comments

Comments
 (0)