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

+3 -3
View File
@@ -137,7 +137,7 @@ class TestTomlLanguageServerBasics:
# Check that body exists and contains expected content
# Note: Taplo includes the section header in the body
assert "body" in package_symbol, "'package' symbol should have body"
package_body = package_symbol["body"]
package_body = package_symbol["body"].get_text()
assert 'name = "test_project"' in package_body, "Body should contain 'name' field"
assert 'version = "0.1.0"' in package_body, "Body should contain 'version' field"
assert 'edition = "2021"' in package_body, "Body should contain 'edition' field"
@@ -146,7 +146,7 @@ class TestTomlLanguageServerBasics:
deps_symbol = next((s for s in all_symbols if s.get("name") == "dependencies"), None)
assert deps_symbol is not None, "Should find 'dependencies' symbol"
assert "body" in deps_symbol, "'dependencies' symbol should have body"
deps_body = deps_symbol["body"]
deps_body = deps_symbol["body"].get_text()
assert "serde" in deps_body, "Body should contain serde dependency"
assert "tokio" in deps_body, "Body should contain tokio dependency"
@@ -160,7 +160,7 @@ class TestTomlLanguageServerBasics:
)
assert features_symbol is not None, "Should find top-level 'features' table symbol"
assert "body" in features_symbol, "'features' symbol should have body"
features_body = features_symbol["body"]
features_body = features_symbol["body"].get_text()
assert "default" in features_body, "Body should contain 'default' feature"
@pytest.mark.parametrize("language_server", [Language.TOML], indirect=True)