Skip to content
Open
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ node_modules/
*.vsix
out/
.DS_Store
language-server/
language-service/
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 24.11.0
21 changes: 16 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@ Once you have completed [getting started](#getting-started), you may be wonderin

This extension uses the _Language Server Protocol_ to communicate with Visual Studio Code, which is an open protocol that allows the development of a common implementation - called a __language server__ - that can communicate with different IDEs. This implementation is stored in the [Cucumber Language Server](https://github.com/cucumber/language-server) and the underlying [Cucumber Language Service](https://github.com/cucumber/language-service). Let's integrate local versions of each into our extension so we can modify them.

1. First, clone the Language Server and the Language Service to the same directory in which you cloned the extension. Your directory structure should appear as follows:
1. First, clone the Language Server and the Language Service in cloned extension directory (this is required in order to build a VSIX package). Your directory structure should appear as follows:

```console
directory/
vscode/
├── language-server/
├── language-service/
└── vscode/
└── language-service/
```

2. At this point, please [download and install docker](https://www.docker.com/products/docker-desktop/) if you have not already done so. A [docker installation is required](https://github.com/cucumber/language-service/blob/main/CONTRIBUTING.md#prerequisites) to build the Language Service.
Expand Down Expand Up @@ -69,7 +68,13 @@ This extension uses the _Language Server Protocol_ to communicate with Visual St

```console
la node_modules/@cucumber
lrwxr-xr-x 1 username staff 24 Jan 22 09:32 language-server -> ../../../language-server
lrwxr-xr-x 1 username staff 24 Jan 22 09:32 language-server -> ../../language-server
```

Convenience script was created: [reconfigure_local_modules.sh](./reconfigure_local_modules.sh)

```bash
./reconfigure_local_modules.sh
```

4. Now open the extension repository in Visual Studio Code.
Expand All @@ -85,6 +90,12 @@ If you need to make further changes to these packages, you have to rebuild them

For debugging the extension, set breakpoints within the code. 🐞

You can use convenience script - [rebuild.sh](./rebuild.sh)

```bash
./rebuild.sh
```

### Check everything is working

A nice way to check you are using the local language server implementations is to modify the snippet templates that generate step definitions for undefined steps. You will find these templates assigned to `defaultSnippetTemplate` in each of the ['\<language>Language.ts' files](https://github.com/cucumber/language-service/tree/main/src/language) of the Language Service, where each `<language>` is a programming language in which you can write compatible step definitions. Preferably, use a language you are comfortable with.
Expand Down
60 changes: 17 additions & 43 deletions package-lock.json

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

11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "cucumber-official",
"displayName": "Cucumber",
"description": "Cucumber for Visual Studio Code",
"version": "1.11.0",
"version": "2.0.0-beta",
"publisher": "CucumberOpen",
"engines": {
"vscode": "^1.82.0"
Expand Down Expand Up @@ -87,7 +87,14 @@
"default": []
}
}
}
},
"commands": [
{
"command": "cucumber.forceReindex",
"title": "Cucumber: Force Reindex",
"description": "Force reindexing of the Cucumber Language Server"
}
]
},
"scripts": {
"vscode:prepublish": "npm run build",
Expand Down
10 changes: 10 additions & 0 deletions rebuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -euo pipefail

cd language-service
npm run build
cd ..
cd language-server
npm run build
cd ..
17 changes: 17 additions & 0 deletions reconfigure_local_modules.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
set -euo pipefail

cd language-service
npm install
npm link
npm run build
cd ..
cd language-server
npm install
npm link @cucumber/language-service
npm link
npm run build
cd ..
npm install
npm link @cucumber/language-server
ls -lAh node_modules/@cucumber
33 changes: 33 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,40 @@ export async function activate(context: vscode.ExtensionContext) {

client = new LanguageClient('Cucumber', 'Cucumber Language Server', serverOptions, clientOptions)

console.log('Connecting to Cucumber Language Server')
await client.start()

// Register the force reindex command
const forceReindexCommand = vscode.commands.registerCommand('cucumber.forceReindex', async () => {
if (!client || !client.isRunning()) {
vscode.window.showWarningMessage('Cucumber Language Server is not running')
return
}

try {
await vscode.window.withProgress(
{
location: vscode.ProgressLocation.Notification,
title: 'Cucumber: Reindexing...',
cancellable: false,
},
async () => {
const result = await client.sendRequest<{ success: boolean; error?: string }>(
'cucumber/forceReindex'
)
if (result.success) {
vscode.window.showInformationMessage('Cucumber: Reindexing completed successfully')
} else {
vscode.window.showErrorMessage(`Cucumber: Reindexing failed - ${result.error}`)
}
}
)
} catch (error) {
vscode.window.showErrorMessage(`Cucumber: Failed to trigger reindex - ${error}`)
}
})

context.subscriptions.push(forceReindexCommand)
}

// this method is called when your extension is deactivated
Expand Down
17 changes: 17 additions & 0 deletions vscode.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"folders": [
{
"name": "cucumber-vscode",
"path": "."
},
{
"name": "language-service",
"path": "language-service"
},
{
"name": "language-server",
"path": "language-server"
}
],
"settings": {}
}