Debugger: check that label for marked object is a valid java identifier (KT-12651)
#KT-12651 Fixed
This commit is contained in:
committed by
Nikolay Krasko
parent
5ea74ed562
commit
3cbe28095b
@@ -110,6 +110,7 @@ These artifacts include extensions for the types available in the latter JDKs, s
|
|||||||
|
|
||||||
- [`KT-13059`](https://youtrack.jetbrains.com/issue/KT-13059) Fix error stepping on *Step Over* action in the end of while block
|
- [`KT-13059`](https://youtrack.jetbrains.com/issue/KT-13059) Fix error stepping on *Step Over* action in the end of while block
|
||||||
- [`KT-13037`](https://youtrack.jetbrains.com/issue/KT-13037) Fix possible deadlock in debugger in 2016.1 and exception in 2016.2
|
- [`KT-13037`](https://youtrack.jetbrains.com/issue/KT-13037) Fix possible deadlock in debugger in 2016.1 and exception in 2016.2
|
||||||
|
- [`KT-12651`](https://youtrack.jetbrains.com/issue/KT-12651) Fix exception in evaluate expression when bad identifier is used for marking object
|
||||||
|
|
||||||
## 1.0.3
|
## 1.0.3
|
||||||
|
|
||||||
|
|||||||
@@ -43,14 +43,13 @@ import org.jetbrains.eval4j.jdi.asValue
|
|||||||
import org.jetbrains.kotlin.asJava.KtLightClass
|
import org.jetbrains.kotlin.asJava.KtLightClass
|
||||||
import org.jetbrains.kotlin.idea.KotlinFileType
|
import org.jetbrains.kotlin.idea.KotlinFileType
|
||||||
import org.jetbrains.kotlin.idea.codeInsight.CodeInsightUtils
|
import org.jetbrains.kotlin.idea.codeInsight.CodeInsightUtils
|
||||||
|
import org.jetbrains.kotlin.idea.core.quoteIfNeeded
|
||||||
import org.jetbrains.kotlin.idea.debugger.KotlinEditorTextProvider
|
import org.jetbrains.kotlin.idea.debugger.KotlinEditorTextProvider
|
||||||
import org.jetbrains.kotlin.idea.j2k.J2kPostProcessor
|
import org.jetbrains.kotlin.idea.j2k.J2kPostProcessor
|
||||||
import org.jetbrains.kotlin.idea.refactoring.j2kText
|
import org.jetbrains.kotlin.idea.refactoring.j2kText
|
||||||
import org.jetbrains.kotlin.idea.core.quoteIfNeeded
|
|
||||||
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
|
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
|
||||||
import org.jetbrains.kotlin.idea.util.application.executeWriteCommand
|
import org.jetbrains.kotlin.idea.util.application.executeWriteCommand
|
||||||
import org.jetbrains.kotlin.j2k.AfterConversionPass
|
import org.jetbrains.kotlin.j2k.AfterConversionPass
|
||||||
import org.jetbrains.kotlin.name.Name
|
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext
|
import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
@@ -245,10 +244,12 @@ class KotlinCodeFragmentFactory: CodeFragmentFactory() {
|
|||||||
fun createCodeFragmentForLabeledObjects(project: Project, markupMap: Map<*, ValueMarkup>): Pair<String, Map<String, Value>> {
|
fun createCodeFragmentForLabeledObjects(project: Project, markupMap: Map<*, ValueMarkup>): Pair<String, Map<String, Value>> {
|
||||||
val sb = StringBuilder()
|
val sb = StringBuilder()
|
||||||
val labeledObjects = HashMap<String, Value>()
|
val labeledObjects = HashMap<String, Value>()
|
||||||
|
val psiNameHelper = PsiNameHelper.getInstance(project)
|
||||||
|
|
||||||
val entrySet: Set<Map.Entry<*, ValueMarkup>> = markupMap.entries
|
val entrySet: Set<Map.Entry<*, ValueMarkup>> = markupMap.entries
|
||||||
for ((value, markup) in entrySet) {
|
for ((value, markup) in entrySet) {
|
||||||
val labelName = markup.text
|
val labelName = markup.text
|
||||||
if (!Name.isValidIdentifier(labelName)) continue
|
if (!psiNameHelper.isIdentifier(labelName)) continue
|
||||||
|
|
||||||
val objectRef = value as? Value ?: continue
|
val objectRef = value as? Value ?: continue
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
LineBreakpoint created at lIdentifier.kt:10
|
||||||
|
!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! lIdentifier.LIdentifierKt
|
||||||
|
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||||
|
lIdentifier.kt:10
|
||||||
|
Compile bytecode for a
|
||||||
|
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||||
|
|
||||||
|
Process finished with exit code 0
|
||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
package lIdentifier
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
val a = 1
|
||||||
|
val b = 1
|
||||||
|
val c = 1
|
||||||
|
val d = 1
|
||||||
|
val e = 1
|
||||||
|
//Breakpoint!
|
||||||
|
val f = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
// DEBUG_LABEL: a = 0
|
||||||
|
// DEBUG_LABEL: b = <no_name>
|
||||||
|
// DEBUG_LABEL: c = for
|
||||||
|
// DEBUG_LABEL: d = *
|
||||||
|
// DEBUG_LABEL: e = e-e
|
||||||
|
|
||||||
|
// EXPRESSION: a
|
||||||
|
// RESULT: 1: I
|
||||||
+6
@@ -711,6 +711,12 @@ public class KotlinEvaluateExpressionTestGenerated extends AbstractKotlinEvaluat
|
|||||||
doSingleBreakpointTest(fileName);
|
doSingleBreakpointTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("lIdentifier.kt")
|
||||||
|
public void testLIdentifier() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/labels/lIdentifier.kt");
|
||||||
|
doSingleBreakpointTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("lSeveralLabels.kt")
|
@TestMetadata("lSeveralLabels.kt")
|
||||||
public void testLSeveralLabels() throws Exception {
|
public void testLSeveralLabels() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/labels/lSeveralLabels.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/labels/lSeveralLabels.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user