mirror of
https://github.com/tiennm99/serena.git
synced 2026-10-13 22:16:23 +00:00
Cpp extensions (#1451)
* Add more cpp extensions * Allow FilenameMatcher to be case insensitive --------- Co-authored-by: Darin Morrison <darinmorrison@gmail.com> Co-authored-by: silvanshade <silvanshade@users.noreply.github.com> Co-authored-by: MischaPanch
This commit is contained in:
17 files changed
+263
-18
No files matched your search
@@ -0,0 +1,24 @@
|
||||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
from solidlsp.ls_config import Language
|
||||
from test.conftest import start_ls_context
|
||||
|
||||
|
||||
@pytest.mark.cpp
|
||||
class TestCCLSLanguages:
|
||||
@pytest.mark.parametrize(
|
||||
"lang, unit, names",
|
||||
[
|
||||
("C", "a.c", {"main"}),
|
||||
("Objective-C", "a.m", {"main", "Hello", "-hello"}),
|
||||
],
|
||||
)
|
||||
def test_get_document_symbols(self, lang: str, unit: str, names: set[str]) -> None:
|
||||
with start_ls_context(Language.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
|
||||
symbols = {s.get("name") for s in symbols}
|
||||
assert names == symbols, f"Expected '{names}' in document symbols, got: {symbols}"
|
||||
@@ -0,0 +1,30 @@
|
||||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
from solidlsp.ls_config import Language
|
||||
from test.conftest import start_ls_context
|
||||
|
||||
|
||||
@pytest.mark.cpp
|
||||
class TestClangdLanguages:
|
||||
@pytest.mark.parametrize(
|
||||
"lang, unit, names",
|
||||
[
|
||||
("C", "a.c", {"main"}),
|
||||
("CUDA", "a.cu", {"main", "cuda_hello"}),
|
||||
("CXX20", "a.cpp", {"main"}),
|
||||
("CXX20", "b.cpp", {"add", "add_f32"}),
|
||||
("CXX20", "b.cppm", {"add", "add_f32", "add_u32"}),
|
||||
("HIP", "a.hip", {"add_vectors"}),
|
||||
("OpenCL", "a.cl", {"add_vectors"}),
|
||||
("Objective-C", "a.m", {"main", "Hello", "-hello"}),
|
||||
],
|
||||
)
|
||||
def test_get_document_symbols(self, lang: str, unit: str, names: set[str]) -> None:
|
||||
with start_ls_context(Language.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
|
||||
symbols = {s.get("name") for s in symbols}
|
||||
assert names == symbols, f"Expected '{names}' in document symbols, got: {symbols}"
|
||||
@@ -16,16 +16,11 @@ import pytest
|
||||
from solidlsp import SolidLanguageServer
|
||||
from solidlsp.ls_config import Language
|
||||
from solidlsp.ls_utils import SymbolUtils
|
||||
from test.conftest import get_repo_path, start_ls_context
|
||||
from test.conftest import get_repo_path, language_tests_enabled, start_ls_context
|
||||
from test.solidlsp.conftest import format_symbol_for_assert, has_malformed_name, request_all_symbols
|
||||
|
||||
|
||||
def _ccls_available() -> bool:
|
||||
return shutil.which("ccls") is not None
|
||||
|
||||
|
||||
_cpp_servers: list[Language] = [Language.CPP]
|
||||
if _ccls_available():
|
||||
if language_tests_enabled(Language.CPP_CCLS):
|
||||
_cpp_servers.append(Language.CPP_CCLS)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user