antkorwin / better-strings

Java String Interpolation Plugin
Apache License 2.0
98 stars 8 forks source link

Provide option for explicit toString calls in the generated interpolation code #14

Closed PawelLipski closed 4 years ago

PawelLipski commented 4 years ago

I found it pretty useful e.g. for static code analyzers to make sure that an explicit toString call is always present. E.g. in our project we'd like to forbid toString calls on certain classes (like Option(al)), since it's usually not intended (and in case of Option, it can result in a literal Some(...) being rendered in user-facing strings in the UI).

Plus also resolve a bug related to reported positions of compilation errors within interpolated strings & improve code style in a few places.

Depends on https://github.com/jupiter-tools/compile-test/pull/1

antkorwin commented 4 years ago

Hi @PawelLipski , thanks a lot for your work! it looks pretty useful!

I will find time to cover this by unit tests and fix build errors, unfortunately, now I'm very busy (a lot of work this week), maybe I can do it next week.

PawelLipski commented 4 years ago

Ok! let me know if you agree with the general design, I can also provide docs for this as well

codecov-commenter commented 4 years ago

Codecov Report

Merging #14 into master will increase coverage by 0.21%. The diff coverage is 96.42%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master      #14      +/-   ##
============================================
+ Coverage     91.89%   92.10%   +0.21%     
+ Complexity       54       52       -2     
============================================
  Files             6        6              
  Lines           148      152       +4     
  Branches         16       16              
============================================
+ Hits            136      140       +4     
  Misses            7        7              
  Partials          5        5              
Impacted Files Coverage Δ Complexity Δ
.../antkorwin/betterstrings/ast/ExpressionParser.java 92.50% <90.00%> (+1.32%) 3.00 <1.00> (ø)
...ntkorwin/betterstrings/BetterStringsProcessor.java 100.00% <100.00%> (ø) 10.00 <0.00> (-1.00)
...etterstrings/ast/InnerStringVarsAstTranslator.java 86.79% <100.00%> (+0.79%) 26.00 <1.00> (ø)
...a/com/antkorwin/betterstrings/tokenizer/Token.java 88.88% <100.00%> (-1.12%) 4.00 <1.00> (-1.00)
...m/antkorwin/betterstrings/tokenizer/Tokenizer.java 96.29% <100.00%> (-0.14%) 8.00 <2.00> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update d346269...8d41986. Read the comment docs.

PawelLipski commented 4 years ago

Also, I fixed the build (see the latest commit), apparently com.sun.tools.javac.api.JavacTaskImpl#parse is declared throwing or not throwing IOException depending on the exact environment (Java version? I develop on OpenJDK/JBR 11.0.6)

PawelLipski commented 4 years ago

@antkorwin added tests for the newly-added option; they depends on https://github.com/jupiter-tools/compile-test/pull/1 getting released as v0.2 first, however (that's why Travis isn't passing as for now)

PawelLipski commented 4 years ago

... and docs as well :) I'd appreciate your feedback since one of our projects would greatly benefit from this feature getting released

mkondratek commented 4 years ago

Hey @antkorwin :smile: how does the work go? when can we get it merged?

PawelLipski commented 4 years ago

@antkorwin long time no hear... how's going?

antkorwin commented 4 years ago

Hi, @PawelLipski I'm so sorry about long delay

It looks great! Thanks a lot for your patience!

antkorwin commented 4 years ago

I will check it today and deploy the next version to maven central...

@PawelLipski @mkondratek thanks a lot for your contribution!

antkorwin commented 4 years ago

the next release already published to the maven central https://github.com/antkorwin/better-strings/releases/tag/v0.4