diff --git a/doc/changelog.markdown b/doc/changelog.markdown index ab8ad2e9..7430a99d 100644 --- a/doc/changelog.markdown +++ b/doc/changelog.markdown @@ -1,10 +1,11 @@ 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). +* 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. 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 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/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) { 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; 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:

+

+ 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)">