Cleanup: fix some compiler warnings (mostly deprecations, javaClass)
This commit is contained in:
+1
-1
@@ -108,7 +108,7 @@ abstract class AbstractProcessorTest : AbstractBytecodeTextTest() {
|
||||
protected fun testShouldNotRun(
|
||||
name: String,
|
||||
vararg supportedAnnotations: String
|
||||
) = testAP(false, name, { set, roundEnv, env -> fail("Should not run") }, *supportedAnnotations)
|
||||
) = testAP(false, name, { _, _, _ -> fail("Should not run") }, *supportedAnnotations)
|
||||
|
||||
protected fun testAP(
|
||||
shouldRun: Boolean,
|
||||
|
||||
+8
-8
@@ -25,7 +25,7 @@ import javax.lang.model.element.TypeElement
|
||||
class ElementsTests : AbstractProcessorTest() {
|
||||
override val testDataDir = "plugins/annotation-processing/testData/elements"
|
||||
|
||||
fun testOverrides() = test("Overrides", "*") { set, roundEnv, env ->
|
||||
fun testOverrides() = test("Overrides", "*") { _, _, env ->
|
||||
val (parent, child, childChild) = Triple(env.findClass("Parent"), env.findClass("Child"), env.findClass("ChildOfChild"))
|
||||
|
||||
val parentA = parent.findMethod("a")
|
||||
@@ -52,7 +52,7 @@ class ElementsTests : AbstractProcessorTest() {
|
||||
childChildACharSequence.assertOverrides(childA, false)
|
||||
}
|
||||
|
||||
fun testOverrides2() = test("Overrides2", "*") { set, roundEnv, env ->
|
||||
fun testOverrides2() = test("Overrides2", "*") { _, _, env ->
|
||||
val classes = listOf(env.findClass("Intf"), env.findClass("A"), env.findClass("B"))
|
||||
val (intf, a, b) = classes.map { it.findMethod("a") }
|
||||
|
||||
@@ -66,7 +66,7 @@ class ElementsTests : AbstractProcessorTest() {
|
||||
a.assertOverrides(intf, classes[2], true)
|
||||
}
|
||||
|
||||
fun testIsFunctionalInterface() = test("IsFunctionalInterface", "*") { set, roundEnv, env ->
|
||||
fun testIsFunctionalInterface() = test("IsFunctionalInterface", "*") { _, _, env ->
|
||||
with (env.elementUtils as KotlinElements) {
|
||||
fun assertIsFunctionalInterface(fqName: String, isIntf: Boolean) {
|
||||
assertEquals(isIntf, isFunctionalInterface(env.findClass(fqName)))
|
||||
@@ -82,7 +82,7 @@ class ElementsTests : AbstractProcessorTest() {
|
||||
}
|
||||
}
|
||||
|
||||
fun testIsDeprecated() = test("IsDeprecated", "*") { set, roundEnv, env ->
|
||||
fun testIsDeprecated() = test("IsDeprecated", "*") { _, _, env ->
|
||||
with (env.elementUtils) {
|
||||
assertEquals(true, isDeprecated(env.findClass("Depr")))
|
||||
assertEquals(false, isDeprecated(env.findClass("NoDepr")))
|
||||
@@ -90,7 +90,7 @@ class ElementsTests : AbstractProcessorTest() {
|
||||
}
|
||||
}
|
||||
|
||||
fun testGetElementValuesWithDefaults() = test("GetElementValuesWithDefaults", "Anno") { set, roundEnv, env ->
|
||||
fun testGetElementValuesWithDefaults() = test("GetElementValuesWithDefaults", "Anno") { _, _, env ->
|
||||
val (a, b, c, d) = listOf(env.findClass("A"), env.findClass("B"), env.findClass("C"), env.findClass("D"))
|
||||
fun getValues(e: JeTypeElement) = env.elementUtils
|
||||
.getElementValuesWithDefaults(e.annotationMirrors.first { it.psi.qualifiedName == "Anno" })
|
||||
@@ -102,7 +102,7 @@ class ElementsTests : AbstractProcessorTest() {
|
||||
assertEquals(listOf("Mary", 20), getValues(d))
|
||||
}
|
||||
|
||||
fun testGetAllMembers() = test("GetAllMembers", "*") { set, roundEnv, env ->
|
||||
fun testGetAllMembers() = test("GetAllMembers", "*") { _, _, env ->
|
||||
val clazz = env.findClass("MyClass")
|
||||
val members = clazz.enclosedElements
|
||||
assertEquals(5, members.size) // constructor, field, getter/setter, arbitrary method
|
||||
@@ -114,7 +114,7 @@ class ElementsTests : AbstractProcessorTest() {
|
||||
allMembers.sortedBy { it.simpleName.toString() }.joinToString { it.simpleName })
|
||||
}
|
||||
|
||||
fun testGetPackageOf() = test("GetPackageOf", "*") { set, roundEnv, env ->
|
||||
fun testGetPackageOf() = test("GetPackageOf", "*") { _, _, env ->
|
||||
val e = env.elementUtils
|
||||
|
||||
val myClass = env.findClass("test.MyClass")
|
||||
@@ -130,7 +130,7 @@ class ElementsTests : AbstractProcessorTest() {
|
||||
assertEquals(3, classes.size)
|
||||
}
|
||||
|
||||
fun testGetArrayType() = test("GetPackageOf", "*") { set, roundEnv, env ->
|
||||
fun testGetArrayType() = test("GetPackageOf", "*") { _, _, env ->
|
||||
val myClass = env.findClass("test.MyClass").asType()
|
||||
val array = env.typeUtils.getArrayType(myClass)
|
||||
assert(array is JeArrayType)
|
||||
|
||||
+22
-22
@@ -38,7 +38,7 @@ annotation class ColorsAnnotation(val colors: Array<RGBColors>)
|
||||
class ProcessorTests : AbstractProcessorTest() {
|
||||
override val testDataDir = "plugins/annotation-processing/testData/processors"
|
||||
|
||||
fun testSimple() = test("Simple", "Anno") { set, roundEnv, env ->
|
||||
fun testSimple() = test("Simple", "Anno") { set, roundEnv, _ ->
|
||||
assertEquals(1, set.size)
|
||||
val annotated = roundEnv.getElementsAnnotatedWith(set.first())
|
||||
assertEquals(3, annotated.size)
|
||||
@@ -52,7 +52,7 @@ class ProcessorTests : AbstractProcessorTest() {
|
||||
}
|
||||
}
|
||||
|
||||
fun testSeveralAnnotations() = test("SeveralAnnotations", "Name", "Age") { set, roundEnv, env ->
|
||||
fun testSeveralAnnotations() = test("SeveralAnnotations", "Name", "Age") { set, roundEnv, _ ->
|
||||
val annos = set.toList()
|
||||
|
||||
assertEquals(2, annos.size)
|
||||
@@ -70,15 +70,15 @@ class ProcessorTests : AbstractProcessorTest() {
|
||||
}
|
||||
}
|
||||
|
||||
fun testStar() = test("Star", "*") { set, roundEnv, env ->
|
||||
fun testStar() = test("Star", "*") { set, _, _ ->
|
||||
assertEquals(true, set.any { it.qualifiedName.toString() == "Anno" })
|
||||
}
|
||||
|
||||
fun testStar2() = test("Star", "Anno", "*") { set, roundEnv, env ->
|
||||
fun testStar2() = test("Star", "Anno", "*") { set, _, _ ->
|
||||
assertEquals(true, set.any { it.qualifiedName.toString() == "Anno" })
|
||||
}
|
||||
|
||||
fun testStar3() = test("Star3", "Anno", "*") { set, roundEnv, env ->
|
||||
fun testStar3() = test("Star3", "Anno", "*") { set, _, _ ->
|
||||
assertEquals(true, set.any { it.qualifiedName.toString() == "Anno2" })
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ class ProcessorTests : AbstractProcessorTest() {
|
||||
|
||||
fun testInheritedAnnotations() {
|
||||
val handledClasses = mutableListOf<String>()
|
||||
test("InheritedAnnotations", "Anno") { set, roundEnv, env ->
|
||||
test("InheritedAnnotations", "Anno") { set, roundEnv, _ ->
|
||||
assertEquals(1, set.size)
|
||||
val annotatedElements = roundEnv.getElementsAnnotatedWith(set.first())
|
||||
for (element in annotatedElements) {
|
||||
@@ -103,7 +103,7 @@ class ProcessorTests : AbstractProcessorTest() {
|
||||
assertEquals(listOf("Base", "Impl", "Intf"), handledClasses.sorted())
|
||||
}
|
||||
|
||||
fun testInheritedAnnotationsOverridden() = test("InheritedAnnotationsOverridden", "Anno") { set, roundEnv, env ->
|
||||
fun testInheritedAnnotationsOverridden() = test("InheritedAnnotationsOverridden", "Anno") { set, roundEnv, _ ->
|
||||
assertEquals(1, set.size)
|
||||
val annotatedElements = roundEnv.getElementsAnnotatedWith(set.first())
|
||||
assertEquals(2, annotatedElements.size)
|
||||
@@ -112,7 +112,7 @@ class ProcessorTests : AbstractProcessorTest() {
|
||||
assertEquals("Tom", implAnnotations.first().elementValues.values.first().value)
|
||||
}
|
||||
|
||||
fun testNested() = test("Nested", "Anno") { set, roundEnv, env ->
|
||||
fun testNested() = test("Nested", "Anno") { set, roundEnv, _ ->
|
||||
assertEquals(1, set.size)
|
||||
val annotatedElements = roundEnv.getElementsAnnotatedWith(set.first())
|
||||
assertEquals(1, annotatedElements.size)
|
||||
@@ -127,21 +127,21 @@ class ProcessorTests : AbstractProcessorTest() {
|
||||
assertTrue((anno2.getParam("e") as JeArrayAnnotationValue).value.first() is JeTypeAnnotationValue)
|
||||
}
|
||||
|
||||
fun testEnumArray() = test("EnumArray", "*") { set, roundEnv, env ->
|
||||
fun testEnumArray() = test("EnumArray", "*") { _, _, env ->
|
||||
val testClass = env.findClass("org.jetbrains.kotlin.annotation.processing.test.processor.Test")
|
||||
val enumAnno = testClass.getAnnotation(ColorsAnnotation::class.java)
|
||||
assertNotNull(enumAnno)
|
||||
assertEquals(listOf("BLUE", "RED"), enumAnno!!.colors.map { it.name })
|
||||
}
|
||||
|
||||
fun testStringArray() = test("StringArray", "*") { set, roundEnv, env ->
|
||||
fun testStringArray() = test("StringArray", "*") { _, _, env ->
|
||||
val testClass = env.findClass("Test")
|
||||
val suppress = testClass.getAnnotation(Suppress::class.java)
|
||||
assertNotNull(suppress)
|
||||
assertEquals(listOf("Tom", "Mary"), suppress!!.names.toList())
|
||||
}
|
||||
|
||||
fun testTypeArguments() = test("TypeArguments", "*") { set, roundEnv, env ->
|
||||
fun testTypeArguments() = test("TypeArguments", "*") { _, _, env ->
|
||||
val classA = env.findClass("A")
|
||||
val superB = classA.superclass as JeDeclaredType
|
||||
val interfaceC = classA.interfaces[0] as JeDeclaredType
|
||||
@@ -150,7 +150,7 @@ class ProcessorTests : AbstractProcessorTest() {
|
||||
assertTrue(interfaceC.typeArguments.size == 1)
|
||||
}
|
||||
|
||||
fun testTypeArguments2() = test("TypeArguments2", "*") { set, roundEnv, env ->
|
||||
fun testTypeArguments2() = test("TypeArguments2", "*") { _, _, env ->
|
||||
val b = env.findClass("B")
|
||||
val bSuperTypes = env.typeUtils.directSupertypes(b.asType())
|
||||
assertEquals(1, bSuperTypes.size)
|
||||
@@ -182,7 +182,7 @@ class ProcessorTests : AbstractProcessorTest() {
|
||||
assertEquals("I3<java.util.List<? extends java.lang.String>>", i3.toString())
|
||||
}
|
||||
|
||||
fun testErasureSimple() = test("ErasureSimple", "*") { set, roundEnv, env ->
|
||||
fun testErasureSimple() = test("ErasureSimple", "*") { _, _, env ->
|
||||
val test = env.findClass("Test")
|
||||
val int = test.findMethod("a").returnType
|
||||
val void = test.findMethod("b").returnType
|
||||
@@ -190,7 +190,7 @@ class ProcessorTests : AbstractProcessorTest() {
|
||||
assertEquals(void, env.typeUtils.erasure(void))
|
||||
}
|
||||
|
||||
fun testErasure2() = test("Erasure2", "*") { set, roundEnv, env ->
|
||||
fun testErasure2() = test("Erasure2", "*") { _, _, env ->
|
||||
val erasure = fun (t: JeMethodExecutableTypeMirror) = env.typeUtils.erasure(t)
|
||||
fun JeTypeElement.check(methodName: String, toString: String, transform: (JeMethodExecutableTypeMirror) -> TypeMirror = { it }) {
|
||||
val method = enclosedElements.first { it is JeMethodExecutableElement && it.simpleName.toString() == methodName }
|
||||
@@ -246,7 +246,7 @@ class ProcessorTests : AbstractProcessorTest() {
|
||||
.firstIsInstance<AnnotationProcessingExtensionForTests>()
|
||||
|
||||
private fun incrementalDataTest(fileName: String, @Language("TEXT") expectedText: String) {
|
||||
test(fileName, "Anno", "Anno2", "Anno3") { set, roundEnv, env -> }
|
||||
test(fileName, "Anno", "Anno2", "Anno3") { _, _, _ -> }
|
||||
val ext = getKapt2Extension()
|
||||
val incrementalDataFile = ext.incrementalDataFile
|
||||
assertNotNull(incrementalDataFile)
|
||||
@@ -254,7 +254,7 @@ class ProcessorTests : AbstractProcessorTest() {
|
||||
assertEquals(expectedText, text)
|
||||
}
|
||||
|
||||
fun testKotlinAnnotationDefaultValueFromBinary() = test("DefaultValueFromBinary", "*") { set, roundEnv, env ->
|
||||
fun testKotlinAnnotationDefaultValueFromBinary() = test("DefaultValueFromBinary", "*") { _, _, env ->
|
||||
fun check(expectedValue: Boolean, className: String) {
|
||||
val clazz = env.findClass(className)
|
||||
val anno = clazz.getAnnotation(JvmSuppressWildcards::class.java)!!
|
||||
@@ -266,7 +266,7 @@ class ProcessorTests : AbstractProcessorTest() {
|
||||
check(false, "TestFalse")
|
||||
}
|
||||
|
||||
fun testAsMemberOf() = test("AsMemberOf", "*") { set, roundEnv, env ->
|
||||
fun testAsMemberOf() = test("AsMemberOf", "*") { _, _, env ->
|
||||
val f = env.findClass("Test").findField("f")
|
||||
val fType = f.asType() as JeDeclaredType
|
||||
|
||||
@@ -290,7 +290,7 @@ class ProcessorTests : AbstractProcessorTest() {
|
||||
check(implM, "(java.lang.String)java.lang.String")
|
||||
}
|
||||
|
||||
fun testAsMemberOfTypeParameters() = test("AsMemberOfTypeParameters", "*") { set, roundEnv, env ->
|
||||
fun testAsMemberOfTypeParameters() = test("AsMemberOfTypeParameters", "*") { _, _, env ->
|
||||
val intf = env.findClass("Intf")
|
||||
val intfT = intf.typeParameters[0]
|
||||
val base = env.findClass("Base")
|
||||
@@ -309,7 +309,7 @@ class ProcessorTests : AbstractProcessorTest() {
|
||||
fun testDispose() {
|
||||
var savedEnv: ProcessingEnvironment? = null
|
||||
|
||||
test("AsMemberOf", "*") { set, roundEnv, env ->
|
||||
test("AsMemberOf", "*") { _, _, env ->
|
||||
savedEnv = env
|
||||
}
|
||||
|
||||
@@ -333,7 +333,7 @@ class ProcessorTests : AbstractProcessorTest() {
|
||||
test { filer }
|
||||
|
||||
fun testDisposable(name: String) {
|
||||
test { (javaClass.methods.first { it.name.startsWith("$name$") }.invoke(this) as DisposableRef<*>).invoke() }
|
||||
test { (this::class.java.methods.first { it.name.startsWith("$name$") }.invoke(this) as DisposableRef<*>).invoke() }
|
||||
}
|
||||
|
||||
testDisposable("getProject")
|
||||
@@ -342,7 +342,7 @@ class ProcessorTests : AbstractProcessorTest() {
|
||||
}
|
||||
}
|
||||
|
||||
fun testMapMutableMap() = test("MapMutableMap", "*") { set, roundEnv, env ->
|
||||
fun testMapMutableMap() = test("MapMutableMap", "*") { _, _, env ->
|
||||
val test = env.findClass("Test")
|
||||
fun test(name: String, expected: String) {
|
||||
assertEquals(expected, test.findMethods(name).single().parameters.single().asType().toString())
|
||||
@@ -359,7 +359,7 @@ class ProcessorTests : AbstractProcessorTest() {
|
||||
|
||||
var kotlinEnv: KotlinProcessingEnvironment? = null
|
||||
try {
|
||||
test("MapMutableMap", "*") { set, roundEnv, env ->
|
||||
test("MapMutableMap", "*") { _, _, env ->
|
||||
kotlinEnv = env as KotlinProcessingEnvironment
|
||||
throw HiThere()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user