https://github.com/DeinAlptraum updated https://github.com/llvm/llvm-project/pull/160296
>From e29ee6463042dc9c8b4366af2d884c1c20e6a1f5 Mon Sep 17 00:00:00 2001 From: Jannick Kremer <jannick.kre...@mailbox.org> Date: Tue, 23 Sep 2025 22:26:44 +0900 Subject: [PATCH] Use existing AvailabilityKind enum for code completion availability --- clang/bindings/python/clang/cindex.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py index 13a91d83ede1c..7f2c2183ec1bb 100644 --- a/clang/bindings/python/clang/cindex.py +++ b/clang/bindings/python/clang/cindex.py @@ -3039,6 +3039,16 @@ class _CXUnsavedFile(Structure): } +# Converting the new enum names (full upper-case, underscore separated) +# to the old ones (separated by capitalization), e.g. RESULT_TYPE -> ResultType +def _kind_to_old_name(kind: BaseEnumeration): + # Remove underscores + components = kind.name.split("_") + # Upper-camel case each split component + components = [component.lower().capitalize() for component in components] + return "".join(components) + + class CompletionChunk: class Kind: def __init__(self, name: str): @@ -3165,9 +3175,9 @@ def priority(self) -> int: return conf.lib.clang_getCompletionPriority(self.obj) # type: ignore [no-any-return] @property - def availability(self) -> CompletionChunk.Kind: + def availability(self) -> AvailabilityKind: res = conf.lib.clang_getCompletionAvailability(self.obj) - return availabilityKinds[res] + return AvailabilityKind.from_id(res) @property def briefComment(self) -> str: @@ -3179,20 +3189,12 @@ def __repr__(self) -> str: + " || Priority: " + str(self.priority) + " || Availability: " - + str(self.availability) + + _kind_to_old_name(self.availability) + " || Brief comment: " + str(self.briefComment) ) -availabilityKinds = { - 0: CompletionChunk.Kind("Available"), - 1: CompletionChunk.Kind("Deprecated"), - 2: CompletionChunk.Kind("NotAvailable"), - 3: CompletionChunk.Kind("NotAccessible"), -} - - class CodeCompletionResult(Structure): _fields_ = [("cursorKind", c_int), ("completionString", c_object_p)] _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits