Fix Solid-LSP project cache path using hard-coded path element '.serena'

(move to SolidLSPSettings instead)
This commit is contained in:
Dominik Jain authored and Dominik Jain committed 2025-09-01 22:01:14 +02:00
1 parent 8bd84b87d9
commit 78be9c87fe
3 files changed
+23 -3

No files matched your search

+9 -1
View File
@@ -84,6 +84,8 @@ class SolidLanguageServer(ABC):
It is used to communicate with Language Servers of different programming languages.
"""
CACHE_FOLDER_NAME = "cache"
# To be overridden and extended by subclasses
def is_ignored_dirname(self, dirname: str) -> bool:
"""
@@ -1640,7 +1642,13 @@ class SolidLanguageServer(ABC):
"""
The path to the cache file for the document symbols.
"""
return Path(self.repository_root_path) / ".serena" / "cache" / self.language_id / "document_symbols_cache_v23-06-25.pkl"
return (
Path(self.repository_root_path)
/ self._solidlsp_settings.project_data_relative_path
/ self.CACHE_FOLDER_NAME
/ self.language_id
/ "document_symbols_cache_v23-06-25.pkl"
)
def save_cache(self):
with self._cache_lock:
+9
View File
@@ -10,6 +10,15 @@ from dataclasses import dataclass
@dataclass
class SolidLSPSettings:
solidlsp_dir: str = str(pathlib.Path.home() / ".solidlsp")
"""
Path to the directory in which to store global Solid-LSP data (which is not project-specific)
"""
project_data_relative_path: str = ".solidlsp"
"""
Relative path within each project directory where Solid-LSP can store project-specific data, e.g. cache files.
For instance, if this is ".solidlsp" and the project is located at "/home/user/myproject",
then Solid-LSP will store project-specific data in "/home/user/myproject/.solidlsp".
"""
def __post_init__(self):
os.makedirs(str(self.solidlsp_dir), exist_ok=True)
+5 -2
View File
@@ -4,7 +4,7 @@ from pathlib import Path
import pytest
from sensai.util.logging import configure
from serena.constants import SERENA_MANAGED_DIR_IN_HOME
from serena.constants import SERENA_MANAGED_DIR_IN_HOME, SERENA_MANAGED_DIR_NAME
from serena.project import Project
from serena.util.file_system import GitignoreParser
from solidlsp.ls import SolidLanguageServer
@@ -46,7 +46,10 @@ def create_ls(
config = LanguageServerConfig(code_language=language, ignored_paths=ignored_paths, trace_lsp_communication=trace_lsp_communication)
logger = LanguageServerLogger(log_level=log_level)
return SolidLanguageServer.create(
config, logger, repo_path, solidlsp_settings=SolidLSPSettings(solidlsp_dir=SERENA_MANAGED_DIR_IN_HOME)
config,
logger,
repo_path,
solidlsp_settings=SolidLSPSettings(solidlsp_dir=SERENA_MANAGED_DIR_IN_HOME, project_data_relative_path=SERENA_MANAGED_DIR_NAME),
)