Refactoring: Rename Language to LanguageServerId

This resolves a long-standing naming issue in Serena & SolidLSP.
This commit is contained in:
Dominik Jain authored and Dominik Jain committed 2026-07-22 20:55:36 +02:00
1 parent ef0e218fb1
commit d2cf18ddcb
180 files changed
+1806 -1767

No files matched your search

+19 -19
View File
@@ -4,8 +4,8 @@ from pathlib import Path
import pytest
from solidlsp import SolidLanguageServer
from solidlsp.ls_config import Language
from test.conftest import is_ci, is_windows, language_tests_enabled
from solidlsp.ls_config import LanguageServerId
from test.conftest import is_ci, is_windows, language_server_tests_enabled
from test.solidlsp.conftest import format_symbol_for_assert, has_malformed_name, request_all_symbols
@@ -15,20 +15,20 @@ def _php_supports_phpactor() -> bool:
return "openssl" in installed_extensions
_php_servers: list[Language] = [Language.PHP]
if language_tests_enabled(Language.PHP_PHPACTOR):
_php_servers: list[LanguageServerId] = [LanguageServerId.PHP]
if language_server_tests_enabled(LanguageServerId.PHP_PHPACTOR):
if not (is_windows and is_ci) and _php_supports_phpactor():
_php_servers.append(Language.PHP_PHPACTOR)
if language_tests_enabled(Language.PHP_PHPANTOM):
_php_servers.append(Language.PHP_PHPANTOM)
_php_servers.append(LanguageServerId.PHP_PHPACTOR)
if language_server_tests_enabled(LanguageServerId.PHP_PHPANTOM):
_php_servers.append(LanguageServerId.PHP_PHPANTOM)
def _is_phpactor(language_server: SolidLanguageServer) -> bool:
return language_server.language_server.language == Language.PHP_PHPACTOR
return language_server.language_server.ls_id == LanguageServerId.PHP_PHPACTOR
def _is_phpantom(language_server: SolidLanguageServer) -> bool:
return language_server.language_server.language == Language.PHP_PHPANTOM
return language_server.language_server.ls_id == LanguageServerId.PHP_PHPANTOM
def _is_non_default_php_backend(language_server: SolidLanguageServer) -> bool:
@@ -38,14 +38,14 @@ def _is_non_default_php_backend(language_server: SolidLanguageServer) -> bool:
@pytest.mark.php
class TestPhpLanguageServers:
@pytest.mark.parametrize("language_server", _php_servers, indirect=True)
@pytest.mark.parametrize("repo_path", [Language.PHP], indirect=True)
@pytest.mark.parametrize("repo_path", [LanguageServerId.PHP], indirect=True)
def test_ls_is_running(self, language_server: SolidLanguageServer, repo_path: Path) -> None:
"""Test that the language server starts and stops successfully."""
assert language_server.is_running()
assert Path(language_server.language_server.repository_root_path).resolve() == repo_path.resolve()
@pytest.mark.parametrize("language_server", _php_servers, indirect=True)
@pytest.mark.parametrize("repo_path", [Language.PHP], indirect=True)
@pytest.mark.parametrize("repo_path", [LanguageServerId.PHP], indirect=True)
def test_find_definition_within_file(self, language_server: SolidLanguageServer, repo_path: Path) -> None:
# In index.php:
# Line 9 (1-indexed): $greeting = greet($userName);
@@ -74,7 +74,7 @@ class TestPhpLanguageServers:
assert definition_location["range"]["start"]["character"] == 0
@pytest.mark.parametrize("language_server", _php_servers, indirect=True)
@pytest.mark.parametrize("repo_path", [Language.PHP], indirect=True)
@pytest.mark.parametrize("repo_path", [LanguageServerId.PHP], indirect=True)
def test_find_definition_across_files(self, language_server: SolidLanguageServer, repo_path: Path) -> None:
# Intelephense uses line 12 (0-indexed), Phpactor uses line 13 (0-indexed)
if _is_non_default_php_backend(language_server):
@@ -94,7 +94,7 @@ class TestPhpLanguageServers:
assert definition_location["range"]["start"]["character"] == 0
@pytest.mark.parametrize("language_server", _php_servers, indirect=True)
@pytest.mark.parametrize("repo_path", [Language.PHP], indirect=True)
@pytest.mark.parametrize("repo_path", [LanguageServerId.PHP], indirect=True)
def test_find_definition_simple_variable(self, language_server: SolidLanguageServer, repo_path: Path) -> None:
file_path = str(repo_path / "simple_var.php")
@@ -119,7 +119,7 @@ class TestPhpLanguageServers:
assert definition_location["range"]["start"]["character"] == 0 # $localVar (0-indexed)
@pytest.mark.parametrize("language_server", _php_servers, indirect=True)
@pytest.mark.parametrize("repo_path", [Language.PHP], indirect=True)
@pytest.mark.parametrize("repo_path", [LanguageServerId.PHP], indirect=True)
def test_find_references_within_file(self, language_server: SolidLanguageServer, repo_path: Path) -> None:
index_php_path = str(repo_path / "index.php")
@@ -167,7 +167,7 @@ class TestPhpLanguageServers:
assert actual_locations == expected_locations
@pytest.mark.parametrize("language_server", _php_servers, indirect=True)
@pytest.mark.parametrize("repo_path", [Language.PHP], indirect=True)
@pytest.mark.parametrize("repo_path", [LanguageServerId.PHP], indirect=True)
def test_find_references_across_files(self, language_server: SolidLanguageServer, repo_path: Path) -> None:
helper_php_path = str(repo_path / "helper.php")
# In index.php (0-indexed lines):
@@ -208,7 +208,7 @@ class TestPhpLanguageServers:
usage_in_index_php = {"uri_suffix": "index.php", "line": 13, "character": 0}
assert usage_in_index_php in actual_locations_comparable, "Usage of helperFunction in index.php not found"
@pytest.mark.parametrize("language_server", [Language.PHP, Language.PHP_PHPANTOM], indirect=True)
@pytest.mark.parametrize("language_server", [LanguageServerId.PHP, LanguageServerId.PHP_PHPANTOM], indirect=True)
def test_find_symbol(self, language_server: SolidLanguageServer) -> None:
"""Test that document symbols are properly retrieved after Intelephense capability fix."""
from solidlsp.ls_utils import SymbolUtils
@@ -217,7 +217,7 @@ class TestPhpLanguageServers:
assert SymbolUtils.symbol_tree_contains_name(symbols, "helperFunction"), "helperFunction not found in symbol tree"
assert SymbolUtils.symbol_tree_contains_name(symbols, "greet"), "greet function not found in symbol tree"
@pytest.mark.parametrize("language_server", [Language.PHP, Language.PHP_PHPANTOM], indirect=True)
@pytest.mark.parametrize("language_server", [LanguageServerId.PHP, LanguageServerId.PHP_PHPANTOM], indirect=True)
def test_document_symbols(self, language_server: SolidLanguageServer) -> None:
"""Test that document symbols are properly retrieved for a specific file."""
doc_symbols = language_server.request_document_symbols("helper.php")
@@ -225,7 +225,7 @@ class TestPhpLanguageServers:
symbol_names = [sym.get("name") for sym in all_symbols[0] if sym.get("name")]
assert "helperFunction" in symbol_names, f"helperFunction not found in document symbols. Found: {symbol_names}"
@pytest.mark.parametrize("language_server", [Language.PHP, Language.PHP_PHPANTOM], indirect=True)
@pytest.mark.parametrize("language_server", [LanguageServerId.PHP, LanguageServerId.PHP_PHPANTOM], indirect=True)
def test_document_symbols_hierarchical_structure(self, language_server: SolidLanguageServer) -> None:
"""Verify Intelephense returns hierarchical DocumentSymbol format.
@@ -259,7 +259,7 @@ class TestPhpLanguageServers:
assert "greet" not in root_names, f"greet should be a child of Dog, not at root level. Roots: {root_names}"
assert "fetch" not in root_names, f"fetch should be a child of Dog, not at root level. Roots: {root_names}"
@pytest.mark.parametrize("language_server", [Language.PHP, Language.PHP_PHPANTOM], indirect=True)
@pytest.mark.parametrize("language_server", [LanguageServerId.PHP, LanguageServerId.PHP_PHPANTOM], indirect=True)
def test_full_symbol_tree_within_file(self, language_server: SolidLanguageServer) -> None:
"""Verify request_full_symbol_tree scoped to a PHP file returns correct symbols.
+6 -6
View File
@@ -15,7 +15,7 @@ rest of the PHP suite.
import pytest
from solidlsp.ls_config import FilenameMatcher, Language
from solidlsp.ls_config import FilenameMatcher, LanguageServerId
from solidlsp.ls_utils import SymbolUtils
from test.conftest import get_repo_path, start_ls_context
@@ -24,14 +24,14 @@ class TestPhpSourceFnMatcherDefaults:
def test_phtml_matched_by_default_for_all_php_language_servers(self) -> None:
# .phtml is a standard (yet outdated) PHP extension, so all PHP language servers treat it
# as a PHP source by default (#1710).
for language in (Language.PHP, Language.PHP_PHPACTOR, Language.PHP_PHPANTOM):
for language in (LanguageServerId.PHP, LanguageServerId.PHP_PHPACTOR, LanguageServerId.PHP_PHPANTOM):
matcher = language.get_source_fn_matcher()
assert matcher.is_relevant_filename("index.php"), f"{language}: .php not matched"
assert matcher.is_relevant_filename("template.phtml"), f"{language}: .phtml not matched"
def test_module_not_matched_by_default(self) -> None:
# guard for the integration test below: .module files only become visible via file_filter
assert not Language.PHP.get_source_fn_matcher().is_relevant_filename("hooks.module")
assert not LanguageServerId.PHP.get_source_fn_matcher().is_relevant_filename("hooks.module")
def test_file_extensions_property_returns_copy(self) -> None:
# _create_base_initialize_params derives the files.associations globs from this property;
@@ -54,14 +54,14 @@ class TestFileFilterIntegration:
def test_module_file_symbols_and_references_visible(self) -> None:
with start_ls_context(
Language.PHP,
ls_specific_settings={Language.PHP: {"file_filter": [".module"]}},
LanguageServerId.PHP,
ls_specific_settings={LanguageServerId.PHP: {"file_filter": [".module"]}},
) as ls:
# Layer 2 (files.associations) must be asserted FIRST: the reference in the
# never-opened drupal_module.module can only come from the server's association-driven
# background index. request_full_symbol_tree below didOpens every matched file in the
# LS, after which this assertion could pass even without the associations.
helper_php_path = str(get_repo_path(Language.PHP) / "helper.php")
helper_php_path = str(get_repo_path(LanguageServerId.PHP) / "helper.php")
references = ls.request_references(helper_php_path, 2, len("function "))
assert any(ref["uri"].endswith("drupal_module.module") for ref in references), (
f"helperFunction call in drupal_module.module not found in references: {references}"
+2 -2
View File
@@ -1,13 +1,13 @@
import pytest
from solidlsp import SolidLanguageServer
from solidlsp.ls_config import Language
from solidlsp.ls_config import LanguageServerId
from test.solidlsp.util.diagnostics import assert_file_diagnostics
@pytest.mark.php
class TestPhpDiagnostics:
@pytest.mark.parametrize("language_server", [Language.PHP, Language.PHP_PHPANTOM], indirect=True)
@pytest.mark.parametrize("language_server", [LanguageServerId.PHP, LanguageServerId.PHP_PHPANTOM], indirect=True)
def test_file_diagnostics(self, language_server: SolidLanguageServer) -> None:
assert_file_diagnostics(
language_server,
+9 -9
View File
@@ -5,7 +5,7 @@ import pytest
from serena.code_editor import LanguageServerCodeEditor
from solidlsp import SolidLanguageServer
from solidlsp.ls_config import Language
from solidlsp.ls_config import LanguageServerId
from src.serena.symbol import LanguageServerSymbolRetriever
from test.conftest import project_with_ls_context, start_ls_context
@@ -22,7 +22,7 @@ def _extract_changes(workspace_edit: dict) -> dict[str, list[dict]]:
def _copy_php_fixture(tmp_path: Path) -> Path:
from test.conftest import get_repo_path
fixture_path = get_repo_path(Language.PHP)
fixture_path = get_repo_path(LanguageServerId.PHP)
target_path = tmp_path / "test_repo"
shutil.copytree(fixture_path, target_path)
return target_path
@@ -126,8 +126,8 @@ def _find_child_symbol(parent_symbol: dict, child_name: str) -> dict:
@pytest.mark.php
class TestPHPantom:
@pytest.mark.parametrize("language_server", [Language.PHP_PHPANTOM], indirect=True)
@pytest.mark.parametrize("repo_path", [Language.PHP], indirect=True)
@pytest.mark.parametrize("language_server", [LanguageServerId.PHP_PHPANTOM], indirect=True)
@pytest.mark.parametrize("repo_path", [LanguageServerId.PHP], indirect=True)
def test_rename_local_variable(self, language_server: SolidLanguageServer, repo_path: Path) -> None:
workspace_edit = language_server.request_rename_symbol_edit(str(Path("index.php")), 9, 1, "welcomeMessage")
assert workspace_edit is not None, "Rename should be supported for local PHP variables"
@@ -145,7 +145,7 @@ class TestPHPantom:
repo_path = _copy_php_fixture(tmp_path)
_write_psr4_fixture(repo_path)
with start_ls_context(Language.PHP_PHPANTOM, repo_path=str(repo_path), solidlsp_dir=tmp_path) as language_server:
with start_ls_context(LanguageServerId.PHP_PHPANTOM, repo_path=str(repo_path), solidlsp_dir=tmp_path) as language_server:
welcome_symbol = _find_root_symbol(language_server, "src/Welcome.php", "Welcome")
greet_symbol = _find_child_symbol(welcome_symbol, "greet")
selection = greet_symbol["selectionRange"]["start"]
@@ -164,7 +164,7 @@ class TestPHPantom:
repo_path = _copy_php_fixture(tmp_path)
_write_psr4_fixture(repo_path)
with start_ls_context(Language.PHP_PHPANTOM, repo_path=str(repo_path), solidlsp_dir=tmp_path) as language_server:
with start_ls_context(LanguageServerId.PHP_PHPANTOM, repo_path=str(repo_path), solidlsp_dir=tmp_path) as language_server:
welcome_symbol = _find_root_symbol(language_server, "src/Welcome.php", "Welcome")
selection = welcome_symbol["selectionRange"]["start"]
workspace_edit = language_server.request_rename_symbol_edit(
@@ -182,7 +182,7 @@ class TestPHPantom:
repo_path = _copy_php_fixture(tmp_path)
_write_psr4_fixture(repo_path)
with project_with_ls_context(Language.PHP_PHPANTOM, str(repo_path)) as project:
with project_with_ls_context(LanguageServerId.PHP_PHPANTOM, str(repo_path)) as project:
symbol_retriever = LanguageServerSymbolRetriever(project)
code_editor = LanguageServerCodeEditor(symbol_retriever)
status_message = code_editor.rename_symbol("Welcome", relative_path="src/Welcome.php", new_name="GreetingService")
@@ -200,7 +200,7 @@ class TestPHPantom:
repo_path = _copy_php_fixture(tmp_path)
_write_psr4_fixture(repo_path)
with project_with_ls_context(Language.PHP_PHPANTOM, str(repo_path)) as project:
with project_with_ls_context(LanguageServerId.PHP_PHPANTOM, str(repo_path)) as project:
symbol_retriever = LanguageServerSymbolRetriever(project)
symbols = symbol_retriever.find("Welcome", within_relative_path="src/Welcome.php")
info_by_symbol = symbol_retriever.request_info_for_symbol_batch(symbols)
@@ -213,7 +213,7 @@ class TestPHPantom:
repo_path = _copy_php_fixture(tmp_path)
_write_psr4_fixture(repo_path)
with start_ls_context(Language.PHP_PHPANTOM, repo_path=str(repo_path), solidlsp_dir=tmp_path) as language_server:
with start_ls_context(LanguageServerId.PHP_PHPANTOM, repo_path=str(repo_path), solidlsp_dir=tmp_path) as language_server:
class_symbols = language_server.request_workspace_symbol("Welcome") or []
function_symbols = language_server.request_workspace_symbol("format_name") or []
constant_symbols = language_server.request_workspace_symbol("MAX_GREETING_LENGTH") or []