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 1/3] 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)] >From b67b19b2d3d880a307be0e9216bb51e57a26c8be Mon Sep 17 00:00:00 2001 From: Jannick Kremer <jannick.kre...@mailbox.org> Date: Wed, 24 Sep 2025 22:18:25 +0900 Subject: [PATCH 2/3] Turn comment into docstring --- clang/bindings/python/clang/cindex.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py index 7f2c2183ec1bb..4b9abfb829b6c 100644 --- a/clang/bindings/python/clang/cindex.py +++ b/clang/bindings/python/clang/cindex.py @@ -3039,9 +3039,11 @@ 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): + """ + Converting the new enum names (full upper-case, underscore separated) + to the old ones (separated by capitalization), e.g. RESULT_TYPE -> ResultType + """ # Remove underscores components = kind.name.split("_") # Upper-camel case each split component >From 9e200ecb1bfd5481aff5057d960ceffaf18b2df3 Mon Sep 17 00:00:00 2001 From: Jannick Kremer <jannick.kre...@mailbox.org> Date: Wed, 24 Sep 2025 22:19:19 +0900 Subject: [PATCH 3/3] Change converter function name --- clang/bindings/python/clang/cindex.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py index 4b9abfb829b6c..220e05f69eacf 100644 --- a/clang/bindings/python/clang/cindex.py +++ b/clang/bindings/python/clang/cindex.py @@ -3191,7 +3191,7 @@ def __repr__(self) -> str: + " || Priority: " + str(self.priority) + " || Availability: " - + _kind_to_old_name(self.availability) + + _convert_screaming_caps_to_pascal_case(self.availability) + " || Brief comment: " + str(self.briefComment) ) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits