-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cleanup to make use of text blocks leaves out many cases #1703
Comments
Looking at the examples, there are two situations:
|
So for long sections it would be possible to either have multiple text blocks or use something similar to printf on the resulting block to insert the particular append line. I agree this is no easy addition, maybe not worth it.
Yes, cool approach. I closed the PR that shows the use cases. I think it is still visible but not in the list of active prs. |
I don't think breaking up the text block is the answer. I don't know how but it might be worth contacting the language standard people to let then know about such a scenario and see if they could put in a line comment equivalent that would be ignored by the text block. The other way of doing this would be to subsume comments into the text block since in this case we are dealing with code sequences and adding a line comment within the string would be reasonable. Impossible to guess with a cleanup but perhaps could be done as a quick fix so the user could tell you manually they want that. For example:
gets converted to:
I alread7 have a patch for the indexOf support. I am on vacation but will push it up shortly. If the indexOf() call is in the middle of a bunch of appends it won't convert but it allows the indexOf to be before or after the toString()/implicit toString() call. |
- add new support to StringConcatToTextBlockFixCore to allow an indexOf call for StringBuilder/StringBuffer which can also work on a String once the conversion is complete (change the variable name of the indexOf call appropriately) - add new tests to StringConcatToTextBlockFixCore - for eclipse-jdt#1703
There are some more cases where the cleanup is failing. |
* Enhance StringBuilder to text block cleanup to support indexOf - add new support to StringConcatToTextBlockFixCore to allow an indexOf call for StringBuilder/StringBuffer which can also work on a String once the conversion is complete (change the variable name of the indexOf call appropriately) - add new tests to CleanUpTest15 and AssistQuickFixTest15 - for #1703
Hi @carstenartur It appears that adding the empty string at the end is causing the cleanup to bail (removal of empty strings as last concatenation makes it work). I will make a patch to fix this. |
- add logic to StringConcatToTextBlockFixCore to handle the case where empty strings are appended - modify tests in CleanUpTest15 to add some empty strings to existing tests - for eclipse-jdt#1703
Hi @carstenartur let me know if there are other scenarios. It would be preferable to open separate specific issues for them and close this one as it makes it easier for end-users to track if their problem is the same. |
Yes, of course. Let's close this one for being able to distinguish different use cases. There are more issues e.g. a case where the the formatting cleanup makes a sequence of text blocks indent each one a little bit more until the text blocks end up with hundreds of leading spaces. When I come to that point I can create another issue. |
Thanks @carstenartur. I am hoping to get your big explicit encoding feature into M2 this week. |
Many cases are not covered by the cleanup to make use of text blocks
Many more examples at
#1702
The text was updated successfully, but these errors were encountered: