From 8ed8234ac08ddbec9e587d58baf4ddb18c1a46e8 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Mon, 31 Mar 2025 13:51:35 +0200 Subject: [PATCH 1/5] [unused-code] We kept a ref to the `storeEnd` in PrettyPrinter but we never use it. --- .../lombok/delombok/PrettyPrinter.java | 24 +------------------ 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/src/delombok/lombok/delombok/PrettyPrinter.java b/src/delombok/lombok/delombok/PrettyPrinter.java index 85598d32..53ed4728 100644 --- a/src/delombok/lombok/delombok/PrettyPrinter.java +++ b/src/delombok/lombok/delombok/PrettyPrinter.java @@ -1599,39 +1599,17 @@ public class PrettyPrinter extends JCTree.Visitor { } } - private static final Method getExtendsClause, getEndPosition, storeEnd; + private static final Method getExtendsClause, getEndPosition; static { getExtendsClause = getMethod(JCClassDecl.class, "getExtendsClause", new Class[0]); if (getJavaCompilerVersion() < 8) { getEndPosition = getMethod(DiagnosticPosition.class, "getEndPosition", java.util.Map.class); - storeEnd = getMethod(java.util.Map.class, "put", Object.class, Object.class); } else { getEndPosition = getMethod(DiagnosticPosition.class, "getEndPosition", "com.sun.tools.javac.tree.EndPosTable"); - Method storeEndMethodTemp; - Class endPosTable; - try { - endPosTable = Class.forName("com.sun.tools.javac.tree.EndPosTable"); - } catch (ClassNotFoundException ex) { - throw sneakyThrow(ex); - } - try { - storeEndMethodTemp = Permit.getMethod(endPosTable, "storeEnd", JCTree.class, int.class); - } catch (NoSuchMethodException e) { - try { - endPosTable = Class.forName("com.sun.tools.javac.parser.JavacParser$AbstractEndPosTable"); - storeEndMethodTemp = Permit.getMethod(endPosTable, "storeEnd", JCTree.class, int.class); - } catch (NoSuchMethodException ex) { - throw sneakyThrow(ex); - } catch (ClassNotFoundException ex) { - throw sneakyThrow(ex); - } - } - storeEnd = storeEndMethodTemp; } Permit.setAccessible(getEndPosition); - Permit.setAccessible(storeEnd); } private static Method getMethod(Class clazz, String name, Class... paramTypes) { From b7896c5a74de2fa2c4467c21aea5469d6673f197 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Mon, 31 Mar 2025 13:52:33 +0200 Subject: [PATCH 2/5] [#3824] Our own 'Comment' ad hoc impl now also needs to provide an impl for `getPos()`. --- .../lombok/delombok/DocCommentIntegrator.java | 31 +++++++++++++++++++ .../com/sun/tools/javac/tree/EndPosTable.java | 5 +++ .../sun/tools/javac/util/JCDiagnostic.java | 0 src/utils/lombok/javac/Javac.java | 1 - 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 src/stubs/com/sun/tools/javac/tree/EndPosTable.java rename src/{stubs => stubsstubs}/com/sun/tools/javac/util/JCDiagnostic.java (100%) diff --git a/src/delombok/lombok/delombok/DocCommentIntegrator.java b/src/delombok/lombok/delombok/DocCommentIntegrator.java index 3464964e..491073c7 100644 --- a/src/delombok/lombok/delombok/DocCommentIntegrator.java +++ b/src/delombok/lombok/delombok/DocCommentIntegrator.java @@ -31,11 +31,13 @@ import java.util.regex.Pattern; import com.sun.tools.javac.parser.Tokens.Comment; import com.sun.tools.javac.tree.DocCommentTable; +import com.sun.tools.javac.tree.EndPosTable; import com.sun.tools.javac.tree.JCTree; import com.sun.tools.javac.tree.JCTree.JCClassDecl; import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; import com.sun.tools.javac.tree.JCTree.JCMethodDecl; import com.sun.tools.javac.tree.JCTree.JCVariableDecl; +import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; import com.sun.tools.javac.tree.TreeScanner; import lombok.javac.CommentInfo; @@ -132,6 +134,35 @@ public class DocCommentIntegrator { return docCommentContent_; } + @Override public DiagnosticPosition getPos() { + return new DiagnosticPosition() { + public JCTree getTree() { + return node; + } + + public int getStartPosition() { + return pos; + } + + public int getPreferredPosition() { + return pos; + } + + @SuppressWarnings("unused") // We compile against very old versions of javac intentionally (to support old stuff), but this is the method for newer impls. + public int getEndPosition(EndPosTable endPosTable) { + int end = endPosTable == null ? 0 : endPosTable.getEndPos(node); + if (end > pos) return end; + return pos + docCommentContent_.length(); + } + + public int getEndPosition(Map endPosTable) { + Integer end = endPosTable.get(node); + if (end != null && end.intValue() > pos) return end.intValue(); + return pos + docCommentContent_.length(); + } + }; + } + @Override public int getSourcePos(int index) { return pos + index; } diff --git a/src/stubs/com/sun/tools/javac/tree/EndPosTable.java b/src/stubs/com/sun/tools/javac/tree/EndPosTable.java new file mode 100644 index 00000000..b6e25220 --- /dev/null +++ b/src/stubs/com/sun/tools/javac/tree/EndPosTable.java @@ -0,0 +1,5 @@ +package com.sun.tools.javac.tree; + +public interface EndPosTable { + int getEndPos(JCTree tree); +} diff --git a/src/stubs/com/sun/tools/javac/util/JCDiagnostic.java b/src/stubsstubs/com/sun/tools/javac/util/JCDiagnostic.java similarity index 100% rename from src/stubs/com/sun/tools/javac/util/JCDiagnostic.java rename to src/stubsstubs/com/sun/tools/javac/util/JCDiagnostic.java diff --git a/src/utils/lombok/javac/Javac.java b/src/utils/lombok/javac/Javac.java index af19114d..22edcd05 100644 --- a/src/utils/lombok/javac/Javac.java +++ b/src/utils/lombok/javac/Javac.java @@ -55,7 +55,6 @@ import com.sun.tools.javac.tree.JCTree.JCIdent; import com.sun.tools.javac.tree.JCTree.JCImport; import com.sun.tools.javac.tree.JCTree.JCLiteral; import com.sun.tools.javac.tree.JCTree.JCVariableDecl; -import com.sun.tools.javac.tree.TreeInfo; import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; import lombok.core.ClassLiteral; From ed0965b5f938240ba13d8c58f4f3443477123fbe Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Mon, 31 Mar 2025 13:52:48 +0200 Subject: [PATCH 3/5] [docs] Cleaned up use of `

` in maven and edge html. --- website/templates/_download-edge.html | 26 +++++++++++++++----------- website/templates/setup/maven.html | 10 +++++++--- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/website/templates/_download-edge.html b/website/templates/_download-edge.html index 7b98d3b2..8df640c2 100644 --- a/website/templates/_download-edge.html +++ b/website/templates/_download-edge.html @@ -9,14 +9,19 @@ ${changelogEdge?no_esc}

Download edge release now!

-

+

You can use the edge release from maven using the projectlombok.org repository. - This requires:

    + This requires: +

    +
    • Adding the lombok maven repository to your repositories section
    • Adding lombok as a dependency to your project in the dependencies section, specifying version edge-SNAPSHOT.
    • Adding lombok as an annotation processor in the annotationProcessorPaths section, specifying version edge-SNAPSHOT.
    • -
    - These sections in your pom file should look like this:
    +			
+

+ These sections in your pom file should look like this: +

+
 <repositories>
 	<repository>
 		<id>projectlombok.org</id>
@@ -49,12 +54,12 @@
 			</configuration>
 		</plugin>
 	</plugins>
-</build>
-
-
-

+</build> +

- You can use the edge release from gradle using the projectlombok.org repository:

+				You can use the edge release from gradle using the projectlombok.org repository:
+			

+
 repositories {
 	mavenCentral()
 	maven { url 'https://projectlombok.org/edge-releases' }
@@ -69,11 +74,10 @@ dependencies {
 	
 	apt 'org.projectlombok:lombok:edge-SNAPSHOT'
 }
-

Cutting edge a bit too gutsy for you? You can grab the stable release instead.

- \ No newline at end of file + diff --git a/website/templates/setup/maven.html b/website/templates/setup/maven.html index 27153cb3..eebd745b 100644 --- a/website/templates/setup/maven.html +++ b/website/templates/setup/maven.html @@ -11,7 +11,9 @@ <@s.section title="Adding lombok to your pom file">

- To include lombok as a 'provided' dependency, add it to your <dependencies> block like so:

+			To include lombok as a 'provided' dependency, add it to your <dependencies> block like so:
+		

+
 <dependencies>
 	<dependency>
 		<groupId>org.projectlombok</groupId>
@@ -21,9 +23,10 @@
 	</dependency>
 </dependencies>
 
-

- You also need to add lombok as an annotation processor. This is mandatory starting with JDK23, or JDK9+ if compiling as modules (you have module-info.java files in your build):

+			You also need to add lombok as an annotation processor. This is mandatory starting with JDK23, or JDK9+ if compiling as modules (you have module-info.java files in your build):
+		

+
 <build>
 	<plugins>
 		<plugin>
@@ -41,6 +44,7 @@
 		</plugin>
 	</plugins>
 </build>
+
<@s.section title="Eclipse Compiler (ECJ/JDT)"> From ec886ae07b077196eceef9bf7176ea3453ddf1ee Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Mon, 31 Mar 2025 14:18:21 +0200 Subject: [PATCH 4/5] [changelog] Mention fixing of #3783 in changelog. --- doc/changelog.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/changelog.markdown b/doc/changelog.markdown index ab8ad2e9..5a0c437c 100644 --- a/doc/changelog.markdown +++ b/doc/changelog.markdown @@ -5,6 +5,7 @@ Lombok Changelog * PLATFORM: JDK24 support added. * FEATURE: Lombok's nullity annotation now supports [JSpecify](https://jspecify.dev) out of the box, using [config key](https://projectlombok.org/features/configuration) `jspecify`. * BUGFIX: Recent eclipse releases would get you 'negative length' error. The bug had always been in lombok but didn't matter until recent releases. [Issue #3823](https://github.com/projectlombok/lombok/issues/3823). +* BUGFIX: The 'extract local variable' refactor script of VSCode wouldn't replace all occurrences if run on a method call to a lombok generated method. [Issue #3783](https://github.com/projectlombok/lombok/issues/3783). ### v1.18.36 (November 15th, 2024) * PLATFORM: JDK23 support added. From 37b7e192c9e46ccafc26d6cab424c93cbcaf95d5 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Mon, 31 Mar 2025 14:19:44 +0200 Subject: [PATCH 5/5] [release] pre-release version bump for v1.18.38 --- doc/changelog.markdown | 2 +- src/core/lombok/core/Version.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/changelog.markdown b/doc/changelog.markdown index 5a0c437c..7430a99d 100644 --- a/doc/changelog.markdown +++ b/doc/changelog.markdown @@ -1,7 +1,7 @@ Lombok Changelog ---------------- -### v1.18.37 "Edgy Guinea Pig" +### v1.18.38 (March 31st, 2025) * PLATFORM: JDK24 support added. * FEATURE: Lombok's nullity annotation now supports [JSpecify](https://jspecify.dev) out of the box, using [config key](https://projectlombok.org/features/configuration) `jspecify`. * BUGFIX: Recent eclipse releases would get you 'negative length' error. The bug had always been in lombok but didn't matter until recent releases. [Issue #3823](https://github.com/projectlombok/lombok/issues/3823). diff --git a/src/core/lombok/core/Version.java b/src/core/lombok/core/Version.java index 789bbf5e..f0f321bd 100644 --- a/src/core/lombok/core/Version.java +++ b/src/core/lombok/core/Version.java @@ -30,9 +30,9 @@ public class Version { // ** CAREFUL ** - this class must always compile with 0 dependencies (it must not refer to any other sources or libraries). // Note: In 'X.Y.Z', if Z is odd, its a snapshot build built from the repository, so many different 0.10.3 versions can exist, for example. // Official builds always end in an even number. (Since 0.10.2). - private static final String VERSION = "1.18.37"; - private static final String RELEASE_NAME = "Edgy Guinea Pig"; -// private static final String RELEASE_NAME = "Envious Ferret"; + private static final String VERSION = "1.18.38"; +// private static final String RELEASE_NAME = "Edgy Guinea Pig"; + private static final String RELEASE_NAME = "Envious Ferret"; // Named version history: // Angry Butterfly