Skip to content

Commit

Permalink
Merge branch 'projectlombok:master' into feature/builder-setterPrefix…
Browse files Browse the repository at this point in the history
…-configuration
  • Loading branch information
sadv1r authored Nov 23, 2021
2 parents c5f39ec + d3b763f commit ae998c9
Show file tree
Hide file tree
Showing 196 changed files with 2,599 additions and 268 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Takuya Murakami <[email protected]>
Thomas Darimont <[email protected]>
Till Brychcy <[email protected]>
Victor Williams Stafusa da Silva <[email protected]>
Yonatan Sherwin <[email protected]>
Yun Zhi Lin <[email protected]>

By adding your name to this list, you grant full and irrevocable copyright and patent indemnity to Project Lombok and all use of Project Lombok in relation to all commits you add to Project Lombok, and you certify that you have the right to do so.
16 changes: 13 additions & 3 deletions buildScripts/tests.ant.xml
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,18 @@ This buildfile is part of projectlombok.org. It takes care of compiling and runn

<macrodef name="test.eclipse-X">
<attribute name="version" />
<attribute name="compiler.compliance.level" default="latest" />
<sequential>
<echo>Running TestEclipse on eclipse-@{version} on JVM${ant.java.version}.</echo>
<condition property="compiler.compliance.level" value="-Dcompiler.compliance.level=@{compiler.compliance.level}" else="-Dnot=set">
<not><equals arg1="@{compiler.compliance.level}" arg2="latest" /></not>
</condition>
<echo>Running TestEclipse on eclipse-@{version} on JVM${ant.java.version} using. Compiler compliance level: @{compiler.compliance.level}</echo>
<junit haltonfailure="yes" fork="true" forkmode="once">
<formatter classname="lombok.ant.SimpleTestFormatter" usefile="false" unless="tests.quiet" />
<jvmarg value="-Xbootclasspath/a:${jdk8-rt.loc}" />
<jvmarg value="-Ddelombok.bootclasspath=${jdk8-rt.loc}" />
<jvmarg value="-javaagent:dist/lombok.jar" />
<jvmarg value="${compiler.compliance.level}" />
<classpath location="build/ant" />
<classpath refid="cp.test" />
<classpath refid="cp.stripe" />
Expand All @@ -175,11 +180,16 @@ This buildfile is part of projectlombok.org. It takes care of compiling and runn
<test.eclipse-X version="oxygen" />
</target>

<target name="test.eclipse-202006" depends="test.formatter.compile, test.compile" description="runs the tests on your default VM, testing the 2020-03 release of eclipse">
<target name="test.eclipse-202006" depends="test.formatter.compile, test.compile" description="runs the tests on your default VM, testing the 2020-06 release of eclipse">
<fetchdep.eclipse version="202006" />
<test.eclipse-X version="202006" />
</target>

<target name="test.eclipse-202006-jdk8" depends="test.formatter.compile, test.compile" description="runs the tests on your default VM, testing the 2020-06 release of eclipse with compiler compliance level 8">
<fetchdep.eclipse version="202006" />
<test.eclipse-X version="202006" compiler.compliance.level="8" />
</target>

<macrodef name="test.ecj-X">
<attribute name="version" />
<sequential>
Expand Down Expand Up @@ -217,5 +227,5 @@ This buildfile is part of projectlombok.org. It takes care of compiling and runn
</target>

<target name="test" depends="test.javacCurrent, test.eclipse-202006" description="runs the tests against the default JVM, javac, and eclipse" />
<target name="test.broad" depends="test.javac8, test.javac14, test.eclipse-oxygen, test.eclipse-202006" description="runs the tests against the default JVM, javac, and eclipse" />
<target name="test.broad" depends="test.javac8, test.javac14, test.eclipse-oxygen, test.eclipse-202006, test.eclipse-202006-jdk8" description="runs the tests against the default JVM, javac, and eclipse" />
</project>
13 changes: 11 additions & 2 deletions doc/changelog.markdown
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
Lombok Changelog
----------------

### v1.18.21 "Edgy Guinea Pig"
* Added the `@StandardException` feature. [Pull Request #2702](https://github.com/projectlombok/lombok/pull/2702).
### v1.18.24 "Edgy Guinea Pig"
* FEATURE: Turning a field named `uShape` into a getter is tricky: `getUShape` or `getuShape`? The community is split on which style to use. Lombok does `getUShape`, but if you prefer the `getuShape` style, add to `lombok.config`: `lombok.accessors.capitalization = beanspec`. [Issue #2693](https://github.com/projectlombok/lombok/issues/2693) [Pull Request #2996](https://github.com/projectlombok/lombok/pull/2996). Thanks __@YonathanSherwin__!
* BUGFIX: Various save actions and refactor scripts in eclipse work better. [Issue #2995](https://github.com/projectlombok/lombok/issues/2995) [Issue #1309](https://github.com/projectlombok/lombok/issues/1309) [Issue #2985](https://github.com/projectlombok/lombok/issues/2985) [Issue #2509](https://github.com/projectlombok/lombok/issues/2509)

### v1.18.22 (October 6th, 2021)
* PLATFORM: JDK17 support added. [Issue #2898](https://github.com/projectlombok/lombok/issues/2898).
* FEATURE: Added the `@StandardException` feature. [Pull Request #2702](https://github.com/projectlombok/lombok/pull/2702).
* IMPROBABLE BREAKING CHANGE: If the underlying compiler and `--release` / `--source` option is 10 or higher, lombok's `val` is now replaced by `final var`. That means compound declarations such as `val x = 10, y = 12;` now fail (lombok's old `val` implementation supported it, javac's `var` does not), but IDE support in particular is more reliable. We decided it was worth the tradeoff.
* BUGFIX: Syntax highlighting in VSCode now works reliably when using lombok. [Issue #2950](https://github.com/projectlombok/lombok/issues/2950).
* BUGFIX: Eclipse's _organize imports_ feature would sometimes remove your `lombok.val` import. [Issue #2972](https://github.com/projectlombok/lombok/issues/2972).


### v1.18.20 (April 2nd, 2021)
* PLATFORM: JDK16 support added. [Issue #2681](https://github.com/projectlombok/lombok/issues/2681).
Expand Down
22 changes: 22 additions & 0 deletions doc/debug-insights/eclipse.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# How to debug lombok running in eclipse

## Overview

Lombok's build scripting can generate a target for you, that lets you run the same eclipse installation inside eclipse, in debug mode. Now you can add breakpoints.

As lombok is an agent, lombok __must__ load from a jar file.
Nevertheless, lombok can be hot-code-replaced in the debugger.
This works via the loader: The lombok agent has its own classloading architecture, and this architecture is capable of loading lombok's class files from a location of your choosing. Choose the /bin dir from your eclipse project which will help with debugging; eclipse will then be able to apply HCR to the eclipse-running-in-eclipse. Unless there are issues with the loader architecture itself, of course.

The end goal is that you can make some changes to the lombok sources in your eclipse, then click the 'debug' button, and a new 'test eclipse' starts up using lombok as you wrote it just now. You can now make changes to lombok sources in the original eclipse, hit 'save', and these changes now get automatically applied to the 'test eclipse', as long as you aren't making any changes to signatures (add or remove methods/fields/types, or change return types, param types, etc).

If you have the sources to eclipse itself, you can open them, set breakpoints, and step through, though be aware that lombok's agent injection system does cause some issues here; we move methods into different classes and eclipse's debugger naturally doesn't understand this, so you can't breakpoint lombok's own patch methods, and stepping through them 'works' but looks bizarre in the debugger as the debugger now thinks your source file clearly cannot possibly match the class file currently running. Just keep going ('step out'), eclipse will figure it out again once you're back in un-instrumented eclipse code.


TODO:

Describe in detail:

* Which ant tasks to run to create the targets
* How to modify this target, if needed, to point at your bin dir

7 changes: 7 additions & 0 deletions doc/debug-insights/vscode.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
As per @Rawi01's experimenting:

* VSCode's lombok plugin simply adds the appropriate `-javaagent` options when it fires up the eclipse-based language server. You can also add debug flags here.
* Add the flags `-agentlib:jdwp-transport=dt_socket,server=y,suspend=n,quiet=y,address=12345` to the `settings.json` of the VSCode lombok plugin, and then tell your debugger to attach to localhost:12345.
* Set the property `java.server.launchMode` to `"Standard"`.
* Consider activing the language server debug mode.

12 changes: 11 additions & 1 deletion src/core/lombok/ConfigurationKeys.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2013-2020 The Project Lombok Authors.
* Copyright (C) 2013-2021 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -24,6 +24,7 @@
import java.util.List;

import lombok.core.configuration.CallSuperType;
import lombok.core.configuration.CapitalizationStrategy;
import lombok.core.configuration.CheckerFrameworkVersion;
import lombok.core.configuration.ConfigurationKey;
import lombok.core.configuration.FlagUsageType;
Expand Down Expand Up @@ -565,6 +566,15 @@ private ConfigurationKeys() {}
*/
public static final ConfigurationKey<Boolean> ACCESSORS_FLUENT = new ConfigurationKey<Boolean>("lombok.accessors.fluent", "Generate getters and setters using only the field name (no get/set prefix) (default: false).") {};

/**
* lombok configuration: {@code lombok.accessors.capitalization} = {@code basic} | {@code beanspec}.
*
* Which capitalization rule is used to turn field names into getter/setter/with names and vice versa for field names that start with 1 lowercase letter, then 1 uppercase letter.
* basic = {@code uShape} becomes {@code getUShape}, beanspec = {@code uShape} becomes {@code getuShape} (default = basic).
*/
public static final ConfigurationKey<CapitalizationStrategy> ACCESSORS_JAVA_BEANS_SPEC_CAPITALIZATION = new ConfigurationKey<CapitalizationStrategy>("lombok.accessors.capitalization", "Which capitalization strategy to use when converting field names to accessor names and vice versa (default: basic).") {};


// ----- ExtensionMethod -----

/**
Expand Down
18 changes: 17 additions & 1 deletion src/core/lombok/core/AST.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2009-2019 The Project Lombok Authors.
* Copyright (C) 2009-2021 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -430,6 +430,9 @@ private void buildWithCollection(Class<L> nodeType, Object collection, Collectio
}
}

/**
* @return The {@code lombok.config} configuration value for the provided {@code key}, or {@code null} if that key is not in the config / there is no config.
*/
public final <T> T readConfiguration(ConfigurationKey<T> key) {
long start = configTracker == null ? 0L : configTracker.start();
try {
Expand All @@ -438,4 +441,17 @@ public final <T> T readConfiguration(ConfigurationKey<T> key) {
if (configTracker != null) configTracker.end(start);
}
}

/**
* @return The {@code lombok.config} configuration value for the provided {@code key}, or {@code defaultValue} if that key is not in the config / there is no config.
*/
public final <T> T readConfigurationOr(ConfigurationKey<T> key, T defaultValue) {
long start = configTracker == null ? 0L : configTracker.start();
try {
T value = LombokConfiguration.read(key, this);
return value != null ? value : defaultValue;
} finally {
if (configTracker != null) configTracker.end(start);
}
}
}
2 changes: 1 addition & 1 deletion src/core/lombok/core/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ 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.21";
private static final String VERSION = "1.18.23";
private static final String RELEASE_NAME = "Edgy Guinea Pig";
// private static final String RELEASE_NAME = "Envious Ferret";

Expand Down
52 changes: 52 additions & 0 deletions src/core/lombok/core/configuration/CapitalizationStrategy.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright (C) 2021 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package lombok.core.configuration;

/** Used for lombok configuration to determine how to transform field names when turning them into accessor method names and vice versa. */
public enum CapitalizationStrategy {
BASIC {
@Override public String capitalize(String in) {
if (in.length() == 0) return in;
char first = in.charAt(0);
if (!Character.isLowerCase(first)) return in;
boolean useUpperCase = in.length() > 2 &&
(Character.isTitleCase(in.charAt(1)) || Character.isUpperCase(in.charAt(1)));
return (useUpperCase ? Character.toUpperCase(first) : Character.toTitleCase(first)) + in.substring(1);
}
},
BEANSPEC {
@Override public String capitalize(String in) {
if (in.length() == 0) return in;
char first = in.charAt(0);
if (!Character.isLowerCase(first) || (in.length() > 1 && Character.isUpperCase(in.charAt(1)))) return in;
boolean useUpperCase = in.length() > 2 && Character.isTitleCase(in.charAt(1));
return (useUpperCase ? Character.toUpperCase(first) : Character.toTitleCase(first)) + in.substring(1);
}
},
;

public static CapitalizationStrategy defaultValue() {
return BASIC;
}

public abstract String capitalize(String in);
}
4 changes: 2 additions & 2 deletions src/core/lombok/core/configuration/FlagUsageType.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2014 The Project Lombok Authors.
* Copyright (C) 2014-2021 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -21,7 +21,7 @@
*/
package lombok.core.configuration;

/** Used for lombok configuration to flag usages of certain lombok feature. */
/** Used for lombok configuration to flag usages of certain lombok features. */
public enum FlagUsageType {
WARNING, ERROR, ALLOW;
}
Loading

0 comments on commit ae998c9

Please sign in to comment.