Skip to content

Commit 6c15586

Browse files
alexr00rebornix
andauthored
Add telemtry for how long it takes to parse files with tree-sitter (microsoft#213565)
* Make space for tree sitter * Add the tree sitter wasm file * Very naive tree-sitter syntax highlighting for html, with a layer breaker * Update tree when content changes * WIP for making abstract tokens class * Handle theme changes * Replace entire text model value with parse callback * Perf improvements * Add tree-sitter-typescript * Add typescript + better initial parsing * Refactor into tree parsing service and fix flaw in parse callback * Remove things that aren't the parser service * Add yielding * Remove changes that aren't required for PR * Remove more file changes * Reduce yield to 50 ms * Fix incremental parsing * Try update node-abi * Revert "Try update node-abi" This reverts commit df28801. * Update text buffer chunk api * fix build * Remove tree-sitter dependency * Adopt new, as yet unpublished, `@vscode/tree-sitter-wasm` package * Use published `@vscode/tree-sitter-wasm` package * Break `TreeSitterTree` and `TreeSitterParserService` into better pieces and: - document the order of editor changes - use service injection where `TextModel` is constructed * Fix tests * Remove unneeded import * Fix missing tree-sitter-wasm in web and remote * Make package.jsons match * Add @vscode/tree-sitter-wasm to web loader config * Try using importAMDNodeModule * PR feedback * Add race condition test for changing language while loading language * Use same timeout * Queue content changes * Remove override dispose * Move queue into TreeSitterTree --------- Co-authored-by: Peng Lyu <[email protected]>
1 parent 22e3447 commit 6c15586

29 files changed

+670
-71
lines changed

.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,8 @@
755755
"vs/base/~",
756756
"vs/base/parts/*/~",
757757
"vs/platform/*/~",
758-
"vs/editor/~"
758+
"vs/editor/~",
759+
"@vscode/tree-sitter-wasm" // node module allowed even in /common/
759760
]
760761
},
761762
{

build/.webignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ vscode-textmate/webpack.config.js
3838

3939
# This makes sure the model is included in the package
4040
!@vscode/vscode-languagedetection/model/**
41+
!@vscode/tree-sitter-wasm/wasm/**
4142

4243
# Ensure only the required telemetry pieces are loaded in web to reduce bundle size
4344
@microsoft/1ds-core-js/**

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
"@vscode/spdlog": "^0.15.0",
7979
"@vscode/sqlite3": "5.1.6-vscode",
8080
"@vscode/sudo-prompt": "9.3.1",
81+
"@vscode/tree-sitter-wasm": "^0.0.1",
8182
"@vscode/vscode-languagedetection": "1.0.21",
8283
"@vscode/windows-mutex": "^0.5.0",
8384
"@vscode/windows-process-tree": "^0.6.0",

remote/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"@vscode/proxy-agent": "^0.22.0",
1212
"@vscode/ripgrep": "^1.15.9",
1313
"@vscode/spdlog": "^0.15.0",
14+
"@vscode/tree-sitter-wasm": "^0.0.1",
1415
"@vscode/vscode-languagedetection": "1.0.21",
1516
"@vscode/windows-process-tree": "^0.6.0",
1617
"@vscode/windows-registry": "^1.1.0",

remote/web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"@microsoft/1ds-core-js": "^3.2.13",
77
"@microsoft/1ds-post-js": "^3.2.13",
88
"@vscode/iconv-lite-umd": "0.7.0",
9+
"@vscode/tree-sitter-wasm": "^0.0.1",
910
"@vscode/vscode-languagedetection": "1.0.21",
1011
"@xterm/addon-clipboard": "0.2.0-beta.34",
1112
"@xterm/addon-image": "0.9.0-beta.51",

remote/web/yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@
4343
resolved "https://registry.yarnpkg.com/@vscode/iconv-lite-umd/-/iconv-lite-umd-0.7.0.tgz#d2f1e0664ee6036408f9743fee264ea0699b0e48"
4444
integrity sha512-bRRFxLfg5dtAyl5XyiVWz/ZBPahpOpPrNYnnHpOpUZvam4tKH35wdhP4Kj6PbM0+KdliOsPzbGWpkxcdpNB/sg==
4545

46+
"@vscode/tree-sitter-wasm@^0.0.1":
47+
version "0.0.1"
48+
resolved "https://registry.yarnpkg.com/@vscode/tree-sitter-wasm/-/tree-sitter-wasm-0.0.1.tgz#ffb2e295a416698f4c77cbffeca3b28567d6754b"
49+
integrity sha512-m0GKnQ3BxWnVd+20KLGwr1+Qvt/RiiaJmKAqHNU35pNydDtduUzyBm7ETz/T0vOVKoeIAaiYsJOA1aKWs7Y1tA==
50+
4651
4752
version "1.0.21"
4853
resolved "https://registry.yarnpkg.com/@vscode/vscode-languagedetection/-/vscode-languagedetection-1.0.21.tgz#89b48f293f6aa3341bb888c1118d16ff13b032d3"

remote/yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@
9898
mkdirp "^1.0.4"
9999
node-addon-api "7.1.0"
100100

101+
"@vscode/tree-sitter-wasm@^0.0.1":
102+
version "0.0.1"
103+
resolved "https://registry.yarnpkg.com/@vscode/tree-sitter-wasm/-/tree-sitter-wasm-0.0.1.tgz#ffb2e295a416698f4c77cbffeca3b28567d6754b"
104+
integrity sha512-m0GKnQ3BxWnVd+20KLGwr1+Qvt/RiiaJmKAqHNU35pNydDtduUzyBm7ETz/T0vOVKoeIAaiYsJOA1aKWs7Y1tA==
105+
101106
102107
version "1.0.21"
103108
resolved "https://registry.yarnpkg.com/@vscode/vscode-languagedetection/-/vscode-languagedetection-1.0.21.tgz#89b48f293f6aa3341bb888c1118d16ff13b032d3"

src/bootstrap-window.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ const isESM = false;
197197
// using a fallback such as node.js require which does not exist in sandbox
198198
const baseNodeModulesPath = isDev ? '../node_modules' : '../node_modules.asar';
199199
loaderConfig.paths = {
200+
'@vscode/tree-sitter-wasm': `${baseNodeModulesPath}/@vscode/tree-sitter-wasm/wasm/tree-sitter.js`,
200201
'vscode-textmate': `${baseNodeModulesPath}/vscode-textmate/release/main.js`,
201202
'vscode-oniguruma': `${baseNodeModulesPath}/vscode-oniguruma/release/main.js`,
202203
'vsda': `${baseNodeModulesPath}/vsda/index.js`,

0 commit comments

Comments
 (0)