Evaluator: Allow to evaluate expression on synthetic lines in .kt files
This commit is contained in:
+2
-2
@@ -89,12 +89,12 @@ object KotlinEvaluationBuilder : EvaluatorBuilder {
|
|||||||
return EvaluatorBuilderImpl.getInstance()!!.build(codeFragment, position)
|
return EvaluatorBuilderImpl.getInstance()!!.build(codeFragment, position)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (position.line < 0) {
|
if (position.line < 0 && position.file !is KtFile) {
|
||||||
evaluationException("Couldn't evaluate Kotlin expression at $position")
|
evaluationException("Couldn't evaluate Kotlin expression at $position")
|
||||||
}
|
}
|
||||||
|
|
||||||
val file = position.file
|
val file = position.file
|
||||||
if (file is KtFile) {
|
if (file is KtFile && position.line >= 0) {
|
||||||
val document = PsiDocumentManager.getInstance(file.project).getDocument(file)
|
val document = PsiDocumentManager.getInstance(file.project).getDocument(file)
|
||||||
if (document == null || document.lineCount < position.line) {
|
if (document == null || document.lineCount < position.line) {
|
||||||
evaluationException(
|
evaluationException(
|
||||||
|
|||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
package dataClassCopy
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
val a = Foo("foo")
|
||||||
|
//Breakpoint!
|
||||||
|
a.copy("bar")
|
||||||
|
}
|
||||||
|
|
||||||
|
data class Foo(val a: String)
|
||||||
|
|
||||||
|
// STEP_INTO: 1
|
||||||
|
// STEP_OUT: 1
|
||||||
|
|
||||||
|
// EXPRESSION: Foo("baz")
|
||||||
|
// RESULT: instance of dataClassCopy.Foo(id=ID): LdataClassCopy/Foo;
|
||||||
|
|
||||||
|
// EXPRESSION: a
|
||||||
|
// RESULT: Unresolved reference: a
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
LineBreakpoint created at dataClassCopy.kt:6
|
||||||
|
Run Java
|
||||||
|
Connected to the target VM
|
||||||
|
dataClassCopy.kt:6
|
||||||
|
dataClassCopy.kt:9
|
||||||
|
dataClassCopy.kt:-1
|
||||||
|
Compile bytecode for Foo("baz")
|
||||||
|
Disconnected from the target VM
|
||||||
|
|
||||||
|
Process finished with exit code 0
|
||||||
Generated
+5
@@ -91,6 +91,11 @@ public class KotlinEvaluateExpressionTestGenerated extends AbstractKotlinEvaluat
|
|||||||
runTest("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/collections.kt");
|
runTest("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/collections.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("dataClassCopy.kt")
|
||||||
|
public void testDataClassCopy() throws Exception {
|
||||||
|
runTest("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/dataClassCopy.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("defaultParameterValues.kt")
|
@TestMetadata("defaultParameterValues.kt")
|
||||||
public void testDefaultParameterValues() throws Exception {
|
public void testDefaultParameterValues() throws Exception {
|
||||||
runTest("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/defaultParameterValues.kt");
|
runTest("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/defaultParameterValues.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user