================
@@ -3149,6 +3073,107 @@ def __str__(self) -> str:
VERTICAL_SPACE = 20
+class CompletionChunk:
+ class SpellingCacheAlias:
+ """
+ A temporary utility that acts as an alias to
CompletionChunk.SPELLING_CACHE.
+ This will be removed without deprecation warning in a future release.
+ Please do not use it directly!
+ """
+
+ deprecation_message = (
+ "'SPELLING_CACHE' has been moved into the scope of
'CompletionChunk' "
+ "and adapted to use 'CompletionChunkKind's as keys instead of
their "
+ "enum values. Please adapt all uses of 'SPELLING_CACHE' to use "
+ "'CompletionChunk.SPELLING_CACHE' instead. The old
'SPELLING_CACHE' "
+ "will be removed in a future release."
+ )
+
+ def __getitem__(self, value: int):
+ warnings.warn(self.deprecation_message, DeprecationWarning)
+ return
CompletionChunk.SPELLING_CACHE[CompletionChunkKind.from_id(value)]
+
+ def __contains__(self, value: int):
+ warnings.warn(self.deprecation_message, DeprecationWarning)
+ return CompletionChunkKind.from_id(value) in
CompletionChunk.SPELLING_CACHE
----------------
DeinAlptraum wrote:
I had to add an extra class so we can put some processing into the
`__getitem__` operator, for conversion and to add a deprecation warning. I'm
currently only replicating the `[]` and `in` operators, but technically there
are a bunch more usages that would break here, such as if you call
`SPELLING_CACHE.keys()` or similar. I could cover for this as well by adding
additional methods, but trying to perfectly replicate `dict()` behavior in this
temporary Alias class seems like a bit of a waste of effort... what do you
think?
https://github.com/llvm/llvm-project/pull/177586
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits