Minor: get line start without whitespaces in KotlinExtraVariablesProvider
#KT-10183 Fxied
This commit is contained in:
@@ -34,9 +34,12 @@ import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.idea.KotlinFileType
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeFully
|
||||
import org.jetbrains.kotlin.idea.codeInsight.CodeInsightUtils
|
||||
import org.jetbrains.kotlin.idea.core.refactoring.getLineEndOffset
|
||||
import org.jetbrains.kotlin.idea.core.refactoring.getLineStartOffset
|
||||
import org.jetbrains.kotlin.idea.util.application.runReadAction
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.check
|
||||
import java.util.*
|
||||
|
||||
public class KotlinFrameExtraVariablesProvider : FrameExtraVariablesProvider {
|
||||
@@ -61,8 +64,7 @@ private fun findAdditionalExpressions(position: SourcePosition): Set<TextWithImp
|
||||
return emptySet()
|
||||
}
|
||||
|
||||
val offset = doc.getLineStartOffset(line)
|
||||
if (offset < 0) return emptySet()
|
||||
val offset = file.getLineStartOffset(line)?.check { it > 0 } ?: return emptySet()
|
||||
|
||||
val elem = file.findElementAt(offset)
|
||||
val containingElement = getContainingElement(elem!!) ?: elem ?: return emptySet()
|
||||
@@ -79,8 +81,8 @@ private fun findAdditionalExpressions(position: SourcePosition): Set<TextWithImp
|
||||
endLine++
|
||||
}
|
||||
|
||||
val startOffset = doc.getLineStartOffset(startLine)
|
||||
val endOffset = doc.getLineEndOffset(endLine)
|
||||
val startOffset = file.getLineStartOffset(startLine) ?: return emptySet()
|
||||
val endOffset = file.getLineEndOffset(endLine) ?: return emptySet()
|
||||
|
||||
if (startOffset >= endOffset) return emptySet()
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
LineBreakpoint created at evFunctionDeclaration.kt:5
|
||||
!JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !OUTPUT_PATH!;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! evFunctionDeclaration.EvFunctionDeclarationKt
|
||||
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||
evFunctionDeclaration.kt:5
|
||||
package evFunctionDeclaration
|
||||
|
||||
class A(val a: Int) {
|
||||
//Breakpoint!
|
||||
fun foo() = a
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
A(1).foo()
|
||||
}
|
||||
|
||||
// PRINT_FRAME
|
||||
Compile bytecode for a
|
||||
frame = foo():5, A {evFunctionDeclaration}
|
||||
this = this = {evFunctionDeclaration.A@uniqueID}
|
||||
field = a: int = 1 (sp = evFunctionDeclaration.kt, 3)
|
||||
extra = a
|
||||
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||
|
||||
Process finished with exit code 0
|
||||
idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/extraVariables/evFunctionDeclaration.kt
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
package evFunctionDeclaration
|
||||
|
||||
class A(val a: Int) {
|
||||
//Breakpoint!
|
||||
fun foo() = a
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
A(1).foo()
|
||||
}
|
||||
|
||||
// PRINT_FRAME
|
||||
+6
@@ -390,6 +390,12 @@ public class KotlinEvaluateExpressionTestGenerated extends AbstractKotlinEvaluat
|
||||
doSingleBreakpointTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("evFunctionDeclaration.kt")
|
||||
public void testEvFunctionDeclaration() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/extraVariables/evFunctionDeclaration.kt");
|
||||
doSingleBreakpointTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("evLineRange.kt")
|
||||
public void testEvLineRange() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/extraVariables/evLineRange.kt");
|
||||
|
||||
Reference in New Issue
Block a user