mirror of
https://github.com/tiennm99/serena.git
synced 2026-10-12 12:14:19 +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
@@ -2,7 +2,7 @@ import os
|
||||
|
||||
import pytest
|
||||
|
||||
from solidlsp.ls_config import Language
|
||||
from solidlsp.ls_config import LanguageServerId
|
||||
from test.conftest import start_ls_context
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ class TestCCLSLanguages:
|
||||
],
|
||||
)
|
||||
def test_get_document_symbols(self, lang: str, unit: str, names: set[str]) -> None:
|
||||
with start_ls_context(Language.CPP) as ccls:
|
||||
with start_ls_context(LanguageServerId.CPP) as ccls:
|
||||
path = os.path.join(lang, unit)
|
||||
symbols = ccls.request_document_symbols(path).get_all_symbols_and_roots()
|
||||
symbols = symbols[0] if symbols and isinstance(symbols[0], list) else symbols
|
||||
|
||||
@@ -2,7 +2,7 @@ import os
|
||||
|
||||
import pytest
|
||||
|
||||
from solidlsp.ls_config import Language
|
||||
from solidlsp.ls_config import LanguageServerId
|
||||
from test.conftest import start_ls_context
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ class TestClangdLanguages:
|
||||
],
|
||||
)
|
||||
def test_get_document_symbols(self, lang: str, unit: str, names: set[str]) -> None:
|
||||
with start_ls_context(Language.CPP) as clangd:
|
||||
with start_ls_context(LanguageServerId.CPP) as clangd:
|
||||
path = os.path.join(lang, unit)
|
||||
symbols = clangd.request_document_symbols(path).get_all_symbols_and_roots()
|
||||
symbols = symbols[0] if symbols and isinstance(symbols[0], list) else symbols
|
||||
|
||||
@@ -14,18 +14,18 @@ from pathlib import Path
|
||||
import pytest
|
||||
|
||||
from solidlsp import SolidLanguageServer
|
||||
from solidlsp.ls_config import Language
|
||||
from solidlsp.ls_config import LanguageServerId
|
||||
from solidlsp.ls_utils import SymbolUtils
|
||||
from test.conftest import get_repo_path, language_tests_enabled, start_ls_context
|
||||
from test.conftest import get_repo_path, language_server_tests_enabled, start_ls_context
|
||||
from test.solidlsp.conftest import format_symbol_for_assert, has_malformed_name, request_all_symbols
|
||||
|
||||
_cpp_servers: list[Language] = [Language.CPP]
|
||||
if language_tests_enabled(Language.CPP_CCLS):
|
||||
_cpp_servers.append(Language.CPP_CCLS)
|
||||
_cpp_servers: list[LanguageServerId] = [LanguageServerId.CPP]
|
||||
if language_server_tests_enabled(LanguageServerId.CPP_CCLS):
|
||||
_cpp_servers.append(LanguageServerId.CPP_CCLS)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("language", [Language.CPP, Language.CPP_CCLS])
|
||||
def test_source_fn_matcher_includes_ino(language: Language) -> None:
|
||||
@pytest.mark.parametrize("language", [LanguageServerId.CPP, LanguageServerId.CPP_CCLS])
|
||||
def test_source_fn_matcher_includes_ino(language: LanguageServerId) -> None:
|
||||
"""Arduino .ino sketches are C++ and must route to the C++ language server.
|
||||
|
||||
This is a pure matcher check; it needs no running language server.
|
||||
@@ -172,7 +172,7 @@ int use_add() {
|
||||
@pytest.mark.cpp
|
||||
class TestCppDocumentSymbolCache:
|
||||
def _copy_cpp_fixture(self, tmp_path: Path) -> Path:
|
||||
fixture_path = get_repo_path(Language.CPP)
|
||||
fixture_path = get_repo_path(LanguageServerId.CPP)
|
||||
target_path = tmp_path / "test_repo"
|
||||
shutil.copytree(fixture_path, target_path)
|
||||
return target_path
|
||||
@@ -180,7 +180,7 @@ class TestCppDocumentSymbolCache:
|
||||
def test_cache_invalidates_when_clangd_context_changes(self, tmp_path: Path) -> None:
|
||||
repo_path = self._copy_cpp_fixture(tmp_path)
|
||||
ls_settings_alt = {
|
||||
Language.CPP: {
|
||||
LanguageServerId.CPP: {
|
||||
"compile_commands_dir": ".serena-alt",
|
||||
}
|
||||
}
|
||||
@@ -201,7 +201,7 @@ class TestCppDocumentSymbolCache:
|
||||
assert ls._raw_document_symbols_cache_is_modified
|
||||
assert ls._document_symbols_cache_is_modified
|
||||
|
||||
with start_ls_context(Language.CPP, repo_path=str(repo_path), solidlsp_dir=tmp_path) as ls_default:
|
||||
with start_ls_context(LanguageServerId.CPP, repo_path=str(repo_path), solidlsp_dir=tmp_path) as ls_default:
|
||||
_ = ls_default.request_document_symbols(main_cpp)
|
||||
|
||||
default_raw_cache_version = ls_default._raw_document_symbols_cache_version()
|
||||
@@ -212,7 +212,7 @@ class TestCppDocumentSymbolCache:
|
||||
cache_files = [p for p in cache_dir.rglob("*") if p.is_file()]
|
||||
assert cache_files, f"Expected SolidLSP to create cache artifacts under {cache_dir}"
|
||||
|
||||
with start_ls_context(Language.CPP, repo_path=str(repo_path), solidlsp_dir=tmp_path) as ls_default_again:
|
||||
with start_ls_context(LanguageServerId.CPP, repo_path=str(repo_path), solidlsp_dir=tmp_path) as ls_default_again:
|
||||
assert ls_default_again.cache_dir == cache_dir
|
||||
_assert_caches_loaded_and_clean(ls_default_again)
|
||||
_ = ls_default_again.request_document_symbols(main_cpp)
|
||||
@@ -220,7 +220,7 @@ class TestCppDocumentSymbolCache:
|
||||
assert not ls_default_again._document_symbols_cache_is_modified
|
||||
|
||||
with start_ls_context(
|
||||
Language.CPP,
|
||||
LanguageServerId.CPP,
|
||||
repo_path=str(repo_path),
|
||||
ls_specific_settings=ls_settings_alt,
|
||||
solidlsp_dir=tmp_path,
|
||||
|
||||
@@ -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.cpp
|
||||
class TestCppDiagnostics:
|
||||
@pytest.mark.parametrize("language_server", [Language.CPP], indirect=True)
|
||||
@pytest.mark.parametrize("language_server", [LanguageServerId.CPP], indirect=True)
|
||||
def test_file_diagnostics(self, language_server: SolidLanguageServer) -> None:
|
||||
assert_file_diagnostics(
|
||||
language_server,
|
||||
|
||||
@@ -23,12 +23,12 @@ from collections.abc import Iterator
|
||||
import pytest
|
||||
|
||||
from solidlsp import SolidLanguageServer
|
||||
from solidlsp.ls_config import Language
|
||||
from solidlsp.ls_config import LanguageServerId
|
||||
from solidlsp.ls_utils import SymbolUtils
|
||||
from test.conftest import find_identifier_position, get_repo_path, start_ls_context
|
||||
from test.solidlsp.conftest import document_symbol_names, find_document_symbol
|
||||
|
||||
UE_REPO_PATH = get_repo_path(Language.CPP).parent / "ue_test_repo"
|
||||
UE_REPO_PATH = get_repo_path(LanguageServerId.CPP).parent / "ue_test_repo"
|
||||
ABILITY_COMPONENT_H = os.path.join("Source", "TestGame", "AbilityComponent.h")
|
||||
ABILITY_ACTOR_H = os.path.join("Source", "TestGame", "AbilityActor.h")
|
||||
ABILITY_ACTOR_CPP = os.path.join("Source", "TestGame", "AbilityActor.cpp")
|
||||
@@ -37,7 +37,7 @@ ABILITY_ACTOR_CPP = os.path.join("Source", "TestGame", "AbilityActor.cpp")
|
||||
@pytest.fixture(scope="module")
|
||||
def language_server() -> Iterator[SolidLanguageServer]:
|
||||
"""Clangd over ue_test_repo; overrides the shared fixture for this module."""
|
||||
with start_ls_context(Language.CPP, repo_path=str(UE_REPO_PATH)) as ls:
|
||||
with start_ls_context(LanguageServerId.CPP, repo_path=str(UE_REPO_PATH)) as ls:
|
||||
yield ls
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user