Added support for lombok.fieldDefaults.default* in lombok.config#571
Conversation
… + adapted AbstractLombokConfigSystemTestCase accordingly
…le lombok.fieldDefaults.* in lombok.config
|
Sorry, I should've run all the tests after introducing my changes. Apparently, my PR breaks something in |
…htCodeInsightTestCase
|
OK, for some strange reason, The problem was not in However, when I changed @mplushnikov, @alexejk: Are you aware, if |
Codecov Report
@@ Coverage Diff @@
## master #571 +/- ##
===========================================
+ Coverage 64.38% 64.5% +0.11%
- Complexity 1488 1505 +17
===========================================
Files 178 178
Lines 5298 5310 +12
Branches 1182 1185 +3
===========================================
+ Hits 3411 3425 +14
+ Misses 1380 1378 -2
Partials 507 507
Continue to review full report at Codecov.
|
|
@tlinkowski Thank you very much for your help! I'll look on your PR on weekend. |
|
Great PR, very well documentated! Thank you very much! Make more of this:)
As I know this is mostly problem in the tests only. Using AbstractLombokLightCodeInsightTestCase is absolutly right, because it setups all of lombok classes (and jdk mock) for the test run. Without this setup Intellij can't not find any of classes used i the test and a lot of "resolve" operations fails. Thank you for fixing this in the test too! Did you tried your build in some big projects? I will merge this now, but I am a little bit afraid of some possible performance degradation, because this code will be running now for every field in every class and searching for lombok configuration information again and again. It could be vissible degradation on big classes with a lot of fields for example. ConfigDiscovery operates on an index and should be fast, but I got already a lot of performance issues for the plugin and comment like this: #516 (comment) are not really reassuring... |
|
Thank you, Michail, for your kind words 😃 As to performance issues: no, I have not tried this build at all. Actually, I have not even considered the consequences with respect to performance - you made an excellent observation! Update: I have built the plugin (IJ 2018.3.2), and tested it on a fairly large project. When I opened a file with 10+ non-static fields, I think I have experienced some minor slowdown while loading the file (but I can't be sure). I took a quick look at As far as I understand, the current index (let's call it index A) stores the contents of
The index I have in mind (let's call it index B) would use index A to determine the effective values of lombok configuration keys for any given directory (not necessarily containing a
In other words, I would like to move the logic of But I really don't know if such things are possible within the IntelliJ API so this proposal might be nonsense. And such an approach would pose challenges (e.g. when given Note that since this index would need to contain all the affected directories in the project, it'd be much bigger than index A (but I can't tell if this could be a problem). |
|
Just some feedback: I've been running IntelliJ 2018.3 with a custom-built 0.24 lombok-intellij-plugin (which included this PR) for almost 3 months now (large project at work). Conclusion: I haven't experienced any problems nor inconveniences (especially no slowdowns that would be noticeable). |
This fixes #353 and #456.
This PR consists of four commits:
Extracted configsystem tests to "before" directories + adapted
AbstractLombokConfigSystemTestCaseaccordingly (d6bd9e2, TDD: refactor)This changes the layout of "testData/configsystem" directory from:
configSystem ... value.extraPrivate after ValueTest.java ValueTest.java lombok.config ...to
configSystem ... value.extraPrivate before ValueTest.java lombok.config after ValueTest.java ...This change was necessary for this fix because - in the original layout -
lombok.configwas affecting the files in the "after" directory too. Until now, it wasn't a problem because nearly alllombok.configflags affect only classes that contain certain Lombok annotations. However,lombok.fieldDefaults.default*flags affect every file.If you checkout this commit, you can verify that all tests still pass.
Introduced configsystem/
FieldDefaultsTests(ede994e, TDD: red)Added all the tests for

lombok.fieldDefaults.default*. The results of calling the tests at this stage are as follows:Explanation:
*WithFieldDefaultsTestpass because they test if putting@FieldDefaults(makeFinal = true)annotation overridesdefaultFinalinlombok.configDefautFinalFieldWithUnrelatedFieldDefaultsTestpass because putting@FieldDefaults(level = ...)contains an implicitmakeFinal = falsewhich overridesdefaultFinalinlombok.configIf you checkout this commit, you can verify that the results of the tests are as above.
Adapted
FieldDefaultsModifierProcessor(e6db3ae, TDD: green)Please note that I replaced
PsiAnnotationUtil.getAnnotationValues(fieldDefaultsAnnotation, "level", String.class)withPsiAnnotationUtil.getStringAnnotationValue(fieldDefaultsAnnotation, "level")(it seemed safe because only one value can be present there, but I'm not 100% sure it is).If you checkout this commit, you can verify that all the tests in
FieldDefaultsTestsnow pass.Refactorings in FieldDefaultsModifierProcessor and AbstractLombokParsingTestCase (f3ac2ef, TDD: refactor)
This is optional but:
FieldDefaultsModifierProcessormake it more readableAbstractLombokParsingTestCasechanges the parent type incompareModifiersfromPsiMethodtoPsiElement- without this change, the tests do not display the name of the field for which the modifiers are differentIf you checkout this commit, you can verify that all the tests still pass.
I hope you'll find this PR useful 🙂 If there were anything that needed improvement, feel free to let me know.