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
5 changes: 4 additions & 1 deletion bin/cucumber-language-server.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ const { NodeFiles } = require('../dist/cjs/src/node/NodeFiles')
const path = require('path')
const { version } = require('../dist/cjs/src/version')

const wasmBasePath = path.resolve(`${__dirname}/../node_modules/@cucumber/language-service/dist`)
// Use require.resolve so this works regardless of whether npm hoisted
// @cucumber/language-service or installed it nested inside our node_modules.
// Main CJS entry is dist/cjs/src/index.js — go up two dirs to reach dist/.
const wasmBasePath = path.join(path.dirname(require.resolve('@cucumber/language-service')), '../..')
const { connection } = startStandaloneServer(wasmBasePath, (rootUri) => new NodeFiles(rootUri))

// Don't die on unhandled Promise rejections
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
},
"dependencies": {
"@cucumber/gherkin-utils": "^12.0.0",
"@cucumber/language-service": "^1.7.0",
"@cucumber/language-service": "github:marton78/language-service#kotlin-support",
"fast-glob": "3.3.3",
"source-map-support": "0.5.21",
"vscode-languageserver": "8.0.2",
Expand Down
9 changes: 8 additions & 1 deletion src/CucumberLanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,14 @@ export class CucumberLanguageServer {
if (params.capabilities.workspace?.configuration) {
connection.onDidChangeConfiguration((params) => {
this.connection.console.info(`Client sent workspace/configuration`)
this.reindex(<Settings>params.settings).catch((err) => {
// params.settings may be null or missing features/glue depending on the client;
// only use it if it looks like a valid Settings object, otherwise fall back to
// getSettings() to avoid a crash on undefined.reduce() during reindex.
const settings =
params.settings?.features != null && params.settings?.glue != null
? (params.settings as Settings)
: undefined
this.reindex(settings).catch((err) => {
connection.console.error(`Failed to reindex: ${err.message}`)
})
})
Expand Down
2 changes: 2 additions & 0 deletions src/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export const glueExtByLanguageName: Record<LanguageName, string[]> = {
python: ['.py'],
rust: ['.rs'],
go: ['.go'],
scala: ['.scala'],
kotlin: ['.kt', '.kts'],
}

type ExtLangEntry = [string, LanguageName]
Expand Down