From 483538a293863d64f932b5980e4b0099f2eeb165 Mon Sep 17 00:00:00 2001 From: Lin Yang Date: Thu, 26 Mar 2026 03:33:27 -0700 Subject: [PATCH] Use deterministic workspace dir for EclipseJDTLS to enable cache reuse (#1214) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Use deterministic workspace dir for EclipseJDTLS to enable cache reuse Replace uuid.uuid4().hex with a hash of the project path for the JDTLS workspace directory. This allows the workspace cache (project index, shared index, configuration) to be reused across server restarts instead of rebuilding from scratch each time. The random UUID was inherited from microsoft/multilspy (a research/testing library where ephemeral workspaces made sense), but for Serena's use case — long-lived projects with repeated restarts — deterministic workspace paths significantly reduce startup time, especially for large Java projects. * Fix import sort order for ruff lint --- src/solidlsp/language_servers/eclipse_jdtls.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/solidlsp/language_servers/eclipse_jdtls.py b/src/solidlsp/language_servers/eclipse_jdtls.py index 67a23c3b..c44bb791 100644 --- a/src/solidlsp/language_servers/eclipse_jdtls.py +++ b/src/solidlsp/language_servers/eclipse_jdtls.py @@ -3,12 +3,12 @@ Provides Java specific instantiation of the LanguageServer class. Contains vario """ import dataclasses +import hashlib import logging import os import pathlib import shutil import threading -import uuid from pathlib import PurePath from time import sleep from typing import cast @@ -276,13 +276,16 @@ class EclipseJDTLS(SolidLanguageServer): ) def create_launch_command(self) -> list[str]: - # ws_dir is the workspace directory for the EclipseJDTLS server + # ws_dir is the workspace directory for the EclipseJDTLS server. + # Use a deterministic hash of the project path so the workspace + # (and its cached index) can be reused across restarts. + project_hash = hashlib.md5(self._repository_root_path.encode()).hexdigest() ws_dir = str( PurePath( self._solidlsp_settings.ls_resources_dir, "EclipseJDTLS", "workspaces", - uuid.uuid4().hex, + project_hash, ) )