[lombok] Check that nullability actually works
This commit is contained in:
committed by
TeamCityServer
parent
1fb4590978
commit
5a6819daa8
@@ -19,7 +19,7 @@ Features support:
|
||||
- [x] lombok.accessors.chain
|
||||
- [x] lombok.accessors.prefix
|
||||
- [ ] lombok.noArgsConstructor.extraPrivate (probably we don't need to support it - it is private after all)
|
||||
- [ ] lombok.copyableAnnotations
|
||||
- [ ] lombok.copyableAnnotations (probably don't need it)
|
||||
- [ ] Copy annotations
|
||||
- [x] Strip defined prefixes - in config and @Accessors
|
||||
- [x] Skip generation with AccessLevel.NONE
|
||||
@@ -49,8 +49,9 @@ Other todos:
|
||||
- [x] Actually run compiled code
|
||||
- [x] Don't generate members that already exist (if having a duplicate is a problem)
|
||||
- [x] Gradle integration (as subplugin or just a way to enable lombok support)
|
||||
- [ ] Gradle plugin integration test
|
||||
- [ ] Maven integration (as subplugin or just a way to enable lombok support)
|
||||
- [ ] Nullability from annotations. Check if it is inherited from variable definition
|
||||
- [x] Nullability from annotations. Check if it is inherited from variable definition
|
||||
|
||||
|
||||
|
||||
|
||||
+4
-3
@@ -64,17 +64,18 @@ class LombokSyntheticJavaPartsProvider(config: LombokConfig) : SyntheticJavaPart
|
||||
addNonExistent(result, constructors)
|
||||
}
|
||||
|
||||
//we process only local java files
|
||||
private fun extractClass(descriptor: ClassDescriptor): JavaClassImpl? =
|
||||
(descriptor as? LazyJavaClassDescriptor)?.jClass as? JavaClassImpl
|
||||
|
||||
private fun getSyntheticParts(descriptor: ClassDescriptor): SyntheticParts =
|
||||
extractClass(descriptor)?.let { jClass ->
|
||||
extractClass(descriptor)?.let { _ ->
|
||||
partsCache.getOrPut(descriptor) {
|
||||
computeSyntheticParts(descriptor, jClass)
|
||||
computeSyntheticParts(descriptor)
|
||||
}
|
||||
} ?: SyntheticParts.Empty
|
||||
|
||||
private fun computeSyntheticParts(descriptor: ClassDescriptor, jClass: JavaClassImpl): SyntheticParts =
|
||||
private fun computeSyntheticParts(descriptor: ClassDescriptor): SyntheticParts =
|
||||
processors.map { it.contribute(descriptor) }.reduce { a, b -> a + b }
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
//FILE: GetterSetterExample.java
|
||||
|
||||
import lombok.*;
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
@Getter @Setter
|
||||
public class GetterSetterExample {
|
||||
@NotNull
|
||||
private Integer age = 10;
|
||||
@Nullable
|
||||
private String name;
|
||||
}
|
||||
|
||||
|
||||
//FILE: test.kt
|
||||
|
||||
class Test {
|
||||
fun run() {
|
||||
val obj = GetterSetterExample()
|
||||
val age: Int = obj.getAge()
|
||||
val name: String? = obj.getName()
|
||||
}
|
||||
}
|
||||
+5
@@ -114,6 +114,11 @@ public class LombokCompileTestGenerated extends AbstractLombokCompileTest {
|
||||
runTest("plugins/lombok/lombok-compiler-plugin/testData/compile/noArgsConstructorStatic.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullability.kt")
|
||||
public void testNullability() throws Exception {
|
||||
runTest("plugins/lombok/lombok-compiler-plugin/testData/compile/nullability.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("requiredArgsConstructor.kt")
|
||||
public void testRequiredArgsConstructor() throws Exception {
|
||||
runTest("plugins/lombok/lombok-compiler-plugin/testData/compile/requiredArgsConstructor.kt");
|
||||
|
||||
Reference in New Issue
Block a user