Skip to content

Removing tree sitter hack and upgrading dependencies #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
# See https://www.npmjs.com/package/web-tree-sitter
LANGUAGES = agda bash c c-sharp clojure cpp css go haskell html java javascript json latex markdown php python query ruby rust scala scss sparql tsx typescript yaml


# NOTE: Update the version number in the filepath for web-tree-sitter in package.json,
# when you change this version number.
TREE_SITTER_VERSION := 0.20.4


# Build web-tree-sitter parsers for $(LANGUAGES)

.PHONY: parsers
Expand All @@ -32,32 +26,3 @@ parsers/tree-sitter-c-sharp.wasm: node_modules/tree-sitter-c-sharp/package.json
mkdir -p $(dir $@)
npx tree-sitter build-wasm $(dir $^)
mv tree-sitter-c_sharp.wasm $@


# Build web-tree-sitter

WEB_TREE_SITTER_FILES := README.md package.json tree-sitter-web.d.ts tree-sitter.js tree-sitter.wasm
WEB_TREE_SITTER_DIR := vendor/web-tree-sitter/$(TREE_SITTER_VERSION)
WEB_TREE_SITTER_PATCH := patches/tree-sitter+$(TREE_SITTER_VERSION).patch

MAKE_CACHE_DIR := .make-work

.PHONY: web-tree-sitter
web-tree-sitter: $(addprefix $(WEB_TREE_SITTER_DIR)/,$(WEB_TREE_SITTER_FILES)) \

$(addprefix $(WEB_TREE_SITTER_DIR)/,$(WEB_TREE_SITTER_FILES)):
@rm -rf $(MAKE_CACHE_DIR)/tree-sitter
@git clone \
-c advice.detachedHead=false --quiet \
--depth=1 --branch=v$(TREE_SITTER_VERSION) \
https://github.com/tree-sitter/tree-sitter.git \
$(MAKE_CACHE_DIR)/tree-sitter
ifneq (,$(wildcard $(WEB_TREE_SITTER_PATCH)))
@(cp $(WEB_TREE_SITTER_PATCH) $(MAKE_CACHE_DIR)/tree-sitter)
@(cd $(MAKE_CACHE_DIR)/tree-sitter && git apply $(notdir $(WEB_TREE_SITTER_PATCH)))
endif
@(cd $(MAKE_CACHE_DIR)/tree-sitter && ./script/build-wasm)
@mkdir -p $(WEB_TREE_SITTER_DIR)
@cp $(MAKE_CACHE_DIR)/tree-sitter/LICENSE $(WEB_TREE_SITTER_DIR)
@cp $(addprefix $(MAKE_CACHE_DIR)/tree-sitter/lib/binding_web/,$(WEB_TREE_SITTER_FILES)) $(WEB_TREE_SITTER_DIR)
@rm -rf $(MAKE_CACHE_DIR)/tree-sitter
11 changes: 0 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,6 @@ When working with WSL, the host vscode instance connects to a vscode server on t
- If you're adding language support to `vscode-parse-tree`, you need to clone that as well, build it, and link it into the `vscode-server` extension folder: `ln -s ~/your/code/vscode-parse-tree ~/.vscode-server/extensions/parse-tree` for instance.
- If you get errors about needing to install the `Remote-WSL` extension, you might need to manually delete the extension from the host side and try again.

### Updating `web-tree-sitter`

We build a custom version of `web-tree-sitter` to ensure that we can always use the latest version and fix any problems as they come up.
To update `web-tree-sitter`:

1. Update the variable `TREE_SITTER_VERSION` in the [`Makefile`](Makefile#L8);
2. Update the path to `web-tree-sitter` in [`package.json`](package.json#103);
3. (Optional) Create a new patch in `patches/tree-sitter+$TREE_SITTER_VERSION.patch`.

The script which builds our custom version is in the [`Makefile`](Makefile#L37-63).

## Change Log

See [CHANGELOG.md](CHANGELOG.md).
Expand Down
37 changes: 18 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
"vscode:prepublish": "npm run compile",
"compile": "tsc -p ./ && make parsers",
"watch": "tsc -watch -p ./",
"preinstall": "make web-tree-sitter",
"postinstall": "node ./node_modules/vscode/bin/install",
"test": "npm run compile && node ./out/test",
"benchmark": "npm run compile && node ./out/benchmark",
Expand All @@ -71,46 +70,46 @@
"publish": "vsce publish patch"
},
"devDependencies": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Will-Sommers you're going to have a bunch of merge conflicts with #28; not sure how to handle. I'd be inclined to get this PR in because it's fairly mechanical, but you're probably then going to need to redo the pins on #28.

"@types/mocha": "^2.2.42",
"@types/node": "^8.10.25",
"electron-rebuild": "^2.3.5",
"@types/mocha": "^9.1.1",
"@types/node": "^16.0.0",
"electron-rebuild": "^3.2.7",
"tree-sitter-agda": "github:pokey/tree-sitter-agda#e5fba6cabe8c7fc7993ced2b86704f3841215284",
"tree-sitter-bash": "^0.19.0",
"tree-sitter-c": "^0.19.0",
"tree-sitter-css": "^0.19.0",
"tree-sitter-c-sharp": "^0.19.0",
"tree-sitter-cli": "^0.20.1",
"tree-sitter-c": "^0.20.1",
"tree-sitter-c-sharp": "^0.19.1",
"tree-sitter-cli": "^0.20.6",
"tree-sitter-clojure": "github:sogaiu/tree-sitter-clojure#master",
"tree-sitter-cpp": "^0.19.0",
"tree-sitter-go": "^0.19.0",
"tree-sitter-cpp": "^0.20.0",
"tree-sitter-css": "^0.19.0",
"tree-sitter-go": "^0.19.1",
"tree-sitter-haskell": "github:tree-sitter/tree-sitter-haskell#d6ccd2d9c40bdec29fee0027ef04fe5ff1ae4ceb",
"tree-sitter-html": "^0.19.0",
"tree-sitter-java": "^0.19.1",
"tree-sitter-javascript": "^0.19.0",
"tree-sitter-json": "^0.19.0",
"tree-sitter-json": "^0.20.0",
"tree-sitter-latex": "github:latex-lsp/tree-sitter-latex#1666e9780de42a31b1376d32fbe8332e8dd5850f",
"tree-sitter-markdown": "^0.7.1",
"tree-sitter-php": "github:tree-sitter/tree-sitter-php#0ce134234214427b6aeb2735e93a307881c6cd6f",
"tree-sitter-python": "^0.19.0",
"tree-sitter-python": "^0.20.1",
"tree-sitter-query": "github:nvim-treesitter/tree-sitter-query#5217c6805c09f8fc00ed13d17d5fcb791437aee6",
"tree-sitter-ruby": "github:tree-sitter/tree-sitter-ruby#1ebfdb288842dae5a9233e2509a135949023dd82",
"tree-sitter-rust": "github:tree-sitter/tree-sitter-rust#36ae187ed6dd3803a8a89dbb54f3124c8ee74662",
"tree-sitter-scala": "github:tree-sitter/tree-sitter-scala#master",
"tree-sitter-query": "github:nvim-treesitter/tree-sitter-query#5217c6805c09f8fc00ed13d17d5fcb791437aee6",
"tree-sitter-scss": "github:serenadeai/tree-sitter-scss#c478c6868648eff49eb04a4df90d703dc45b312a",
"tree-sitter-sparql": "^0.1.0",
"tree-sitter-typescript": "github:tree-sitter/tree-sitter-typescript#master",
"tree-sitter-yaml": "^0.5.0",
"tslint": "^6.0.0",
"typescript": "^3.8.2",
"vsce": "^1.73.0",
"typescript": "^4.7.4",
"vsce": "^2.9.2",
"vscode": "^1.1.36"
},
"dependencies": {
"jsonc-parser": "^2.1.0",
"tar": ">=4.4.2",
"web-tree-sitter": "file:vendor/web-tree-sitter/0.20.4"
"jsonc-parser": "^3.0.0",
"tar": ">=6.1.11",
"web-tree-sitter": "^0.20.5"
},
"bundledDependencies": [
"web-tree-sitter"
]
}
}
25 changes: 0 additions & 25 deletions patches/tree-sitter+0.20.4.patch

This file was deleted.

6 changes: 3 additions & 3 deletions src/scopes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ function checkFileExists(filePath: string): Promise<boolean> {
})
}

function readFileText(filePath: string, encoding: string = "utf8"): Promise<string> {
function readFileText(filePath: string): Promise<string> {
return new Promise<string>((resolve, reject) => {
fs.readFile(filePath, encoding, (err, data) => {
fs.readFile(filePath, 'utf8', (err, data) => {
if (err) {
reject(err)
} else {
resolve(data)
}
})
})
}
}
Loading