Allow to place breakpoints in inline functions defined in android tests
This commit is contained in:
@@ -264,7 +264,7 @@ class KotlinPositionManager(private val myDebugProcess: DebugProcess) : MultiReq
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (myDebugProcess.isDexDebug()) {
|
if (myDebugProcess.isDexDebug()) {
|
||||||
val inlineLocations = getLocationsOfInlinedLine(type, position, myDebugProcess.searchScope)
|
val inlineLocations = runReadAction { getLocationsOfInlinedLine(type, position, myDebugProcess.searchScope) }
|
||||||
if (!inlineLocations.isEmpty()) {
|
if (!inlineLocations.isEmpty()) {
|
||||||
return inlineLocations
|
return inlineLocations
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,27 +54,46 @@ fun readClassFile(project: Project,
|
|||||||
file: VirtualFile): ByteArray? {
|
file: VirtualFile): ByteArray? {
|
||||||
val fqNameWithInners = jvmName.fqNameForClassNameWithoutDollars.tail(jvmName.packageFqName)
|
val fqNameWithInners = jvmName.fqNameForClassNameWithoutDollars.tail(jvmName.packageFqName)
|
||||||
|
|
||||||
when {
|
fun readFromLibrary() : ByteArray? {
|
||||||
ProjectRootsUtil.isLibrarySourceFile(project, file) -> {
|
if (!ProjectRootsUtil.isLibrarySourceFile(project, file)) return null
|
||||||
val classId = ClassId(jvmName.packageFqName, Name.identifier(fqNameWithInners.asString()))
|
|
||||||
|
|
||||||
val fileFinder = JvmVirtualFileFinder.SERVICE.getInstance(project)
|
val classId = ClassId(jvmName.packageFqName, Name.identifier(fqNameWithInners.asString()))
|
||||||
val classFile = fileFinder.findVirtualFileWithHeader(classId) ?: return null
|
|
||||||
return classFile.contentsToByteArray()
|
|
||||||
}
|
|
||||||
|
|
||||||
ProjectRootsUtil.isProjectSourceFile(project, file) -> {
|
val fileFinder = JvmVirtualFileFinder.SERVICE.getInstance(project)
|
||||||
val module = ProjectFileIndex.SERVICE.getInstance(project).getModuleForFile(file)
|
val classFile = fileFinder.findVirtualFileWithHeader(classId) ?: return null
|
||||||
val outputDir = CompilerPaths.getModuleOutputDirectory(module, /*forTests = */ false) ?: return null
|
return classFile.contentsToByteArray()
|
||||||
|
|
||||||
val className = fqNameWithInners.asString().replace('.', '$')
|
|
||||||
val classByDirectory = findClassFileByPath(jvmName.packageFqName.asString(), className, outputDir) ?: return null
|
|
||||||
|
|
||||||
return classByDirectory.readBytes()
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> return null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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? {
|
private fun findClassFileByPath(packageName: String, className: String, outputDir: VirtualFile): File? {
|
||||||
|
|||||||
Reference in New Issue
Block a user