Overview tool: raise ValueError for directory paths (if multiple LS are active)

The error is raised through `LanguageServerManager.get_language_server`, where it is done conservatively (only if multiple LS are available and we can't decide)
This commit is contained in:
Michael Panchenko committed 2026-02-23 19:32:41 +01:00
1 parent bc9bd9085e
commit 1db52b16bf
2 files changed
+6 -1

No files matched your search

+4
View File
@@ -1,4 +1,5 @@
import logging
import os.path
import threading
from collections.abc import Iterator
@@ -129,8 +130,11 @@ class LanguageServerManager:
return ls
def get_language_server(self, relative_path: str) -> SolidLanguageServer:
""":param relative_path: relative path to a file"""
ls: SolidLanguageServer | None = None
if len(self._language_servers) > 1:
if os.path.isdir(relative_path):
raise ValueError(f"Expected a file path, but got a directory: {relative_path}")
for candidate in self._language_servers.values():
if not candidate.is_ignored_path(relative_path, ignore_unsupported_files=True):
ls = candidate
+2 -1
View File
@@ -697,6 +697,7 @@ class LanguageServerSymbolRetriever:
return self._ls_manager.get_root_path()
def get_language_server(self, relative_path: str) -> SolidLanguageServer:
""":param relative_path: relative path to a file"""
return self._ls_manager.get_language_server(relative_path)
def find(
@@ -837,7 +838,7 @@ class LanguageServerSymbolRetriever:
def get_symbol_overview(self, relative_path: str) -> dict[str, list[LanguageServerSymbol]]:
"""
:param relative_path: the path of the file or directory for which to get the symbol overview
:param relative_path: the path of the file for which to get the symbol overview
:return: a mapping from file paths to lists of symbols.
For the case where a file is passed, the mapping will contain a single entry.
"""