mirror of
https://github.com/tiennm99/serena.git
synced 2026-10-20 00:15:41 +00:00
Rename _cache_context_fingerprint -> _document_symbols_cache_fingerprint
Also improve docstring to make clear what the purpose is
This commit is contained in:
1 parent
3d4610fef4
commit
8375da7dc9
2 files changed
+15
-7
No files matched your search
@@ -165,7 +165,7 @@ class Gopls(SolidLanguageServer):
|
|||||||
_CACHE_CONTEXT_ENV_KEYS = ("GOFLAGS", "GOOS", "GOARCH", "CGO_ENABLED")
|
_CACHE_CONTEXT_ENV_KEYS = ("GOFLAGS", "GOOS", "GOARCH", "CGO_ENABLED")
|
||||||
|
|
||||||
@override
|
@override
|
||||||
def _cache_context_fingerprint(self) -> str | None:
|
def _document_symbols_cache_fingerprint(self) -> str | None:
|
||||||
"""
|
"""
|
||||||
Compute a deterministic fingerprint of the Go build context.
|
Compute a deterministic fingerprint of the Go build context.
|
||||||
|
|
||||||
|
|||||||
+14
-6
@@ -1987,14 +1987,22 @@ class SolidLanguageServer(ABC):
|
|||||||
|
|
||||||
return defining_symbol
|
return defining_symbol
|
||||||
|
|
||||||
def _cache_context_fingerprint(self) -> Hashable | None:
|
def _document_symbols_cache_fingerprint(self) -> Hashable | None:
|
||||||
"""
|
"""
|
||||||
Return a fingerprint of any language-server-specific context that affects cached results.
|
Returns a fingerprint of any language server-specific aspects that result in changes
|
||||||
|
to the high-level document symbol information.
|
||||||
|
|
||||||
Subclasses may override to provide a deterministic value that changes when cached results
|
Language servers must implement this method/change the return value
|
||||||
would be invalidated (e.g., build flags, environment variables).
|
* whenever they change the `request_document_symbols` implementation to modify the returned content
|
||||||
|
* are reconfigured in a way that affects the returned contents (e.g. context-specific configuration
|
||||||
|
such as build flags or environment variables); configuration options can, in such cases, be
|
||||||
|
hashed together to produce a single fingerprint value.
|
||||||
|
|
||||||
|
Whenever the value changes, the document symbols cache will be invalidated and re-populated.
|
||||||
|
|
||||||
The value must be hashable and safe for inclusion in cache version tuples.
|
The value must be hashable and safe for inclusion in cache version tuples.
|
||||||
|
E.g. use an integer, a string or a tuple of integers/strings.
|
||||||
|
|
||||||
Returns None if no context-specific fingerprint is needed.
|
Returns None if no context-specific fingerprint is needed.
|
||||||
"""
|
"""
|
||||||
return None
|
return None
|
||||||
@@ -2005,7 +2013,7 @@ class SolidLanguageServer(ABC):
|
|||||||
|
|
||||||
Incorporates cache context fingerprint if provided by the language server.
|
Incorporates cache context fingerprint if provided by the language server.
|
||||||
"""
|
"""
|
||||||
fingerprint = self._cache_context_fingerprint()
|
fingerprint = self._document_symbols_cache_fingerprint()
|
||||||
if fingerprint is not None:
|
if fingerprint is not None:
|
||||||
return (self.DOCUMENT_SYMBOL_CACHE_VERSION, fingerprint)
|
return (self.DOCUMENT_SYMBOL_CACHE_VERSION, fingerprint)
|
||||||
return self.DOCUMENT_SYMBOL_CACHE_VERSION
|
return self.DOCUMENT_SYMBOL_CACHE_VERSION
|
||||||
@@ -2030,7 +2038,7 @@ class SolidLanguageServer(ABC):
|
|||||||
|
|
||||||
def _raw_document_symbols_cache_version(self) -> tuple[Hashable, ...]:
|
def _raw_document_symbols_cache_version(self) -> tuple[Hashable, ...]:
|
||||||
base_version: tuple[Hashable, ...] = (self.RAW_DOCUMENT_SYMBOLS_CACHE_VERSION, self._ls_specific_raw_document_symbols_cache_version)
|
base_version: tuple[Hashable, ...] = (self.RAW_DOCUMENT_SYMBOLS_CACHE_VERSION, self._ls_specific_raw_document_symbols_cache_version)
|
||||||
fingerprint = self._cache_context_fingerprint()
|
fingerprint = self._document_symbols_cache_fingerprint()
|
||||||
if fingerprint is not None:
|
if fingerprint is not None:
|
||||||
return (*base_version, fingerprint)
|
return (*base_version, fingerprint)
|
||||||
return base_version
|
return base_version
|
||||||
|
|||||||
Reference in new issue
Block a user