mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-18 00:20:54 +07:00
65 lines
2.5 KiB
Kotlin
65 lines
2.5 KiB
Kotlin
package com.intellij.codeInspection.tests.kotlin
|
|
|
|
import com.intellij.jvm.analysis.internal.testFramework.CallMatcherTestBase
|
|
import com.intellij.jvm.analysis.testFramework.JvmLanguage
|
|
import com.intellij.testFramework.LightProjectDescriptor
|
|
import com.siyeh.ig.callMatcher.CallMatcher
|
|
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
|
|
import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor
|
|
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
|
|
|
|
abstract class KotlinCallMatcherTest : CallMatcherTestBase(), ExpectedPluginModeProvider {
|
|
override fun getProjectDescriptor(): LightProjectDescriptor = KotlinWithJdkAndRuntimeLightProjectDescriptor.getInstance()
|
|
|
|
override fun setUp() {
|
|
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
|
|
}
|
|
|
|
fun testInstanceMethodCall() {
|
|
checkMatchCall(JvmLanguage.KOTLIN, CallMatcher.instanceCall("Foo", "bar").parameterCount(0), """
|
|
class Foo { fun bar() { } }
|
|
|
|
fun main() { Foo().bar() }
|
|
""".trimIndent())
|
|
}
|
|
|
|
fun testMultipleArgumentsCall() {
|
|
checkMatchCall(JvmLanguage.KOTLIN, CallMatcher.instanceCall("Foo", "bar").parameterCount(3), """
|
|
class Foo { fun bar(x: Int, y: Int, z: Int) { } }
|
|
|
|
fun main() { Foo().bar(0, 0, 0) }
|
|
""".trimIndent())
|
|
}
|
|
|
|
fun testMultipleArgumentsCallDefaultArg() {
|
|
checkMatchCall(JvmLanguage.KOTLIN, CallMatcher.instanceCall("Foo", "bar").parameterCount(3), """
|
|
class Foo { fun bar(x: Int, y: Int, z: Int = 0) { } }
|
|
|
|
fun main() { Foo().bar(0, 0) }
|
|
""".trimIndent())
|
|
}
|
|
|
|
fun testMultipleArgumentTypes() {
|
|
checkMatchCall(JvmLanguage.KOTLIN, CallMatcher.instanceCall("Foo", "bar").parameterTypes("int", "long", "double"), """
|
|
class Foo { fun bar(x: Int, y: Long, z: Double) { } }
|
|
|
|
fun main() { Foo().bar(0, 0L, 0.0) }
|
|
""".trimIndent())
|
|
}
|
|
|
|
fun testInstanceMethodReference() {
|
|
checkMatchCallableReference(JvmLanguage.KOTLIN, CallMatcher.instanceCall("java.lang.String", "plus").parameterCount(1), """
|
|
class Foo { fun bar(arg: String.(String) -> String) { } }
|
|
|
|
class Main { fun main() { Foo().bar(String::plus) } }
|
|
""".trimIndent())
|
|
}
|
|
|
|
fun testMethodReferenceArgumentTypes() {
|
|
checkMatchCallableReference(JvmLanguage.KOTLIN, CallMatcher.instanceCall("java.lang.String", "plus").parameterTypes("java.lang.Object"), """
|
|
class Foo { fun bar(arg: String.(String) -> String) { } }
|
|
|
|
class Main { fun main() { Foo().bar(String::plus) } }
|
|
""".trimIndent())
|
|
}
|
|
} |