AdvancedExpressionFolding icon indicating copy to clipboard operation
AdvancedExpressionFolding copied to clipboard

Fold String.format to interpolated strings.

Open vektory79 opened this issue 8 years ago • 2 comments

At present time plugin fold to interpolated strings only the string concatenations. It's will be impress to fold String.format too.

For example this:

return String.format("Start in %d days", days);

to this:

return "Start in $days days";

vektory79 avatar Mar 31 '17 15:03 vektory79

Didn't realize this wasn't available yet. String.format would definitely be a nice addition; however, there is a popular Android logging library called Timber that is a fusion between Logcat and String.format. If you support String.format, it seems that support of Timber would be plausible.

However, this might bring up the question of if there should be an AdvancedAndroidFolding library that would work together as this is specific to Android code and not necessarily Java.

https://github.com/JakeWharton/timber

Original Timber code example: Timber.i("A button with ID %s was clicked to say %s.", button.getId(), button.getText());

Could be shortened to... Timber.i("A button with ID ${button.id} was clicked to say ${button.text}.");

ciscorucinski avatar Mar 31 '17 18:03 ciscorucinski

Some Java (as in 'non-Android') logging frameworks also support "format pattern" feature. For example, in SLF4J: logger.error("one two three: {} {} {}", "a", "b", "c", new Exception("something went wrong")); So folding support for logging would be useful for "plain Java" code too.

sabi0 avatar Jan 19 '18 14:01 sabi0