Skip to content
Merged
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Changed
- The Cucumber Language Server is now started in-process ([#105](https://github.com/cucumber/vscode/pull/105))

## [1.3.0] - 2022-09-10
### Added
- Add support for `.tsx` ([#87](https://github.com/cucumber/language-service/issues/87) [#90](https://github.com/cucumber/language-service/pull/90))
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"upgrade": "npm-check-updates --upgrade"
},
"dependencies": {
"@cucumber/language-server": "0.12.14",
"@cucumber/language-server": "0.13.1",
"vscode-languageclient": "8.0.2"
},
"devDependencies": {
Expand Down
29 changes: 29 additions & 0 deletions src/VscodeFiles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Files } from '@cucumber/language-server'
import { FileSystem, Uri, workspace } from 'vscode'

export class VscodeFiles implements Files {
constructor(private readonly rootUri: string, private readonly fs: FileSystem) {}

async exists(uri: string): Promise<boolean> {
try {
await this.fs.stat(Uri.parse(uri))
return true
} catch {
return false
}
}

async readFile(uri: string): Promise<string> {
const data = await this.fs.readFile(Uri.parse(uri))
return new TextDecoder().decode(data)
}

async findUris(glob: string): Promise<readonly string[]> {
const uris = await workspace.findFiles(glob)
return uris.map((file) => file.toString())
}

relativePath(uri: string): string {
return workspace.asRelativePath(Uri.parse(uri), true)
}
}
3 changes: 2 additions & 1 deletion src/cucumber-language-server.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { NodeFiles } from '@cucumber/language-server/node'
import { startWasmServer } from '@cucumber/language-server/wasm'

startWasmServer(__dirname)
startWasmServer(__dirname, (rootUri) => new NodeFiles(rootUri))
29 changes: 9 additions & 20 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,28 @@
import path from 'path'
import { newWasmServer } from '@cucumber/language-server'
import vscode from 'vscode'
import {
LanguageClient,
LanguageClientOptions,
ServerOptions,
TransportKind,
} from 'vscode-languageclient/node'
import { LanguageClient, LanguageClientOptions, ServerOptions } from 'vscode-languageclient/node'

import { VscodeFiles } from './VscodeFiles'

let client: LanguageClient

// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export async function activate(context: vscode.ExtensionContext) {
const serverModule = context.asAbsolutePath(path.join('out', 'cucumber-language-server.js'))
const debugOptions = { execArgv: ['--nolazy', '--inspect=6009'] }

const serverOptions: ServerOptions = {
run: { module: serverModule, transport: TransportKind.ipc },
debug: {
module: serverModule,
transport: TransportKind.ipc,
options: debugOptions,
},
}
const makeFiles = (rootUri: string) => new VscodeFiles(rootUri, vscode.workspace.fs)
const serverOptions: ServerOptions = async () => newWasmServer(__dirname, makeFiles)

const clientOptions: LanguageClientOptions = {
// We need to list all supported languages here so that
// the language server is notified to reindex when a file changes
// https://code.visualstudio.com/docs/languages/identifiers#_known-language-identifiers
documentSelector: [
{ scheme: 'file', language: 'csharp' },
{ scheme: 'file', language: 'cucumber' },
{ scheme: 'file', language: 'java' },
{ scheme: 'file', language: 'php' },
{ scheme: 'file', language: 'ruby' },
{ scheme: 'file', language: 'typescript' },
{ scheme: 'file', language: 'typescriptreact' },
{ scheme: 'file', language: 'python' },
],
}
Expand Down