Ensure memory-efficient high-level document symbol cache #944

* Introduce SymbolBody representation (compact), from which the
    body can be reconstructed, rendering body computation lazy
  * Introduce SymbolBodyFactory for the creation of such instances,
    ensuring that instances created from the same factory share
    the same file content, allowing the in-memory and on-disk caches
    to have a significantly smaller memory footprint
  * Change type of "body" key in UnifiedSymbolRepresentation to use
    SymbolBody instead of str
  * Adjust all usages of the "body" key
This commit is contained in:
Dominik Jain authored and Dominik Jain committed 2026-01-22 01:39:59 +01:00
1 parent fe0cc7bb0c
commit c2e795fce4
13 files changed
+108 -56

No files matched your search

@@ -34,7 +34,7 @@ class TestLanguageServerSymbols:
assert containing_symbol["name"] == "create_user"
assert containing_symbol["kind"] == SymbolKind.Method
if "body" in containing_symbol:
assert containing_symbol["body"].strip().startswith("def create_user(self")
assert containing_symbol["body"].get_text().strip().startswith("def create_user(self")
@pytest.mark.parametrize("language_server", [Language.PYTHON], indirect=True)
def test_references_to_variables(self, language_server: SolidLanguageServer) -> None:
@@ -463,7 +463,6 @@ class TestLanguageServerSymbols:
for ref in language_server.request_referencing_symbols(file_path, 4, 6, include_imports=False, include_file_symbols=True)
]
assert {ref["kind"] for ref in references_to_typing} == {SymbolKind.File}
assert {ref["body"] for ref in references_to_typing} == {""}
# now include bodies
references_to_typing = [