mirror of
https://github.com/tiennm99/serena.git
synced 2026-10-15 00:18:04 +00:00
Refactoring: Rename Language to LanguageServerId
This resolves a long-standing naming issue in Serena & SolidLSP.
This commit is contained in:
1 parent
ef0e218fb1
commit
d2cf18ddcb
180 files changed
+1806
-1767
No files matched your search
@@ -17,7 +17,7 @@ import pathspec
|
||||
import pytest
|
||||
|
||||
from solidlsp import SolidLanguageServer, ls_types
|
||||
from solidlsp.ls_config import Language
|
||||
from solidlsp.ls_config import LanguageServerId
|
||||
from solidlsp.ls_utils import PathUtils
|
||||
|
||||
|
||||
@@ -27,13 +27,13 @@ class _IgnoredPathServer(SolidLanguageServer):
|
||||
def __init__(
|
||||
self,
|
||||
root: Path,
|
||||
language: Language,
|
||||
language: LanguageServerId,
|
||||
*,
|
||||
ignored_dirnames: tuple[str, ...] = (),
|
||||
ignore_lines: tuple[str, ...] = (),
|
||||
) -> None:
|
||||
self.repository_root_path = str(root)
|
||||
self.language = language
|
||||
self.ls_id = language
|
||||
self._ignored_dirnames = frozenset(ignored_dirnames)
|
||||
self._ignore_spec = pathspec.PathSpec.from_lines(pathspec.patterns.GitWildMatchPattern, ignore_lines)
|
||||
|
||||
@@ -49,7 +49,7 @@ class _IgnoredPathServer(SolidLanguageServer):
|
||||
|
||||
def test_missing_lombok_class_under_target_is_ignored_not_raised(tmp_path: Path) -> None:
|
||||
"""JDTLS-style missing build artifact under target/classes -- must be ignored, never raise."""
|
||||
ls = _IgnoredPathServer(tmp_path, Language.JAVA)
|
||||
ls = _IgnoredPathServer(tmp_path, LanguageServerId.JAVA)
|
||||
missing = "target/classes/test_repo/LombokModel$LombokModelBuilder.class"
|
||||
|
||||
assert not (tmp_path / missing).exists()
|
||||
@@ -57,7 +57,7 @@ def test_missing_lombok_class_under_target_is_ignored_not_raised(tmp_path: Path)
|
||||
|
||||
|
||||
def test_missing_unsupported_extension_is_ignored(tmp_path: Path) -> None:
|
||||
ls = _IgnoredPathServer(tmp_path, Language.PYTHON)
|
||||
ls = _IgnoredPathServer(tmp_path, LanguageServerId.PYTHON)
|
||||
missing = "src/foo.pyc"
|
||||
assert not (tmp_path / missing).exists()
|
||||
assert ls.is_ignored_path(missing) is True
|
||||
@@ -65,14 +65,14 @@ def test_missing_unsupported_extension_is_ignored(tmp_path: Path) -> None:
|
||||
|
||||
def test_missing_source_file_not_in_ignored_dir_is_not_ignored(tmp_path: Path) -> None:
|
||||
"""A missing source path classifies as not-ignored."""
|
||||
ls = _IgnoredPathServer(tmp_path, Language.PYTHON)
|
||||
ls = _IgnoredPathServer(tmp_path, LanguageServerId.PYTHON)
|
||||
missing = "src/app.py"
|
||||
assert not (tmp_path / missing).exists()
|
||||
assert ls.is_ignored_path(missing) is False
|
||||
|
||||
|
||||
def test_missing_source_file_under_ignored_dirname_is_ignored(tmp_path: Path) -> None:
|
||||
ls = _IgnoredPathServer(tmp_path, Language.PYTHON, ignored_dirnames=("generated",))
|
||||
ls = _IgnoredPathServer(tmp_path, LanguageServerId.PYTHON, ignored_dirnames=("generated",))
|
||||
missing = "generated/app.py"
|
||||
assert not (tmp_path / missing).exists()
|
||||
assert ls.is_ignored_path(missing) is True
|
||||
@@ -80,7 +80,7 @@ def test_missing_source_file_under_ignored_dirname_is_ignored(tmp_path: Path) ->
|
||||
|
||||
def test_missing_directory_with_ignored_dirname_leaf_is_ignored(tmp_path: Path) -> None:
|
||||
"""The leaf of a missing suffixless path may denote a directory and is checked against ignored dirnames."""
|
||||
ls = _IgnoredPathServer(tmp_path, Language.PYTHON, ignored_dirnames=("generated",))
|
||||
ls = _IgnoredPathServer(tmp_path, LanguageServerId.PYTHON, ignored_dirnames=("generated",))
|
||||
assert ls.is_ignored_path("generated", ignore_unsupported_files=False) is True
|
||||
assert ls.is_ignored_path("src/generated", ignore_unsupported_files=False) is True
|
||||
assert ls.is_ignored_path(".venv", ignore_unsupported_files=False) is True
|
||||
@@ -88,26 +88,26 @@ def test_missing_directory_with_ignored_dirname_leaf_is_ignored(tmp_path: Path)
|
||||
|
||||
def test_missing_extensionless_path_is_treated_as_directory(tmp_path: Path) -> None:
|
||||
"""A missing suffixless path is not subject to the unsupported-extension rule for files."""
|
||||
ls = _IgnoredPathServer(tmp_path, Language.PYTHON)
|
||||
ls = _IgnoredPathServer(tmp_path, LanguageServerId.PYTHON)
|
||||
assert ls.is_ignored_path("newpkg") is False
|
||||
|
||||
|
||||
def test_missing_ignored_by_pathspec_is_ignored(tmp_path: Path) -> None:
|
||||
ls = _IgnoredPathServer(tmp_path, Language.PYTHON, ignore_lines=("generated.py",))
|
||||
ls = _IgnoredPathServer(tmp_path, LanguageServerId.PYTHON, ignore_lines=("generated.py",))
|
||||
missing = "generated.py"
|
||||
assert not (tmp_path / missing).exists()
|
||||
assert ls.is_ignored_path(missing) is True
|
||||
|
||||
|
||||
def test_missing_unsupported_extension_can_be_allowed(tmp_path: Path) -> None:
|
||||
ls = _IgnoredPathServer(tmp_path, Language.PYTHON)
|
||||
ls = _IgnoredPathServer(tmp_path, LanguageServerId.PYTHON)
|
||||
missing = "src/foo.pyc"
|
||||
assert not (tmp_path / missing).exists()
|
||||
assert ls.is_ignored_path(missing, ignore_unsupported_files=False) is False
|
||||
|
||||
|
||||
def test_existing_path_under_ignored_dirname_is_ignored(tmp_path: Path) -> None:
|
||||
ls = _IgnoredPathServer(tmp_path, Language.PYTHON, ignored_dirnames=("generated",))
|
||||
ls = _IgnoredPathServer(tmp_path, LanguageServerId.PYTHON, ignored_dirnames=("generated",))
|
||||
source_file = tmp_path / "generated" / "app.py"
|
||||
source_file.parent.mkdir(parents=True)
|
||||
source_file.write_text("x = 1\n")
|
||||
@@ -115,7 +115,7 @@ def test_existing_path_under_ignored_dirname_is_ignored(tmp_path: Path) -> None:
|
||||
|
||||
|
||||
def test_existing_source_file_is_not_ignored(tmp_path: Path) -> None:
|
||||
ls = _IgnoredPathServer(tmp_path, Language.PYTHON)
|
||||
ls = _IgnoredPathServer(tmp_path, LanguageServerId.PYTHON)
|
||||
src = tmp_path / "pkg" / "mod.py"
|
||||
src.parent.mkdir(parents=True)
|
||||
src.write_text("x = 1\n")
|
||||
@@ -134,7 +134,7 @@ def test_java_build_output_paths_never_raise(tmp_path: Path, rel: str) -> None:
|
||||
"""Compiled-class paths classify as ignored via the unsupported-extension rule, present or not
|
||||
(build dirnames are deliberately not hard-ignored for Java).
|
||||
"""
|
||||
ls = _IgnoredPathServer(tmp_path, Language.JAVA)
|
||||
ls = _IgnoredPathServer(tmp_path, LanguageServerId.JAVA)
|
||||
# neither present nor absent should raise
|
||||
assert ls.is_ignored_path(rel) is True
|
||||
p = tmp_path / rel
|
||||
@@ -164,7 +164,7 @@ def _location_item(path: Path) -> dict:
|
||||
|
||||
def test_location_at_missing_path_is_skipped(tmp_path: Path) -> None:
|
||||
"""Locations whose absolute path is not on disk (e.g. LS-reported build artifacts) are dropped."""
|
||||
ls = _IgnoredPathServer(tmp_path, Language.JAVA)
|
||||
ls = _IgnoredPathServer(tmp_path, LanguageServerId.JAVA)
|
||||
missing = tmp_path / "target" / "classes" / "LombokModel$LombokModelBuilder.class"
|
||||
assert not missing.exists()
|
||||
assert _location_request(ls).convert_location_item(_location_item(missing)) is None
|
||||
@@ -172,13 +172,13 @@ def test_location_at_missing_path_is_skipped(tmp_path: Path) -> None:
|
||||
|
||||
def test_location_at_missing_source_path_is_skipped(tmp_path: Path) -> None:
|
||||
"""A missing path that is not ignored is dropped by the existence check alone."""
|
||||
ls = _IgnoredPathServer(tmp_path, Language.PYTHON)
|
||||
ls = _IgnoredPathServer(tmp_path, LanguageServerId.PYTHON)
|
||||
assert ls.is_ignored_path("pkg/mod.py") is False
|
||||
assert _location_request(ls).convert_location_item(_location_item(tmp_path / "pkg" / "mod.py")) is None
|
||||
|
||||
|
||||
def test_location_at_existing_ignored_path_is_skipped(tmp_path: Path) -> None:
|
||||
ls = _IgnoredPathServer(tmp_path, Language.PYTHON, ignored_dirnames=("generated",))
|
||||
ls = _IgnoredPathServer(tmp_path, LanguageServerId.PYTHON, ignored_dirnames=("generated",))
|
||||
source_file = tmp_path / "generated" / "app.py"
|
||||
source_file.parent.mkdir(parents=True)
|
||||
source_file.write_text("x = 1\n")
|
||||
@@ -186,7 +186,7 @@ def test_location_at_existing_ignored_path_is_skipped(tmp_path: Path) -> None:
|
||||
|
||||
|
||||
def test_location_at_existing_source_path_is_converted(tmp_path: Path) -> None:
|
||||
ls = _IgnoredPathServer(tmp_path, Language.PYTHON)
|
||||
ls = _IgnoredPathServer(tmp_path, LanguageServerId.PYTHON)
|
||||
source_file = tmp_path / "pkg" / "mod.py"
|
||||
source_file.parent.mkdir(parents=True)
|
||||
source_file.write_text("x = 1\n")
|
||||
|
||||
Reference in new issue
Block a user