diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinPositionManager.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinPositionManager.kt index b2f0f12b06d..38e3d972bd5 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinPositionManager.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinPositionManager.kt @@ -264,7 +264,7 @@ class KotlinPositionManager(private val myDebugProcess: DebugProcess) : MultiReq } try { if (myDebugProcess.isDexDebug()) { - val inlineLocations = getLocationsOfInlinedLine(type, position, myDebugProcess.searchScope) + val inlineLocations = runReadAction { getLocationsOfInlinedLine(type, position, myDebugProcess.searchScope) } if (!inlineLocations.isEmpty()) { return inlineLocations } diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/smapUtil.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/smapUtil.kt index 6eccd4e1536..9a080aa99a5 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/smapUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/smapUtil.kt @@ -54,27 +54,46 @@ fun readClassFile(project: Project, file: VirtualFile): ByteArray? { val fqNameWithInners = jvmName.fqNameForClassNameWithoutDollars.tail(jvmName.packageFqName) - when { - ProjectRootsUtil.isLibrarySourceFile(project, file) -> { - val classId = ClassId(jvmName.packageFqName, Name.identifier(fqNameWithInners.asString())) + fun readFromLibrary() : ByteArray? { + if (!ProjectRootsUtil.isLibrarySourceFile(project, file)) return null - val fileFinder = JvmVirtualFileFinder.SERVICE.getInstance(project) - val classFile = fileFinder.findVirtualFileWithHeader(classId) ?: return null - return classFile.contentsToByteArray() - } + val classId = ClassId(jvmName.packageFqName, Name.identifier(fqNameWithInners.asString())) - ProjectRootsUtil.isProjectSourceFile(project, file) -> { - val module = ProjectFileIndex.SERVICE.getInstance(project).getModuleForFile(file) - val outputDir = CompilerPaths.getModuleOutputDirectory(module, /*forTests = */ false) ?: return null - - val className = fqNameWithInners.asString().replace('.', '$') - val classByDirectory = findClassFileByPath(jvmName.packageFqName.asString(), className, outputDir) ?: return null - - return classByDirectory.readBytes() - } - - else -> return null + val fileFinder = JvmVirtualFileFinder.SERVICE.getInstance(project) + val classFile = fileFinder.findVirtualFileWithHeader(classId) ?: return null + return classFile.contentsToByteArray() } + + fun readFromOutput(isForTestClasses: Boolean): ByteArray? { + if (!ProjectRootsUtil.isProjectSourceFile(project, file)) return null + + val module = ProjectFileIndex.SERVICE.getInstance(project).getModuleForFile(file) + val outputDir = CompilerPaths.getModuleOutputDirectory(module, /*forTests = */ isForTestClasses) ?: return null + + val className = fqNameWithInners.asString().replace('.', '$') + var classByDirectory = findClassFileByPath(jvmName.packageFqName.asString(), className, outputDir) + + if (classByDirectory == null) { + if (!isForTestClasses) { + return null + } + + val outputModeDirName = outputDir.name + val androidTestOutputDir = outputDir.parent?.parent?.findChild("androidTest")?.findChild(outputModeDirName) ?: return null + + classByDirectory = findClassFileByPath(jvmName.packageFqName.asString(), className, androidTestOutputDir) ?: return null + } + + return classByDirectory.readBytes() + } + + fun readFromSourceOutput() : ByteArray? = readFromOutput(false) + + fun readFromTestOutput() : ByteArray? = readFromOutput(true) + + return readFromLibrary() ?: + readFromSourceOutput() ?: + readFromTestOutput() } private fun findClassFileByPath(packageName: String, className: String, outputDir: VirtualFile): File? {