Skip to content

Commit

Permalink
Move wasm to language-service. Fixes #28
Browse files Browse the repository at this point in the history
  • Loading branch information
aslakhellesoy committed Feb 4, 2022
1 parent f846628 commit c6ebdf6
Show file tree
Hide file tree
Showing 16 changed files with 63 additions and 438 deletions.
71 changes: 38 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 4 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"types": "dist/cjs/src/index.d.ts",
"files": [
"dist/cjs",
"dist/esm",
"*.wasm"
"dist/esm"
],
"module": "dist/esm/src/index.js",
"jsnext:main": "dist/esm/src/index.js",
Expand All @@ -35,8 +34,6 @@
"eslint-fix": "eslint --ext ts,tsx --max-warnings 0 --fix src test",
"eslint": "eslint --ext ts,tsx --max-warnings 0 src test",
"upgrade": "npm-check-updates --upgrade",
"build-java-wasm": "npx tree-sitter build-wasm node_modules/tree-sitter-java",
"build-typescript-wasm": "npx tree-sitter build-wasm node_modules/tree-sitter-typescript/typescript",
"prepare": "husky install",
"pretty-quick-staged": "pretty-quick --staged"
},
Expand All @@ -57,7 +54,7 @@
"devDependencies": {
"@cucumber/cucumber": "7.3.2",
"@types/mocha": "9.1.0",
"@types/node": "17.0.10",
"@types/node": "17.0.13",
"@typescript-eslint/eslint-plugin": "5.10.1",
"@typescript-eslint/parser": "5.10.1",
"eslint": "8.7.0",
Expand All @@ -79,14 +76,10 @@
"dependencies": {
"@cucumber/cucumber-expressions": "^15.0.1",
"@cucumber/gherkin-utils": "^7.0.0",
"@cucumber/language-service": "^0.11.0",
"@cucumber/language-service": "^0.12.1",
"fast-glob": "3.2.11",
"source-map-support": "0.5.21",
"tree-sitter-cli": "0.20.4",
"tree-sitter-java": "0.19.1",
"tree-sitter-typescript": "0.19.0",
"vscode-languageserver": "7.0.0",
"vscode-languageserver-textdocument": "1.0.3",
"web-tree-sitter": "0.20.3"
"vscode-languageserver-textdocument": "1.0.4"
}
}
12 changes: 5 additions & 7 deletions src/CucumberLanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import {
jsSearchIndex,
semanticTokenTypes,
StepDocument,
WasmUrls,
} from '@cucumber/language-service'
import { ExpressionBuilder } from '@cucumber/language-service'
import {
ConfigurationRequest,
Connection,
Expand All @@ -22,7 +24,6 @@ import { TextDocument } from 'vscode-languageserver-textdocument'

import { buildStepTexts } from './buildStepTexts.js'
import { loadAll } from './loadAll.js'
import { ExpressionBuilder } from './tree-sitter/ExpressionBuilder.js'
import { ParameterTypeMeta, Settings } from './types.js'
import { version } from './version.js'

Expand All @@ -46,18 +47,15 @@ export class CucumberLanguageServer {

constructor(
private readonly connection: Connection,
private readonly documents: TextDocuments<TextDocument>
private readonly documents: TextDocuments<TextDocument>,
wasmUrls: WasmUrls
) {
connection.onInitialize(async (params) => {
connection.console.info(
`CucumberLanguageServer initializing with params: ${JSON.stringify(params, null, 2)}`
)

await this.expressionBuilder.init({
// Relative to dist/src/cjs
java: `${__dirname}/../../../tree-sitter-java.wasm`,
typescript: `${__dirname}/../../../tree-sitter-typescript.wasm`,
})
await this.expressionBuilder.init(wasmUrls)

if (params.capabilities.workspace?.configuration) {
connection.onDidChangeConfiguration((params) => {
Expand Down
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './CucumberLanguageServer.js'
export * from './tree-sitter/index.js'
3 changes: 2 additions & 1 deletion src/loadAll.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { LanguageName, Source } from '@cucumber/language-service'
import fg from 'fast-glob'
import fs from 'fs/promises'
import path from 'path'

import { Extension, LanguageName, Source } from './tree-sitter/types.js'
type Extension = '.ts' | '.java'

export const languageByExt: Record<Extension, LanguageName> = {
'.ts': 'typescript',
Expand Down
8 changes: 7 additions & 1 deletion src/server.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { WasmUrls } from '@cucumber/language-service'
import { TextDocuments } from 'vscode-languageserver'
import { createConnection, ProposedFeatures } from 'vscode-languageserver/node'
import { TextDocument } from 'vscode-languageserver-textdocument'
Expand All @@ -7,7 +8,12 @@ import { CucumberLanguageServer } from './CucumberLanguageServer.js'
const connection = createConnection(ProposedFeatures.all)
const documents = new TextDocuments(TextDocument)

new CucumberLanguageServer(connection, documents)
const wasmUrls: WasmUrls = {
java: `tree-sitter-java.wasm`,
typescript: `tree-sitter-typescript.wasm`,
}

new CucumberLanguageServer(connection, documents, wasmUrls)
connection.listen()

// Don't die on unhandled Promise rejections
Expand Down
95 changes: 0 additions & 95 deletions src/tree-sitter/ExpressionBuilder.ts

This file was deleted.

30 changes: 0 additions & 30 deletions src/tree-sitter/helpers.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/tree-sitter/index.ts

This file was deleted.

Loading

0 comments on commit c6ebdf6

Please sign in to comment.