Skip to content

feat: add Kotlin/Scala glue file support and fix two bugs - #140

Open
marton78 wants to merge 1 commit into
cucumber:mainfrom
marton78:kotlin-support
Open

feat: add Kotlin/Scala glue file support and fix two bugs#140
marton78 wants to merge 1 commit into
cucumber:mainfrom
marton78:kotlin-support

Conversation

@marton78

@marton78 marton78 commented Jun 24, 2026

Copy link
Copy Markdown

Summary

  • Adds kotlin (.kt/.kts) and scala (.scala) to glueExtByLanguageName so the server discovers step definitions in those files
  • Fix: reindex crash when DidChangeConfiguration sends null/malformed settings — params.settings was blindly cast to Settings, causing undefined.reduce() if features/glue were missing (observed with Zed)
  • Fix: wasmBasePath resolved incorrectly when npm hoists @cucumber/language-service; now uses require.resolve() instead of the hardcoded __dirname/../node_modules path

Dependency chain

This PR is a part of two, adding Kotlin support:

  1. cucumber/language-service #304 — Kotlin parsing (merge first)
  2. This PR — glue file discovery + two bug fixes

Note: the package.json currently points at marton78/language-service#kotlin-support for development; this should be updated to the official release once PR #304 merges.

Test plan

  • .kt and .kts files are indexed as glue files
  • .scala files are indexed as glue files
  • No crash when Zed sends DidChangeConfiguration with null/missing settings
  • wasmBasePath resolves correctly when @cucumber/language-service is hoisted by npm

- Add kotlin (.kt/.kts) and scala (.scala) to glueExtByLanguageName
- Fix: reindex crash when DidChangeConfiguration sends null/malformed
  settings (params.settings was blindly cast to Settings, causing
  undefined.reduce() if features/glue were missing — seen with Zed)
- Fix: wasmBasePath resolved incorrectly when npm hoists
  @cucumber/language-service; use require.resolve() instead of the
  hardcoded __dirname/../node_modules path
- Point @cucumber/language-service at marton78/language-service fork

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@chinkong83

Copy link
Copy Markdown

Independent confirmation of both bug fixes in this PR, from a different client (Zed + Java glue).

Environment

  • Zed 1.17.2 with the cucumber extension 0.0.2
  • @cucumber/language-server 1.7.0 / @cucumber/language-service 1.7.0, flat (hoisted) npm install
  • 27 .java glue files, 27 .feature files, 1165 steps

Symptom — every step reported as Undefined step (403 diagnostics). Server log:

* Found 27 feature file(s) in [...]
* Found 1165 steps in those feature files
* Found 27 glue file(s) in [...]
* Found 0 step definitions in those glue files
* Step Definition errors: Error: Parsing failed
uri: .../integration/common/CommonStepDefs.java
language: java
    at Parser.parse (web-tree-sitter/tree-sitter.js:2085:21)
    at SourceAnalyzer.parse (language-service/src/language/SourceAnalyzer.ts:139:72)

…repeated for every glue file.

Root cause — confirms the wasmBasePath fix. bin/cucumber-language-server.cjs:9:

const wasmBasePath = path.resolve(`${__dirname}/../node_modules/@cucumber/language-service/dist`)

With a hoisted install this resolves to .../@cucumber/language-server/node_modules/@cucumber/language-service/dist, which does not exist. No grammar is ever loaded, so every parse() throws.

Proof that the path is the only problem. Driving the same installed library directly, with WasmParserAdapter pointed at the real dist directory, over the same 27 files:

files: 27
extracted step definitions: 169
errors: 0

Same wasm grammars, same versions — the parser itself is fine.

Workaround (verified). Symlinking the hoisted package into the location the hardcoded path expects makes the running server report * Found 169 step definitions in those glue files.

The second fix reproduces too. Every reindex logs Failed to reindex: Cannot read properties of undefined (reading 'reduce') first, matching the params.settings cast described in the PR description — and yes, observed with Zed.

Suggestion: both fixes are independent of the Kotlin/Scala feature and are only a few lines each. Splitting them into their own PR would let them land without waiting on cucumber/language-service#304, which has also been open since June. As it stands, Java step-definition support is completely broken for any client with a hoisted install.


🤖 This comment was generated by Claude Code (AI)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants