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 org.jetbrains.kotlin.codegen.SourceInfo
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
val KOTLIN_STRATA_NAME = "Kotlin"
|
||||||
|
val KOTLIN_DEBUG_STRATA_NAME = "KotlinDebug"
|
||||||
|
|
||||||
//TODO join parameter
|
//TODO join parameter
|
||||||
class SMAPBuilder(
|
class SMAPBuilder(
|
||||||
val source: String,
|
val source: String,
|
||||||
@@ -48,7 +51,7 @@ class SMAPBuilder(
|
|||||||
private fun generateDefaultStrata(realMappings: List<FileMapping>): String {
|
private fun generateDefaultStrata(realMappings: List<FileMapping>): String {
|
||||||
val fileIds = "*F" + realMappings.mapIndexed { id, file -> "\n${file.toSMAPFile(id + 1)}" }.joinToString("")
|
val fileIds = "*F" + realMappings.mapIndexed { id, file -> "\n${file.toSMAPFile(id + 1)}" }.joinToString("")
|
||||||
val lineMappings = "*L" + realMappings.joinToString("") { it.toSMAPMapping() }
|
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 {
|
private fun generateDebugStrata(realMappings: List<FileMapping>): String {
|
||||||
@@ -66,7 +69,7 @@ class SMAPBuilder(
|
|||||||
val newMappings = listOf(combinedMapping)
|
val newMappings = listOf(combinedMapping)
|
||||||
val fileIds = "*F" + newMappings.mapIndexed { id, file -> "\n${file.toSMAPFile(id + 1)}" }.joinToString("")
|
val fileIds = "*F" + newMappings.mapIndexed { id, file -> "\n${file.toSMAPFile(id + 1)}" }.joinToString("")
|
||||||
val lineMappings = "*L" + newMappings.joinToString("") { it.toSMAPMapping() }
|
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 {
|
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.Location
|
||||||
import com.sun.jdi.ReferenceType
|
import com.sun.jdi.ReferenceType
|
||||||
import com.sun.jdi.request.ClassPrepareRequest
|
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.JvmFileClassUtil
|
||||||
import org.jetbrains.kotlin.fileClasses.internalNameWithoutInnerClasses
|
import org.jetbrains.kotlin.fileClasses.internalNameWithoutInnerClasses
|
||||||
import org.jetbrains.kotlin.idea.codeInsight.CodeInsightUtils
|
import org.jetbrains.kotlin.idea.codeInsight.CodeInsightUtils
|
||||||
@@ -246,7 +247,7 @@ class KotlinPositionManager(private val myDebugProcess: DebugProcess) : MultiReq
|
|||||||
try {
|
try {
|
||||||
val line = position.line + 1
|
val line = position.line + 1
|
||||||
val locations = if (myDebugProcess.virtualMachineProxy.versionHigher("1.4"))
|
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
|
else
|
||||||
type.locationsOfLine(line)
|
type.locationsOfLine(line)
|
||||||
if (locations == null || locations.isEmpty()) throw NoDataException.INSTANCE
|
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 {
|
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.AbsentInformationException
|
||||||
import com.sun.jdi.Location
|
import com.sun.jdi.Location
|
||||||
import org.jetbrains.annotations.TestOnly
|
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.analyze
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeFully
|
import org.jetbrains.kotlin.idea.caches.resolve.analyzeFully
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
||||||
@@ -339,7 +340,7 @@ fun getStepOverPosition(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return try {
|
return try {
|
||||||
nextLocation.sourceName("Kotlin") == file.name
|
nextLocation.sourceName(KOTLIN_STRATA_NAME) == file.name
|
||||||
}
|
}
|
||||||
catch(e: AbsentInformationException) {
|
catch(e: AbsentInformationException) {
|
||||||
return true
|
return true
|
||||||
|
|||||||
Reference in New Issue
Block a user