Minor: Move safeSourceName to utils, make it a function
This commit is contained in:
@@ -101,7 +101,7 @@ class KotlinPositionManager(private val myDebugProcess: DebugProcess) : MultiReq
|
|||||||
override fun getSourcePosition(location: Location?): SourcePosition? {
|
override fun getSourcePosition(location: Location?): SourcePosition? {
|
||||||
if (location == null) throw NoDataException.INSTANCE
|
if (location == null) throw NoDataException.INSTANCE
|
||||||
|
|
||||||
val fileName = location.safeSourceName ?: throw NoDataException.INSTANCE
|
val fileName = location.safeSourceName() ?: throw NoDataException.INSTANCE
|
||||||
val lineNumber = location.safeLineNumber()
|
val lineNumber = location.safeLineNumber()
|
||||||
if (lineNumber < 0) {
|
if (lineNumber < 0) {
|
||||||
throw NoDataException.INSTANCE
|
throw NoDataException.INSTANCE
|
||||||
@@ -157,7 +157,7 @@ class KotlinPositionManager(private val myDebugProcess: DebugProcess) : MultiReq
|
|||||||
}
|
}
|
||||||
|
|
||||||
val sameLineLocations = location.safeMethod()?.safeAllLineLocations()?.filter {
|
val sameLineLocations = location.safeMethod()?.safeAllLineLocations()?.filter {
|
||||||
it.safeLineNumber() == lineNumber && it.safeSourceName == fileName
|
it.safeLineNumber() == lineNumber && it.safeSourceName() == fileName
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sameLineLocations != null) {
|
if (sameLineLocations != null) {
|
||||||
@@ -253,20 +253,8 @@ class KotlinPositionManager(private val myDebugProcess: DebugProcess) : MultiReq
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
private val Location.safeSourceName: String? get() {
|
|
||||||
return try {
|
|
||||||
sourceName()
|
|
||||||
}
|
|
||||||
catch (e: AbsentInformationException) {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
catch (e: InternalError) {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getPsiFileByLocation(location: Location): PsiFile? {
|
private fun getPsiFileByLocation(location: Location): PsiFile? {
|
||||||
val sourceName = location.safeSourceName ?: return null
|
val sourceName = location.safeSourceName() ?: return null
|
||||||
|
|
||||||
val referenceInternalName = try {
|
val referenceInternalName = try {
|
||||||
if (location.declaringType().containsKotlinStrata()) {
|
if (location.declaringType().containsKotlinStrata()) {
|
||||||
|
|||||||
@@ -54,6 +54,16 @@ fun Method.safeVariables(): List<LocalVariable> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Location.safeSourceName(): String? {
|
||||||
|
return try {
|
||||||
|
sourceName()
|
||||||
|
} catch (e: AbsentInformationException) {
|
||||||
|
null
|
||||||
|
} catch (e: InternalError) {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun Location.safeLineNumber(): Int {
|
fun Location.safeLineNumber(): Int {
|
||||||
return DebuggerUtilsEx.getLineNumber(this, false)
|
return DebuggerUtilsEx.getLineNumber(this, false)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user