From 16c52e8087654c76295dee02a4bed8ec5874e617 Mon Sep 17 00:00:00 2001 From: Michail Plushnikov Date: Sat, 13 Feb 2021 11:59:34 +0100 Subject: [PATCH] [lombok] Fixed ignoring @Tolerate methods for @With processing merged PR(#1001) and corresponding changes from github updated Readme.md GitOrigin-RevId: 69e65839eb6f83becc8a6d05a02b7350353b7a6b --- plugins/lombok/README.md | 147 +----------------- .../processor/field/WitherFieldProcessor.java | 1 + .../plugin/processor/TolerateTest.java | 12 +- .../after/{ => tolerate}/TolerateTest.java | 0 .../after/tolerate/WitherTolerateTest.java | 15 ++ .../before/{ => tolerate}/TolerateTest.java | 0 .../before/tolerate/WitherTolerateTest.java | 14 ++ 7 files changed, 44 insertions(+), 145 deletions(-) rename plugins/lombok/testData/after/{ => tolerate}/TolerateTest.java (100%) create mode 100644 plugins/lombok/testData/after/tolerate/WitherTolerateTest.java rename plugins/lombok/testData/before/{ => tolerate}/TolerateTest.java (100%) create mode 100644 plugins/lombok/testData/before/tolerate/WitherTolerateTest.java diff --git a/plugins/lombok/README.md b/plugins/lombok/README.md index 57365b63706e..bb79df986370 100644 --- a/plugins/lombok/README.md +++ b/plugins/lombok/README.md @@ -1,54 +1,10 @@ -lombok-intellij-plugin [![Donate](https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3F9HXD7A2SMCN) -====================== -[![Build Status][badge-travis-img]][badge-travis] [![Code Coverage](https://img.shields.io/codecov/c/github/mplushnikov/lombok-intellij-plugin/master.svg)](https://codecov.io/github/mplushnikov/lombok-intellij-plugin?branch=master) +## **Lombok IntelliJ Plugin** -[![JetBrains Plugins](https://img.shields.io/jetbrains/plugin/v/6317-lombok-plugin.svg)](https://plugins.jetbrains.com/plugin/6317-lombok-plugin) -[![Downloads](https://img.shields.io/jetbrains/plugin/d/6317-lombok-plugin.svg)](https://plugins.jetbrains.com/plugin/6317-lombok-plugin) -[![Downloads last month](http://phpstorm.espend.de/badge/6317/last-month)](https://plugins.jetbrains.com/plugin/6317-lombok-plugin) +Integrated into IntelliJ starting with 2020.3 Release -[![Gitter][badge-gitter-img]][badge-gitter] [![Donate][badge-paypal-img]][badge-paypal] +Originally developed on Github in https://github.com/mplushnikov/lombok-intellij-plugin, starting on Sun Sep 11 11:16:31 2011 - -## Plugin for [IntelliJ IDEA](http://plugins.jetbrains.com/plugin/6317-lombok-plugin) to support [Lombok](https://projectlombok.org) annotations. - -Provides support for lombok annotations to write great Java code with IntelliJ IDEA. - -**Last version (0.32) released on 25.09.2020** - ---- -:collision: **Unfortunately the current IntelliJ 2020.2 version has a bug and lombok plugin can't be used normally.** :collision: - -:hammer_and_wrench: Use previous IntelliJ version 2020.1 or update to IntelliJ IDEA 2020.2.1 or newer ---- - -:collision: **The latest IntelliJ IDEA versions still contains a BUG :beetle: for several plugins (including plugin for Lombok) were shown as incompatible with the updated version of the IDE.** :collision: - -You can find the issue with a detailed explanation here: https://youtrack.jetbrains.com/issue/IDEA-237113 and https://youtrack.jetbrains.com/issue/IDEA-246822 - -:hammer_and_wrench: As of now, the workaround is to re-install the plugin in the IDE settings. ---- - -36th version of plugin released. - -Install it automatically from IntelliJ Idea plugin repository. - -Tested and supports IntelliJ versions: 2017.X, 2018.X, 2019.X, 2020.1 and 2020.2.1+, 2020.3 EAP - -Last support for IntelliJ 2016.2 and 2016.3 by plugin version 0.31! - -Last support for IntelliJ 15.0.6 and 2016.1 by plugin version 0.19! - -Last support for IntelliJ 14.1.7 by plugin version 0.14! - -Last support for IntelliJ 11.1.5, 12.1.7, 13.1.6 by plugin version 0.11 - -Last support for IntelliJ 10.5.4 by plugin version 0.8.7 - -With this plugin your IntelliJ can recognize all of generated getters, setters and some other things from lombok project, so that you get code completion and are able to work without errors stating the methods don't exists. - - -Features / Supports --------- +### Features / Supports - [@Getter and @Setter](http://projectlombok.org/features/GetterSetter.html) - [@ToString](http://projectlombok.org/features/ToString.html) - [@EqualsAndHashCode](http://projectlombok.org/features/EqualsAndHashCode.html) @@ -64,6 +20,7 @@ Features / Supports - [@SneakyThrows](https://projectlombok.org/features/SneakyThrows.html) - [@val](https://projectlombok.org/features/val.html) available from IntelliJ 14.1 (improved in 2016.2) - [@UtilityClass](https://projectlombok.org/features/experimental/UtilityClass.html) available from IntelliJ 2016.2 +- [@ExtensionMethod](https://projectlombok.org/features/experimental/ExtensionMethod.html) experimental in IntelliJ 2019.2-2020.2, available from IntelliJ 2021 - [lombok config files syntax highlighting](https://projectlombok.org/features/configuration.html) - code inspections - refactoring actions (lombok and delombok) @@ -71,77 +28,7 @@ Features / Supports Many features of the plugin (including warnings) could be disabled through per-project settings. -Installation ------------- -### Plugin Installation -- Using IDE built-in plugin system on Windows: - - File > Settings > Plugins > Browse repositories... > Search for "lombok" > Install Plugin -- Using IDE built-in plugin system on MacOs: - - Preferences > Settings > Plugins > Browse repositories... > Search for "lombok" > Install Plugin -- Manually: - - Download the [latest release](https://github.com/mplushnikov/lombok-intellij-plugin/releases/latest) and install it manually using Preferences > Plugins > Install plugin from disk... - -Restart IDE. - -### Required IntelliJ Configuration -In your project: Click Preferences -> Build, Execution, Deployment -> Compiler, Annotation Processors. Click Enable Annotation Processing - -Afterwards you might need to do a complete rebuild of your project via Build -> Rebuild Project. - -### Lombok project dependency -Make sure you have Lombok dependency added to your project. This plugin **does not** automatically add it for you. - -**Please Note:** Using newest version of the Lombok dependency is recommended, but does not guarantee that all the features introduced will be available. See [Lombok changelog](https://projectlombok.org/changelog.html) for more details. - -If you are using Gradle/Maven/Ivy, see example below: - -##### Gradle -In your `build.gradle`: -```groovy -repositories { - mavenCentral() -} - -dependencies { - compileOnly 'org.projectlombok:lombok:1.18.12' - annotationProcessor 'org.projectlombok:lombok:1.18.12' - - testCompileOnly 'org.projectlombok:lombok:1.18.12' - testAnnotationProcessor 'org.projectlombok:lombok:1.18.12' -} -``` - -##### Maven -In your `pom.xml`: -```xml - - - org.projectlombok - lombok - 1.18.12 - provided - - -``` - -##### Ivy -In your `ivy.xml`: -```xml - -``` - -IntelliJ and Eclipse compiler ------------------------------ -If you're using Eclipse compiler with lombok, try this setup: -- install plugin -- make sure Lombok dependency is added to the project -- change compiler setting: - - ... > Compiler > Java Compiler > Use Compiler: Eclipse - - ... > Compiler > Annotation Processors > Enable annotation processing: checked (default configuration) - - ... > Compiler > Additional build process VM options: -javaagent:lombok.jar - -Developed By ------------- +### Developed by [**@mplushnikov** Michail Plushnikov](https://github.com/mplushnikov) **Contributors** @@ -151,6 +38,7 @@ Developed By - [**@AlexejK** Alexej Kubarev](https://github.com/AlexejK) - [**@bulgakovalexander** Alexander Bulgakov](https://github.com/bulgakovalexander) - [**@GingerGeek** Zed Spencer-Milnes](https://github.com/GingerGeek) +- [**@iProdigy** Sidd](https://github.com/iProdigy) - [**@jeromewaibel** Jérôme Waibel](https://github.com/jeromewaibel) - [**@Jessevanbekkum** Jesse van Bekkum](https://github.com/Jessevanbekkum) - [**@juriad** Adam Juraszek](https://github.com/juriad) @@ -175,24 +63,3 @@ Developed By - [**@wyhasany** Michał Rowicki](https://github.com/wyhasany) - [**@ocadaruma** Haruki Okada](https://github.com/ocadaruma) - [**@mackatozis** Alexandros Efthymiadis](https://github.com/mackatozis) - -Supporters --------- -[](https://www.yourkit.com/) - -YourKit supports open source projects with its full-featured Java Profiler. -YourKit, LLC is the creator of [YourKit Java Profiler](https://www.yourkit.com/java/profiler/index.jsp) and [YourKit .NET Profiler](https://www.yourkit.com/.net/profiler/index.jsp), innovative and intelligent tools for profiling Java and .NET applications. - - -License -------- -Copyright (c) 2011-2020 Michail Plushnikov. See the [LICENSE](./LICENSE) file for license rights and limitations (Apache 2.0). - -[badge-gitter-img]: https://badges.gitter.im/mplushnikov/lombok-intellij-plugin.svg -[badge-gitter]: https://gitter.im/mplushnikov/lombok-intellij-plugin -[badge-travis-img]: https://travis-ci.org/mplushnikov/lombok-intellij-plugin.svg -[badge-travis]: https://travis-ci.org/mplushnikov/lombok-intellij-plugin -[badge-coveralls-img]: https://coveralls.io/repos/github/mplushnikov/lombok-intellij-plugin/badge.svg?branch=master -[badge-coveralls]: https://coveralls.io/github/mplushnikov/lombok-intellij-plugin?branch=master -[badge-paypal-img]: https://img.shields.io/badge/donate-paypal-yellow.svg -[badge-paypal]: https://www.paypal.me/mplushnikov diff --git a/plugins/lombok/src/main/java/de/plushnikov/intellij/plugin/processor/field/WitherFieldProcessor.java b/plugins/lombok/src/main/java/de/plushnikov/intellij/plugin/processor/field/WitherFieldProcessor.java index 36b6ed238f1c..2cb946fefc11 100644 --- a/plugins/lombok/src/main/java/de/plushnikov/intellij/plugin/processor/field/WitherFieldProcessor.java +++ b/plugins/lombok/src/main/java/de/plushnikov/intellij/plugin/processor/field/WitherFieldProcessor.java @@ -99,6 +99,7 @@ public class WitherFieldProcessor extends AbstractFieldProcessor { final String psiFieldName = psiField.getName(); if (fieldContainingClass != null) { final Collection classMethods = PsiClassUtil.collectClassMethodsIntern(fieldContainingClass); + filterToleratedElements(classMethods); final AccessorsInfo accessorsInfo = buildAccessorsInfo(psiField); final Collection possibleWitherNames = LombokUtils.toAllWitherNames(accessorsInfo, psiFieldName, PsiType.BOOLEAN.equals(psiField.getType())); diff --git a/plugins/lombok/src/test/java/de/plushnikov/intellij/plugin/processor/TolerateTest.java b/plugins/lombok/src/test/java/de/plushnikov/intellij/plugin/processor/TolerateTest.java index a6c039283ad1..df0962fd7692 100644 --- a/plugins/lombok/src/test/java/de/plushnikov/intellij/plugin/processor/TolerateTest.java +++ b/plugins/lombok/src/test/java/de/plushnikov/intellij/plugin/processor/TolerateTest.java @@ -2,14 +2,16 @@ package de.plushnikov.intellij.plugin.processor; import de.plushnikov.intellij.plugin.AbstractLombokParsingTestCase; -import java.io.IOException; - /** * Unit tests for IntelliJPlugin for Lombok, based on lombok test classes */ public class TolerateTest extends AbstractLombokParsingTestCase { - public void testTolerateTest() throws IOException { - doTest(); + public void testTolerate$TolerateTest() { + doTest(true); } -} \ No newline at end of file + + public void testTolerate$WitherTolerateTest() { + doTest(true); + } +} diff --git a/plugins/lombok/testData/after/TolerateTest.java b/plugins/lombok/testData/after/tolerate/TolerateTest.java similarity index 100% rename from plugins/lombok/testData/after/TolerateTest.java rename to plugins/lombok/testData/after/tolerate/TolerateTest.java diff --git a/plugins/lombok/testData/after/tolerate/WitherTolerateTest.java b/plugins/lombok/testData/after/tolerate/WitherTolerateTest.java new file mode 100644 index 000000000000..61143be7d37b --- /dev/null +++ b/plugins/lombok/testData/after/tolerate/WitherTolerateTest.java @@ -0,0 +1,15 @@ +public class WitherTolerateTest { + private final Integer score; + + public WitherTolerateTest withScore(String score) { + return withScore(Integer.parseInt(score)); + } + + public WitherTolerateTest(Integer score) { + this.score = score; + } + + public WitherTolerateTest withScore(Integer score) { + return this.score == score ? this : new WitherTolerateTest(score); + } +} diff --git a/plugins/lombok/testData/before/TolerateTest.java b/plugins/lombok/testData/before/tolerate/TolerateTest.java similarity index 100% rename from plugins/lombok/testData/before/TolerateTest.java rename to plugins/lombok/testData/before/tolerate/TolerateTest.java diff --git a/plugins/lombok/testData/before/tolerate/WitherTolerateTest.java b/plugins/lombok/testData/before/tolerate/WitherTolerateTest.java new file mode 100644 index 000000000000..8c9bfea7513d --- /dev/null +++ b/plugins/lombok/testData/before/tolerate/WitherTolerateTest.java @@ -0,0 +1,14 @@ +import lombok.RequiredArgsConstructor; +import lombok.With; +import lombok.experimental.Tolerate; + +@RequiredArgsConstructor +public class WitherTolerateTest { + @With + private final Integer score; + + @Tolerate + public WitherTolerateTest withScore(String score) { + return withScore(Integer.parseInt(score)); + } +}