[Lombok] Add implementation of plugin for FIR

This commit is contained in:
Dmitriy Novozhilov
2022-05-25 16:18:50 +03:00
committed by teamcity
parent e58e86932c
commit a84ece7233
41 changed files with 1685 additions and 42 deletions
+7 -2
View File
@@ -1,6 +1,10 @@
// FULL_JDK
// WITH_STDLIB
// FILE: DataExample.java
import lombok.*;
import java.util.List;
import java.util.Arrays;
@Data public class DataExample {
private final String name;
@@ -13,6 +17,7 @@ import lombok.*;
public static class Exercise<T> {
private final String name;
private final T value;
private final List<T> list;
}
public static void usage() {
@@ -21,7 +26,7 @@ import lombok.*;
obj.getTags();
obj.setScore(1.5);
Exercise<Integer> ex = Exercise.of("name", 12);
Exercise<Integer> ex = Exercise.of("name", 12, Arrays.asList(1, 2, 3));
}
}
@@ -38,6 +43,6 @@ fun box(): String {
obj.score = 2.5
assertEquals(obj.score, 2.5)
val ex: DataExample.Exercise<Int> = DataExample.Exercise.of("name", 12)
val ex: DataExample.Exercise<Int> = DataExample.Exercise.of("name", 12, listOf(1, 2, 3))
return "OK"
}
@@ -0,0 +1,27 @@
// KT-46529
// FILE: PrefixJava.java
import lombok.*;
import lombok.experimental.*;
@Getter @Setter @Accessors(chain = false, fluent = true, prefix = {"pxo"})
public class PrefixJava {
private String pxaPropA = "A";
@Accessors(chain = true) private String pxoPropC = "C";
@Accessors private String pxaPropD = "D";
}
// FILE: test.kt
fun test() {
//not generated because doesn't have prefix from class level @Accessors
assertEquals(<!ARGUMENT_TYPE_MISMATCH!>PrefixJava().<!UNRESOLVED_REFERENCE!>propA<!><!>, "A")
//not generated because doesn't have prefix from config
assertEquals(<!ARGUMENT_TYPE_MISMATCH!>PrefixJava().<!UNRESOLVED_REFERENCE!>propC<!><!>, "C")
assertEquals(PrefixJava().propD, "D")
}
// FILE: lombok.config
lombok.accessors.prefix += pxa
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// KT-46529
// FILE: PrefixJava.java
+53
View File
@@ -0,0 +1,53 @@
// FILE: GetterTest.java
import lombok.AccessLevel;
import lombok.Getter;
public class GetterTest {
@Getter private int age = 10;
@Getter(AccessLevel.PROTECTED) private String name;
@Getter private boolean primitiveBoolean;
@Getter private Boolean boxedBoolean;
@Getter(AccessLevel.NONE) private Boolean invisible;
void test() {
getAge();
isPrimitiveBoolean();
// getInvisible();
}
}
// FILE: test.kt
fun test() {
val obj = GetterTest()
val getter = obj.getAge()
val property = obj.age
//todo kotlin doesn't seee isBoolean methods as property
obj.<!INVISIBLE_REFERENCE!>primitiveBoolean<!>
obj.isPrimitiveBoolean()
obj.boxedBoolean
obj.getBoxedBoolean()
//shouldn't be accesible from here
obj.<!INVISIBLE_REFERENCE!>getName<!>()
obj.<!UNRESOLVED_REFERENCE!>getInvisible<!>()
OverridenGetterTest().usage()
}
class OverridenGetterTest : GetterTest() {
fun usage() {
getName()
}
}
-1
View File
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// FILE: GetterTest.java
import lombok.AccessLevel;
@@ -0,0 +1,46 @@
// FILE: ClassLevelGetterTest.java
import lombok.AccessLevel;
import lombok.Getter;
@Getter
public class ClassLevelGetterTest {
private int age = 10;
@Getter(AccessLevel.PROTECTED) private String name;
private boolean primitiveBoolean;
private Boolean boxedBoolean;
void test() {
getAge();
isPrimitiveBoolean();
}
}
// FILE: test.kt
fun test() {
val obj = ClassLevelGetterTest()
val getter = obj.getAge()
val property = obj.age
obj.isPrimitiveBoolean()
obj.boxedBoolean
obj.getBoxedBoolean()
//shouldn't be accesible from here
obj.<!INVISIBLE_REFERENCE!>getName<!>()
OverridenGetterTest().usage()
}
class OverridenGetterTest : ClassLevelGetterTest() {
fun usage() {
getName()
}
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// FILE: ClassLevelGetterTest.java
import lombok.AccessLevel;
+42
View File
@@ -0,0 +1,42 @@
// FILE: SetterTest.java
import lombok.AccessLevel;
import lombok.Setter;
import lombok.Getter;
public class SetterTest {
@Getter @Setter private int age = 10;
@Setter(AccessLevel.PROTECTED) private String name;
@Setter private boolean primitiveBoolean;
void test() {
setAge(12);
setPrimitiveBoolean(true);
}
}
// FILE: test.kt
fun test() {
val obj = SetterTest()
obj.setAge(42)
obj.age = 42
//synthetic property generated only when there is a getter
obj.<!INVISIBLE_REFERENCE!>primitiveBoolean<!> = false
obj.setPrimitiveBoolean(true)
//shouldn't be accesible from here
obj.<!INVISIBLE_REFERENCE!>setName<!>("abc")
OverridenGetterTest().usage()
}
class OverridenGetterTest : SetterTest() {
fun usage() {
setName("abc")
}
}
-1
View File
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// FILE: SetterTest.java
import lombok.AccessLevel;