[lombok] Fix fallback to config for array annotation's parameter
If annotation's parameter is not explicitly defined, it should be taken from config #KT-46529 Fixed
This commit is contained in:
committed by
teamcityserver
parent
57d3f98ece
commit
468fc86a3f
+6
-5
@@ -26,11 +26,12 @@ fun AnnotationDescriptor.getStringArgument(argumentName: String): String? {
|
|||||||
return extractString(argument)
|
return extractString(argument)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun AnnotationDescriptor.getStringArrayArgument(argumentName: String): List<String>? {
|
fun AnnotationDescriptor.getStringArrayArgument(argumentName: String): List<String>? =
|
||||||
val argument = allValueArguments[Name.identifier(argumentName)] ?: return emptyList()
|
when (val argument = allValueArguments[Name.identifier(argumentName)]) {
|
||||||
if (argument !is ArrayValue) throw RuntimeException("Argument should be ArrayValue, got $argument")
|
null -> null
|
||||||
return argument.value.map(::extractString)
|
is ArrayValue -> argument.value.map(::extractString)
|
||||||
}
|
else -> throw RuntimeException("Argument should be ArrayValue, got $argument")
|
||||||
|
}
|
||||||
|
|
||||||
private fun extractString(argument: ConstantValue<*>) = when (argument) {
|
private fun extractString(argument: ConstantValue<*>) = when (argument) {
|
||||||
is EnumValue -> argument.enumEntryName.identifier
|
is EnumValue -> argument.enumEntryName.identifier
|
||||||
|
|||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
//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
|
||||||
|
|
||||||
|
class Test {
|
||||||
|
fun run() {
|
||||||
|
//not generated because doesn't have prefix from class level @Accessors
|
||||||
|
//assertEquals(PrefixJava().propA, "A")
|
||||||
|
//not generated because doesn't have prefix from config
|
||||||
|
//assertEquals(PrefixJava().propC, "C")
|
||||||
|
assertEquals(PrefixJava().propD, "D")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//FILE: lombok.config
|
||||||
|
lombok.accessors.prefix += pxa
|
||||||
+5
@@ -30,6 +30,11 @@ public class LombokCompileTestGenerated extends AbstractLombokCompileTest {
|
|||||||
runTest("plugins/lombok/lombok-compiler-plugin/testData/compile/accessorsStripPrefix.kt");
|
runTest("plugins/lombok/lombok-compiler-plugin/testData/compile/accessorsStripPrefix.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("accessorsStripPrefixCombined.kt")
|
||||||
|
public void testAccessorsStripPrefixCombined() throws Exception {
|
||||||
|
runTest("plugins/lombok/lombok-compiler-plugin/testData/compile/accessorsStripPrefixCombined.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("accessorsStripPrefixConfig.kt")
|
@TestMetadata("accessorsStripPrefixConfig.kt")
|
||||||
public void testAccessorsStripPrefixConfig() throws Exception {
|
public void testAccessorsStripPrefixConfig() throws Exception {
|
||||||
runTest("plugins/lombok/lombok-compiler-plugin/testData/compile/accessorsStripPrefixConfig.kt");
|
runTest("plugins/lombok/lombok-compiler-plugin/testData/compile/accessorsStripPrefixConfig.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user