Endilll wrote: > There are currently two ways to get AvailabilityKinds out of the API (except > for intializing them yourself): accessing the `availability` property on a > `Cursor`, or the property of the same name on a `CompletionString`. > > Changing the `__str__` of `AvailabilityKind` directly would mean a breaking > change over there instead.
Fair. > What would you like to be tested? I believe that today there is only three ways to work with the return value of `CompletionString.availability`: 1. Call `CompletionChunk.Kind.__repr__`. It returns `"<ChunkKind: %s>" % self`, which I hope is only used for debugging purposes. 2. Call `CompletionString.__repr__`. The long string that it returns is also tailored for humans, and is not suitable to be used for anything else, even if a user would try to parse it. 3. Call `CompletionChunk.Kind.__str__`. I think this is what is predominantly used today, because it's at least sane to use: `str(completion_string.availability) == "NotAccessible"`. (Note that they are not even equality comparable, so they have to be converted to strings.) This third usage is the one we should care about, and the one I'd like to be tested. > What's our plan with AvailabilityKind as it is presented in > CompletionString's __repr__? Consequently, I don't think we need to be concerned with the exact output of either `__repr__` functions. > I think it's also worth asking whether we want to go with this approach at > all: this is already a breaking change w.r.t. the string representations of > the availability attribute of CompletionString. I think we need `AvailabilityKindCompat` derived from `AvailabilityKind`. It should do several more things on top of being `AvailabilityKind`: 1. It should have `__str__` that returns camel case names, like `CompletionChunk.Kind.__str__` today, and emit `DeprecationWarning`. This way backwards compatibility is preserved. 2. It should be equality comparable with `AvailabilityKind`, so that when we replace `AvailabilityKindCompat` with `AvailabilityKind`, nothing breaks. This way we have a path forward. `CompletionString.availability` should return `AvailabilityKindCompat` during deprecation period, then removed. `CompletionString.Availiability` (the type) is not used today and is not going to be, so we should remove it. `availabilityKind` should also go away, but you've already done that. https://github.com/llvm/llvm-project/pull/160296 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
