Refactoring: introduce constants with strata names and reuse them in debugger
This commit is contained in:
committed by
Nikolay Krasko
parent
66bbcf470c
commit
64e034959f
@@ -21,6 +21,9 @@ import org.jetbrains.kotlin.codegen.ClassBuilder
|
||||
import org.jetbrains.kotlin.codegen.SourceInfo
|
||||
import java.util.*
|
||||
|
||||
val KOTLIN_STRATA_NAME = "Kotlin"
|
||||
val KOTLIN_DEBUG_STRATA_NAME = "KotlinDebug"
|
||||
|
||||
//TODO join parameter
|
||||
class SMAPBuilder(
|
||||
val source: String,
|
||||
@@ -48,7 +51,7 @@ class SMAPBuilder(
|
||||
private fun generateDefaultStrata(realMappings: List<FileMapping>): String {
|
||||
val fileIds = "*F" + realMappings.mapIndexed { id, file -> "\n${file.toSMAPFile(id + 1)}" }.joinToString("")
|
||||
val lineMappings = "*L" + realMappings.joinToString("") { it.toSMAPMapping() }
|
||||
return "*S Kotlin\n$fileIds\n$lineMappings\n*E\n"
|
||||
return "*S $KOTLIN_STRATA_NAME\n$fileIds\n$lineMappings\n*E\n"
|
||||
}
|
||||
|
||||
private fun generateDebugStrata(realMappings: List<FileMapping>): String {
|
||||
@@ -66,7 +69,7 @@ class SMAPBuilder(
|
||||
val newMappings = listOf(combinedMapping)
|
||||
val fileIds = "*F" + newMappings.mapIndexed { id, file -> "\n${file.toSMAPFile(id + 1)}" }.joinToString("")
|
||||
val lineMappings = "*L" + newMappings.joinToString("") { it.toSMAPMapping() }
|
||||
return "*S KotlinDebug\n$fileIds\n$lineMappings\n*E\n"
|
||||
return "*S $KOTLIN_DEBUG_STRATA_NAME\n$fileIds\n$lineMappings\n*E\n"
|
||||
}
|
||||
|
||||
private fun RangeMapping.toSMAP(fileId: Int): String {
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.sun.jdi.AbsentInformationException
|
||||
import com.sun.jdi.Location
|
||||
import com.sun.jdi.ReferenceType
|
||||
import com.sun.jdi.request.ClassPrepareRequest
|
||||
import org.jetbrains.kotlin.codegen.inline.KOTLIN_STRATA_NAME
|
||||
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil
|
||||
import org.jetbrains.kotlin.fileClasses.internalNameWithoutInnerClasses
|
||||
import org.jetbrains.kotlin.idea.codeInsight.CodeInsightUtils
|
||||
@@ -246,7 +247,7 @@ class KotlinPositionManager(private val myDebugProcess: DebugProcess) : MultiReq
|
||||
try {
|
||||
val line = position.line + 1
|
||||
val locations = if (myDebugProcess.virtualMachineProxy.versionHigher("1.4"))
|
||||
type.locationsOfLine("Kotlin", null, line).filter { it.sourceName("Kotlin") == position.file.name }
|
||||
type.locationsOfLine(KOTLIN_STRATA_NAME, null, line).filter { it.sourceName(KOTLIN_STRATA_NAME) == position.file.name }
|
||||
else
|
||||
type.locationsOfLine(line)
|
||||
if (locations == null || locations.isEmpty()) throw NoDataException.INSTANCE
|
||||
@@ -273,7 +274,7 @@ class KotlinPositionManager(private val myDebugProcess: DebugProcess) : MultiReq
|
||||
}
|
||||
}
|
||||
|
||||
private fun ReferenceType.containsKotlinStrata() = availableStrata().contains("Kotlin")
|
||||
private fun ReferenceType.containsKotlinStrata() = availableStrata().contains(KOTLIN_STRATA_NAME)
|
||||
}
|
||||
|
||||
inline fun <U, V> U.readAction(crossinline f: (U) -> V): V {
|
||||
|
||||
+2
-1
@@ -27,6 +27,7 @@ import com.intellij.xdebugger.impl.XSourcePositionImpl
|
||||
import com.sun.jdi.AbsentInformationException
|
||||
import com.sun.jdi.Location
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
import org.jetbrains.kotlin.codegen.inline.KOTLIN_STRATA_NAME
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeFully
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
||||
@@ -339,7 +340,7 @@ fun getStepOverPosition(
|
||||
}
|
||||
|
||||
return try {
|
||||
nextLocation.sourceName("Kotlin") == file.name
|
||||
nextLocation.sourceName(KOTLIN_STRATA_NAME) == file.name
|
||||
}
|
||||
catch(e: AbsentInformationException) {
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user