Skip to content

Commit 303477d

Browse files
ericdalloeca-agent
andcommitted
Fix slurp-action-test against newer LSP4IJ versions
The test was failing in CI because newer LSP4IJ versions broke the test setup in two independent ways. Both are addressed here. 1. ClojureLanguageServerFactory throws UnsupportedOperationException on plugin instantiation: Caused by: java.lang.UnsupportedOperationException: createLanguageServerSettingsContributor (com.github.clojure-lsp.intellij.extension.language-server-factory/ ClojureLanguageServerFactory_createLanguageServerSettingsContributor not defined?) LSP4IJ added `createServerInstaller` and `createLanguageServerSettingsContributor` as default interface methods. Our factory uses `def-extension` (clj4intellij), which is `gen-class`-backed; gen-class always overrides interface methods, never falling through to the Java default. Adding explicit stubs that return `nil` restores the upstream-default behaviour. 2. Once the factory loads, the LSP server still fails to start: Caused by: java.lang.UnsupportedOperationException: Failed to map temp:///src (filesystem com.intellij.openapi.vfs.ex.temp.TempFileSystem) into nio Path at LanguageServerWrapper.<init> <- FileSystemWatcherManager.getProjectBasePath <- VirtualFile.toNioPath LSP4IJ's `FileSystemWatcherManager` requires the project base to resolve to a real filesystem `Path`. The previous test used `clj4intellij.test/setup`, which builds a `LightProjectDescriptor` exposing the project under the in-memory `TempFileSystem` — for which `toNioPath` throws. Bump `clj4intellij` to 0.9.0 (which adds `setup-heavy`) and switch `test_utils/setup-test-project` to it. The heavy fixture uses `IdeaTestFixtureFactory.createFixtureBuilder` + `createTempDirTestFixture`, giving the project a real disk-backed path. Also rename the test project to `clojure-sample-project` (heavy fixtures use the name as the on-disk directory and IntelliJ sanitizes dots to underscores). 🤖 Generated with [eca](https://eca.dev) Co-Authored-By: eca-agent <git@eca.dev>
1 parent 496350e commit 303477d

5 files changed

Lines changed: 21 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## [Unreleased]
44

5+
- Implement `createServerInstaller` and `createLanguageServerSettingsContributor` on `ClojureLanguageServerFactory`. Newer LSP4IJ versions added these as default interface methods, but our `def-extension`/`gen-class`-backed factory always overrides interface methods, so explicit stubs are required.
6+
- Fix `slurp-action-test` against newer LSP4IJ versions. Bump `clj4intellij` to `0.9.0` and switch the test fixture to `setup-heavy` so the project base has a real filesystem path (LSP4IJ's `FileSystemWatcherManager` calls `VirtualFile.toNioPath()`, which throws on the in-memory `TempFileSystem` used by light fixtures).
7+
58
## 3.5.2
69

710
- Fix `QuoteHandler` compile error by merging `BAD_CHARACTER` into the quote-handler `TokenSet`.

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ repositories {
3535

3636
dependencies {
3737
implementation ("org.clojure:clojure:1.12.0")
38-
implementation ("com.github.ericdallo:clj4intellij:0.8.0")
38+
implementation ("com.github.ericdallo:clj4intellij:0.9.0")
3939
implementation ("seesaw:seesaw:1.5.0")
4040
implementation ("camel-snake-kebab:camel-snake-kebab:0.4.3")
4141
implementation ("com.rpl:proxy-plus:0.0.9")

src/main/clojure/com/github/clojure_lsp/intellij/extension/language_server_factory.clj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@
8585

8686
(getServerInterface [_] com.github.clojure_lsp.intellij.ClojureLanguageServer)
8787

88+
;; Newer LSP4IJ versions added these as default methods on
89+
;; LanguageServerFactory. `def-extension` is gen-class-backed and always
90+
;; overrides interface methods (no fall-through to defaults), so we must
91+
;; declare explicit stubs that return nil — matching the upstream defaults.
92+
(createServerInstaller [_] nil)
93+
(createLanguageServerSettingsContributor [_] nil)
94+
8895
(createClientFeatures [_]
8996
(doto
9097
(proxy+ [] LSPClientFeatures

src/test/clojure/com/github/clojure_lsp/intellij/slurp_action_test.clj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
2323
The test ensures that the Forward Slurp action correctly modifies the code structure
2424
by moving the closing parenthesis forward."
25-
(let [project-name "clojure.sample-project"
25+
;; Avoid dots/underscores in the project name: heavy fixtures use it as
26+
;; the on-disk directory name and IntelliJ sanitizes it to a filesystem-safe
27+
;; identifier.
28+
(let [project-name "clojure-sample-project"
2629
{:keys [fixtures project deps-file]} (test-utils/setup-test-project project-name)
2730
clj-file (.copyFileToProject ^CodeInsightTestFixture fixtures "foo.clj")]
2831
(is (= project-name (.getName ^Project project)))

src/test/clojure/com/github/clojure_lsp/intellij/test_utils.clj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,12 @@
7575
([project-name]
7676
(setup-test-project project-name "{}"))
7777
([project-name deps-content]
78-
(let [fixtures (clj4intellij.test/setup project-name)
78+
;; setup-heavy gives us a disk-backed CodeInsightTestFixture, which is
79+
;; required by recent LSP4IJ versions: their FileSystemWatcherManager
80+
;; calls VirtualFile.toNioPath() on the project base, and that throws
81+
;; UnsupportedOperationException for the in-memory TempFileSystem used
82+
;; by light fixtures.
83+
(let [fixtures (clj4intellij.test/setup-heavy project-name)
7984
deps-file (.createFile fixtures "deps.edn" deps-content)
8085
_ (.setTestDataPath fixtures "testdata")
8186
project (.getProject fixtures)]

0 commit comments

Comments
 (0)