https://github.com/DeinAlptraum updated https://github.com/llvm/llvm-project/pull/177764
>From b57527dbe70fcb4248914001c699da4acbdd685e Mon Sep 17 00:00:00 2001 From: Jannick Kremer <[email protected]> Date: Sat, 24 Jan 2026 22:36:47 +0900 Subject: [PATCH] Deprecate CodeCompletionResults.results --- clang/bindings/python/clang/cindex.py | 18 ++++++++++++++++++ .../tests/cindex/test_code_completion.py | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py index 428ac694720fa..a0b7c475a5fc5 100644 --- a/clang/bindings/python/clang/cindex.py +++ b/clang/bindings/python/clang/cindex.py @@ -3283,8 +3283,26 @@ def from_param(self) -> _Pointer[CCRStructure]: def __del__(self) -> None: conf.lib.clang_disposeCodeCompleteResults(self) + def __len__(self) -> int: + return self.ptr.contents.numResults + + def __getitem__(self, key: int) -> CodeCompletionResult: + if len(self) <= key: + raise IndexError + + return self.ptr.contents.results[key] + @property def results(self) -> CCRStructure: + warnings.warn( + "Access to 'CodeCompletionResult's through " + "'CodeCompletionResults.results' will be removed in a future release." + "Existing uses of 'CodeCompletionResults.results' should be changed " + "to directly use 'CodeCompletionResults': it nows supports '__len__' " + "and '__getitem__', so it can be used the same as " + "'CodeCompletionResults.results'.", + DeprecationWarning, + ) return self.ptr.contents @property diff --git a/clang/bindings/python/tests/cindex/test_code_completion.py b/clang/bindings/python/tests/cindex/test_code_completion.py index c376b0e5cce40..c0a6a7069344b 100644 --- a/clang/bindings/python/tests/cindex/test_code_completion.py +++ b/clang/bindings/python/tests/cindex/test_code_completion.py @@ -14,7 +14,7 @@ def check_completion_results(self, cr, expected): self.assertIsNotNone(cr) self.assertEqual(len(cr.diagnostics), 0) - completions = [str(c) for c in cr.results] + completions = [str(c) for c in cr] for c in expected: self.assertIn(c, completions) _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
