_Original issue created by [email protected] on 2013-12-19 at 07:40 PM_
Tasks:
Hmm, is there any plan yet to open source the source code escapers? If not, we may want to consider closing this issue, because at this rate it looks like it's never going to happen. :)
@cushon has done so in GoogleJavaFormat (or ErrorProne, I don't remember?) but package-private. I think it's a question of API and not feasibility.
I wonder if we'd be willing to release it in a separate, small standalone library. It seems niche enough that maybe we could do that as we experiment with the API? But perhaps it needs some package-private details that would make that challenging.
GoogleJavaFormat (or ErrorProne, I don't remember?)
@cpovirk has a good sense of the API questions that would need to be answered. These are the copies I know of:
Here's a slightly edited version of what I wrote internally just recently:
Do we really want to continue to have a single javaCharEscaper() / javaStringEscaper() that escapes both " and ' characters, or should we instead rename the existing method to javaCharOrStringEscaper(), migrate everyone to that, and then introduce separate javaCharEscaper() and javaStringEscaper() methods for those use specific cases? Users might be annoyed if we insert \' into their strings unnecessarily?
It's also not 100% clear that users want non-ASCII characters escaped in all cases. But we need to be careful about exotic line breaks and perhaps about easily confused characters.
If we do keep one escaper, is javaCharEscaper() the right name for it when probably most users will be escaping for strings?
(Of course we continue to recommend that most people use higher-level APIs. But someone has to write the low-level APIs that those people use :))
I don't imagine we'll do this unless someone comes along internally who is willing to survey the existing internal callers and see what features they actually want.
Just so I'm clear on this, if Google decides to keep javaCharEscaper() and open sources it, and/or does the same for javaStringEscaper(), would those escapers just escape ' into \' and " into \" respectively? Or would they affect other characters as well in some way?
And would you mind clarifying for me which APIs you're referring to when you say "higher-level APIs" and "low-level APIs"?
The escapers would escape other characters, too, like \n and control characters. We'd have to figure out exact details.
We encourage people to use tools like JavaPoet rather than manually escape strings.
Ah okay, understood and understood. :)
any update on opensourcing the source code escapers? We use it in an internal project that we are going to opensource
Sadly no. Cloning them to other projects remains sad but fairly easy and harmless (since they're static methods).