Fix navigation from stack trace to inline function calls in inner classes
This commit is contained in:
@@ -34,6 +34,7 @@ import org.jetbrains.kotlin.idea.util.DebuggerUtils
|
||||
import org.jetbrains.kotlin.idea.util.ProjectRootsUtil
|
||||
import org.jetbrains.kotlin.load.kotlin.JvmVirtualFileFinder
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.tail
|
||||
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.check
|
||||
@@ -71,9 +72,13 @@ class KotlinExceptionFilter(private val searchScope: GlobalSearchScope) : Filter
|
||||
}
|
||||
|
||||
private fun virtualFileForInlineCall(jvmName: JvmClassName, file: VirtualFile, lineNumber: Int, project: Project): OpenFileHyperlinkInfo? {
|
||||
val fqNameWithInners = jvmName.fqNameForClassNameWithoutDollars.tail(jvmName.packageFqName)
|
||||
|
||||
if (ProjectRootsUtil.isInContent(project, file, false, true, false)) {
|
||||
val classId = ClassId(jvmName.packageFqName, Name.identifier(fqNameWithInners.asString()))
|
||||
|
||||
val fileFinder = JvmVirtualFileFinder.SERVICE.getInstance(project)
|
||||
val classFile = fileFinder.findVirtualFileWithHeader(ClassId(jvmName.packageFqName, jvmName.fqNameForClassNameWithoutDollars.shortName())) ?: return null
|
||||
val classFile = fileFinder.findVirtualFileWithHeader(classId) ?: return null
|
||||
return readDebugInfoForInlineFun(classFile.contentsToByteArray(), lineNumber, project)
|
||||
}
|
||||
|
||||
@@ -82,11 +87,11 @@ class KotlinExceptionFilter(private val searchScope: GlobalSearchScope) : Filter
|
||||
val linesInFile = file.toPsiFile(project)?.getLineCount() ?: return null
|
||||
if (lineNumber <= linesInFile) return null
|
||||
|
||||
val className = jvmName.fqNameForClassNameWithoutDollars.tail(jvmName.packageFqName).asString().replace('.', '$')
|
||||
|
||||
val module = ProjectFileIndex.SERVICE.getInstance(project).getModuleForFile(file)
|
||||
val outputDir = CompilerPaths.getModuleOutputDirectory(module, /*forTests = */ false) ?: return null
|
||||
|
||||
val className = fqNameWithInners.asString().replace('.', '$')
|
||||
val classByByDirectory = findClassFileByPath(jvmName.packageFqName.asString(), className, outputDir) ?: return null
|
||||
|
||||
return readDebugInfoForInlineFun(classByByDirectory.readBytes(), lineNumber, project)
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package inlineFunInnerClassFromLibrary
|
||||
|
||||
fun box() {
|
||||
inlineFunctionInnerClassInLbrary.A().Inner().test()
|
||||
}
|
||||
|
||||
// WITH_MOCK_LIBRARY: true
|
||||
// FILE: inlineFunInLibrary.kt
|
||||
// LINE: 4
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package inlineFunctionInnerClass
|
||||
|
||||
inline fun foo(f: () -> Unit) {
|
||||
null!!
|
||||
}
|
||||
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
package inlineFunctionInnerClass
|
||||
|
||||
fun box() {
|
||||
A().Inner().test()
|
||||
}
|
||||
|
||||
class A {
|
||||
inner class Inner {
|
||||
fun test() {
|
||||
foo {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: inlineFunctionFile.kt
|
||||
// LINE: 4
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package inlineFunctionInnerClassInLbrary
|
||||
|
||||
fun box() {
|
||||
A().Inner().test()
|
||||
}
|
||||
|
||||
class A {
|
||||
inner class Inner {
|
||||
fun test() {
|
||||
inlineFunInLibrary.foo {}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,6 +53,12 @@ public class KotlinExceptionFilterTestGenerated extends AbstractKotlinExceptionF
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inlineFunInnerClassFromLibrary")
|
||||
public void testInlineFunInnerClassFromLibrary() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/exceptionFilter/inlineFunInnerClassFromLibrary/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inlineFunctionAnotherFile")
|
||||
public void testInlineFunctionAnotherFile() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/exceptionFilter/inlineFunctionAnotherFile/");
|
||||
|
||||
Reference in New Issue
Block a user