Skip to content

Commit ae2e857

Browse files
committed
Refactoring: remove lambda parameter from readClassFile()
1 parent 623ee31 commit ae2e857

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

idea/src/org/jetbrains/kotlin/idea/debugger/NoStrataPositionManagerHelper.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,16 +110,16 @@ internal fun getOriginalPositionOfInlinedLine(location: Location, project: Proje
110110

111111
internal fun findAndReadClassFile(
112112
fqName: FqName, fileName: String, project: Project, searchScope: GlobalSearchScope,
113-
sourceFileFilter: (VirtualFile) -> Boolean = { true },
114-
libFileFilter: (VirtualFile) -> Boolean = { true }): ByteArray? {
113+
fileFilter: (VirtualFile) -> Boolean): ByteArray? {
115114
val internalName = fqName.asString().replace('.', '/')
116115
val jvmClassName = JvmClassName.byInternalName(internalName)
117116

118117
val file = DebuggerUtils.findSourceFileForClassIncludeLibrarySources(project, searchScope, jvmClassName, fileName) ?: return null
119118

120119
val virtualFile = file.virtualFile ?: return null
120+
if (!fileFilter(virtualFile)) return null
121121

122-
return readClassFile(project, jvmClassName, virtualFile, sourceFileFilter = sourceFileFilter, libFileFilter = libFileFilter)
122+
return readClassFile(project, jvmClassName, virtualFile)
123123
}
124124

125125
internal fun getLocationsOfInlinedLine(type: ReferenceType, position: SourcePosition, sourceSearchScope: GlobalSearchScope): List<Location> {

idea/src/org/jetbrains/kotlin/idea/debugger/smapUtil.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,27 +41,29 @@ import org.jetbrains.org.objectweb.asm.ClassVisitor
4141
import java.io.File
4242

4343
fun isInlineFunctionLineNumber(file: VirtualFile, lineNumber: Int, project: Project): Boolean {
44-
val linesInFile = file.toPsiFile(project)?.getLineCount() ?: return false
45-
return lineNumber > linesInFile
44+
if (ProjectRootsUtil.isProjectSourceFile(project, file)) {
45+
val linesInFile = file.toPsiFile(project)?.getLineCount() ?: return false
46+
return lineNumber > linesInFile
47+
}
48+
49+
return true
4650
}
4751

4852
fun readClassFile(project: Project,
4953
jvmName: JvmClassName,
50-
file: VirtualFile,
51-
sourceFileFilter: (VirtualFile) -> Boolean = { true },
52-
libFileFilter: (VirtualFile) -> Boolean = { true }): ByteArray? {
54+
file: VirtualFile): ByteArray? {
5355
val fqNameWithInners = jvmName.fqNameForClassNameWithoutDollars.tail(jvmName.packageFqName)
5456

5557
when {
56-
ProjectRootsUtil.isLibrarySourceFile(project, file) && libFileFilter(file) -> {
58+
ProjectRootsUtil.isLibrarySourceFile(project, file) -> {
5759
val classId = ClassId(jvmName.packageFqName, Name.identifier(fqNameWithInners.asString()))
5860

5961
val fileFinder = JvmVirtualFileFinder.SERVICE.getInstance(project)
6062
val classFile = fileFinder.findVirtualFileWithHeader(classId) ?: return null
6163
return classFile.contentsToByteArray()
6264
}
6365

64-
ProjectRootsUtil.isProjectSourceFile(project, file) && sourceFileFilter(file) -> {
66+
ProjectRootsUtil.isProjectSourceFile(project, file) -> {
6567
val module = ProjectFileIndex.SERVICE.getInstance(project).getModuleForFile(file)
6668
val outputDir = CompilerPaths.getModuleOutputDirectory(module, /*forTests = */ false) ?: return null
6769

idea/src/org/jetbrains/kotlin/idea/filters/KotlinExceptionFilter.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ class KotlinExceptionFilter(private val searchScope: GlobalSearchScope) : Filter
7373
}
7474

7575
private fun createHyperlinks(jvmName: JvmClassName, file: VirtualFile, line: Int, project: Project): InlineFunctionHyperLinkInfo? {
76-
val bytes = readClassFile(project, jvmName, file,
77-
sourceFileFilter = { sourceFile -> isInlineFunctionLineNumber(sourceFile, line, project) }) ?: return null
76+
if (!isInlineFunctionLineNumber(file, line, project)) return null
77+
78+
val bytes = readClassFile(project, jvmName, file) ?: return null
7879
val smapData = readDebugInfo(bytes) ?: return null
7980

8081
val inlineInfos = arrayListOf<InlineFunctionHyperLinkInfo.InlineInfo>()

0 commit comments

Comments
 (0)