================
@@ -3103,44 +3086,67 @@ def string(self) -> CompletionString | None:
         return CompletionString(res)
 
     def isKindOptional(self) -> bool:
-        return self.__kindNumber == 0
+        return self.__kind_id == 0
 
     def isKindTypedText(self) -> bool:
-        return self.__kindNumber == 1
+        return self.__kind_id == 1
 
     def isKindPlaceHolder(self) -> bool:
-        return self.__kindNumber == 3
+        return self.__kind_id == 3
 
     def isKindInformative(self) -> bool:
-        return self.__kindNumber == 4
+        return self.__kind_id == 4
 
     def isKindResultType(self) -> bool:
-        return self.__kindNumber == 15
-
-
-completionChunkKindMap = {
-    0: CompletionChunk.Kind("Optional"),
-    1: CompletionChunk.Kind("TypedText"),
-    2: CompletionChunk.Kind("Text"),
-    3: CompletionChunk.Kind("Placeholder"),
-    4: CompletionChunk.Kind("Informative"),
-    5: CompletionChunk.Kind("CurrentParameter"),
-    6: CompletionChunk.Kind("LeftParen"),
-    7: CompletionChunk.Kind("RightParen"),
-    8: CompletionChunk.Kind("LeftBracket"),
-    9: CompletionChunk.Kind("RightBracket"),
-    10: CompletionChunk.Kind("LeftBrace"),
-    11: CompletionChunk.Kind("RightBrace"),
-    12: CompletionChunk.Kind("LeftAngle"),
-    13: CompletionChunk.Kind("RightAngle"),
-    14: CompletionChunk.Kind("Comma"),
-    15: CompletionChunk.Kind("ResultType"),
-    16: CompletionChunk.Kind("Colon"),
-    17: CompletionChunk.Kind("SemiColon"),
-    18: CompletionChunk.Kind("Equal"),
-    19: CompletionChunk.Kind("HorizontalSpace"),
-    20: CompletionChunk.Kind("VerticalSpace"),
-}
+        return self.__kind_id == 15
+
+### Completion Chunk Kinds ###
+class CompletionChunkKind(BaseEnumeration):
+    """
+    Describes a single piece of text within a code-completion string.
+    """
+
+    def __str__(self) -> str:
+        """
+        Converts enum value to string in the old camelCase format.
+        This is a temporary measure that will be changed in the future release
+        to return string in ALL_CAPS format, like for other enums.
+        """
+
+        warnings.warn(
+            "String representation of 'CompletionChunkKind' will be "
+            "changed in a future release from 'camelCase' to 'ALL_CAPS' to "
+            "match other enums. 'CompletionChunkKind's can be "
+            "compared to one another without conversion to string.",
+            DeprecationWarning,
+        )
+        # Remove underscores
+        components = self.name.split("_")
+        # Upper-camel case each split component
+        components = [component.lower().capitalize() for component in 
components]
+        return "".join(components)
----------------
DeinAlptraum wrote:

To ensure that the `__str__` representation is the same as 
`CompletionChunk.Kind`, I've added tests when I wrote this in the first commit: 
https://github.com/llvm/llvm-project/pull/176631/commits/76e2a19d3a2047b728832f0a2c4e16b8e1b76944

Since they can't run anymore after removing `CompletionChunk.Kind` I've removed 
them again, but you can check the CI on the commit above to see that they 
passed.

https://github.com/llvm/llvm-project/pull/176631
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to