IDEA: add a couple "navigate to inline function call site" tests

This commit is contained in:
pyos
2020-03-31 12:22:31 +02:00
committed by max-kammerer
parent 9d7db101e6
commit 23ea2446e0
5 changed files with 49 additions and 1 deletions
@@ -53,6 +53,12 @@ class InlineFunctionHyperLinkInfo(
return file?.let { OpenFileDescriptor(project, file.file, file.line, 0) }
}
val callSiteDescriptor: OpenFileDescriptor?
get() {
val file = inlineInfo.firstOrNull { it is InlineInfo.CallSiteInfo }
return file?.let { OpenFileDescriptor(project, file.file, file.line, 0) }
}
sealed class InlineInfo(val prefix: String, val file: VirtualFile, val line: Int) {
class CallSiteInfo(file: VirtualFile, line: Int) :
InlineInfo(KotlinBundle.message("filters.text.inline.function.call.site"), file, line)
@@ -0,0 +1,11 @@
fun box() {
foo()
}
inline fun foo() {
null!!
}
// NAVIGATE_TO_CALL_SITE
// FILE: inlineFunCallSite.kt
// LINE: 2
@@ -0,0 +1,17 @@
fun box() {
bar {
foo()
}
}
inline fun foo() {
null!!
}
inline fun bar(x: () -> Unit) {
x()
}
// NAVIGATE_TO_CALL_SITE
// FILE: inlineFunCallSiteInInlineLambda.kt
// LINE: 3
@@ -110,7 +110,11 @@ abstract class AbstractKotlinExceptionFilterTest : KotlinCodeInsightTestCase() {
}
val info = result.firstHyperlinkInfo as FileHyperlinkInfo
val descriptor = info.descriptor!!
val descriptor = if (InTextDirectivesUtils.isDirectiveDefined(fileText, "NAVIGATE_TO_CALL_SITE"))
(info as? InlineFunctionHyperLinkInfo)?.callSiteDescriptor
?: throw AssertionError("`$stackTraceString` did not resolve to an inline function call")
else
info.descriptor!!
val expectedFileName = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// FILE: ")!!
val expectedVirtualFile = File(rootDir, expectedFileName).toVirtualFile()
@@ -38,6 +38,16 @@ public class KotlinExceptionFilterTestGenerated extends AbstractKotlinExceptionF
runTest("idea/testData/debugger/exceptionFilter/inlineFunCallInLibrary/");
}
@TestMetadata("inlineFunCallSite")
public void testInlineFunCallSite() throws Exception {
runTest("idea/testData/debugger/exceptionFilter/inlineFunCallSite/");
}
@TestMetadata("inlineFunCallSiteInInlineLambda")
public void testInlineFunCallSiteInInlineLambda() throws Exception {
runTest("idea/testData/debugger/exceptionFilter/inlineFunCallSiteInInlineLambda/");
}
@TestMetadata("inlineFunFromLibrary")
public void testInlineFunFromLibrary() throws Exception {
runTest("idea/testData/debugger/exceptionFilter/inlineFunFromLibrary/");