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(
|
||||
fqName: FqName, fileName: String, project: Project, searchScope: GlobalSearchScope,
|
||||
sourceFileFilter: (VirtualFile) -> Boolean = { true },
|
||||
libFileFilter: (VirtualFile) -> Boolean = { true }): ByteArray? {
|
||||
fileFilter: (VirtualFile) -> Boolean): ByteArray? {
|
||||
val internalName = fqName.asString().replace('.', '/')
|
||||
val jvmClassName = JvmClassName.byInternalName(internalName)
|
||||
|
||||
val file = DebuggerUtils.findSourceFileForClassIncludeLibrarySources(project, searchScope, jvmClassName, fileName) ?: 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> {
|
||||
|
||||
@@ -41,19 +41,21 @@ import org.jetbrains.org.objectweb.asm.ClassVisitor
|
||||
import java.io.File
|
||||
|
||||
fun isInlineFunctionLineNumber(file: VirtualFile, lineNumber: Int, project: Project): Boolean {
|
||||
val linesInFile = file.toPsiFile(project)?.getLineCount() ?: return false
|
||||
return lineNumber > linesInFile
|
||||
if (ProjectRootsUtil.isProjectSourceFile(project, file)) {
|
||||
val linesInFile = file.toPsiFile(project)?.getLineCount() ?: return false
|
||||
return lineNumber > linesInFile
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
fun readClassFile(project: Project,
|
||||
jvmName: JvmClassName,
|
||||
file: VirtualFile,
|
||||
sourceFileFilter: (VirtualFile) -> Boolean = { true },
|
||||
libFileFilter: (VirtualFile) -> Boolean = { true }): ByteArray? {
|
||||
file: VirtualFile): ByteArray? {
|
||||
val fqNameWithInners = jvmName.fqNameForClassNameWithoutDollars.tail(jvmName.packageFqName)
|
||||
|
||||
when {
|
||||
ProjectRootsUtil.isLibrarySourceFile(project, file) && libFileFilter(file) -> {
|
||||
ProjectRootsUtil.isLibrarySourceFile(project, file) -> {
|
||||
val classId = ClassId(jvmName.packageFqName, Name.identifier(fqNameWithInners.asString()))
|
||||
|
||||
val fileFinder = JvmVirtualFileFinder.SERVICE.getInstance(project)
|
||||
@@ -61,7 +63,7 @@ fun readClassFile(project: Project,
|
||||
return classFile.contentsToByteArray()
|
||||
}
|
||||
|
||||
ProjectRootsUtil.isProjectSourceFile(project, file) && sourceFileFilter(file) -> {
|
||||
ProjectRootsUtil.isProjectSourceFile(project, file) -> {
|
||||
val module = ProjectFileIndex.SERVICE.getInstance(project).getModuleForFile(file)
|
||||
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? {
|
||||
val bytes = readClassFile(project, jvmName, file,
|
||||
sourceFileFilter = { sourceFile -> isInlineFunctionLineNumber(sourceFile, line, project) }) ?: return null
|
||||
if (!isInlineFunctionLineNumber(file, line, project)) return null
|
||||
|
||||
val bytes = readClassFile(project, jvmName, file) ?: return null
|
||||
val smapData = readDebugInfo(bytes) ?: return null
|
||||
|
||||
val inlineInfos = arrayListOf<InlineFunctionHyperLinkInfo.InlineInfo>()
|
||||
|
||||
Reference in New Issue
Block a user