Refactoring: remove lambda parameter from readClassFile()
This commit is contained in:
@@ -110,16 +110,16 @@ internal fun getOriginalPositionOfInlinedLine(location: Location, project: Proje
|
|||||||
|
|
||||||
internal fun findAndReadClassFile(
|
internal fun findAndReadClassFile(
|
||||||
fqName: FqName, fileName: String, project: Project, searchScope: GlobalSearchScope,
|
fqName: FqName, fileName: String, project: Project, searchScope: GlobalSearchScope,
|
||||||
sourceFileFilter: (VirtualFile) -> Boolean = { true },
|
fileFilter: (VirtualFile) -> Boolean): ByteArray? {
|
||||||
libFileFilter: (VirtualFile) -> Boolean = { true }): ByteArray? {
|
|
||||||
val internalName = fqName.asString().replace('.', '/')
|
val internalName = fqName.asString().replace('.', '/')
|
||||||
val jvmClassName = JvmClassName.byInternalName(internalName)
|
val jvmClassName = JvmClassName.byInternalName(internalName)
|
||||||
|
|
||||||
val file = DebuggerUtils.findSourceFileForClassIncludeLibrarySources(project, searchScope, jvmClassName, fileName) ?: return null
|
val file = DebuggerUtils.findSourceFileForClassIncludeLibrarySources(project, searchScope, jvmClassName, fileName) ?: return null
|
||||||
|
|
||||||
val virtualFile = file.virtualFile ?: return null
|
val virtualFile = file.virtualFile ?: return null
|
||||||
|
if (!fileFilter(virtualFile)) return null
|
||||||
|
|
||||||
return readClassFile(project, jvmClassName, virtualFile, sourceFileFilter = sourceFileFilter, libFileFilter = libFileFilter)
|
return readClassFile(project, jvmClassName, virtualFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun getLocationsOfInlinedLine(type: ReferenceType, position: SourcePosition, sourceSearchScope: GlobalSearchScope): List<Location> {
|
internal fun getLocationsOfInlinedLine(type: ReferenceType, position: SourcePosition, sourceSearchScope: GlobalSearchScope): List<Location> {
|
||||||
|
|||||||
@@ -41,19 +41,21 @@ import org.jetbrains.org.objectweb.asm.ClassVisitor
|
|||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
fun isInlineFunctionLineNumber(file: VirtualFile, lineNumber: Int, project: Project): Boolean {
|
fun isInlineFunctionLineNumber(file: VirtualFile, lineNumber: Int, project: Project): Boolean {
|
||||||
val linesInFile = file.toPsiFile(project)?.getLineCount() ?: return false
|
if (ProjectRootsUtil.isProjectSourceFile(project, file)) {
|
||||||
return lineNumber > linesInFile
|
val linesInFile = file.toPsiFile(project)?.getLineCount() ?: return false
|
||||||
|
return lineNumber > linesInFile
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
fun readClassFile(project: Project,
|
fun readClassFile(project: Project,
|
||||||
jvmName: JvmClassName,
|
jvmName: JvmClassName,
|
||||||
file: VirtualFile,
|
file: VirtualFile): ByteArray? {
|
||||||
sourceFileFilter: (VirtualFile) -> Boolean = { true },
|
|
||||||
libFileFilter: (VirtualFile) -> Boolean = { true }): ByteArray? {
|
|
||||||
val fqNameWithInners = jvmName.fqNameForClassNameWithoutDollars.tail(jvmName.packageFqName)
|
val fqNameWithInners = jvmName.fqNameForClassNameWithoutDollars.tail(jvmName.packageFqName)
|
||||||
|
|
||||||
when {
|
when {
|
||||||
ProjectRootsUtil.isLibrarySourceFile(project, file) && libFileFilter(file) -> {
|
ProjectRootsUtil.isLibrarySourceFile(project, file) -> {
|
||||||
val classId = ClassId(jvmName.packageFqName, Name.identifier(fqNameWithInners.asString()))
|
val classId = ClassId(jvmName.packageFqName, Name.identifier(fqNameWithInners.asString()))
|
||||||
|
|
||||||
val fileFinder = JvmVirtualFileFinder.SERVICE.getInstance(project)
|
val fileFinder = JvmVirtualFileFinder.SERVICE.getInstance(project)
|
||||||
@@ -61,7 +63,7 @@ fun readClassFile(project: Project,
|
|||||||
return classFile.contentsToByteArray()
|
return classFile.contentsToByteArray()
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectRootsUtil.isProjectSourceFile(project, file) && sourceFileFilter(file) -> {
|
ProjectRootsUtil.isProjectSourceFile(project, file) -> {
|
||||||
val module = ProjectFileIndex.SERVICE.getInstance(project).getModuleForFile(file)
|
val module = ProjectFileIndex.SERVICE.getInstance(project).getModuleForFile(file)
|
||||||
val outputDir = CompilerPaths.getModuleOutputDirectory(module, /*forTests = */ false) ?: return null
|
val outputDir = CompilerPaths.getModuleOutputDirectory(module, /*forTests = */ false) ?: return null
|
||||||
|
|
||||||
|
|||||||
@@ -73,8 +73,9 @@ class KotlinExceptionFilter(private val searchScope: GlobalSearchScope) : Filter
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun createHyperlinks(jvmName: JvmClassName, file: VirtualFile, line: Int, project: Project): InlineFunctionHyperLinkInfo? {
|
private fun createHyperlinks(jvmName: JvmClassName, file: VirtualFile, line: Int, project: Project): InlineFunctionHyperLinkInfo? {
|
||||||
val bytes = readClassFile(project, jvmName, file,
|
if (!isInlineFunctionLineNumber(file, line, project)) return null
|
||||||
sourceFileFilter = { sourceFile -> isInlineFunctionLineNumber(sourceFile, line, project) }) ?: return null
|
|
||||||
|
val bytes = readClassFile(project, jvmName, file) ?: return null
|
||||||
val smapData = readDebugInfo(bytes) ?: return null
|
val smapData = readDebugInfo(bytes) ?: return null
|
||||||
|
|
||||||
val inlineInfos = arrayListOf<InlineFunctionHyperLinkInfo.InlineInfo>()
|
val inlineInfos = arrayListOf<InlineFunctionHyperLinkInfo.InlineInfo>()
|
||||||
|
|||||||
Reference in New Issue
Block a user