From 62e9c31987380f8bf6d7cb93a517c163510089f7 Mon Sep 17 00:00:00 2001 From: Natalia Ukhorskaya Date: Thu, 7 May 2015 18:49:58 +0300 Subject: [PATCH] Do not step into package facade class if SKIP_SYNTHETIC_METHODS flag is true --- idea/src/META-INF/plugin.xml | 1 + .../KotlinSyntheticTypeComponentProvider.kt | 40 +++++++++++++++++++ .../debugger/tinyApp/outs/stepIntoStdlib.out | 1 - .../outs/stepIntoStdlibFacadeClass.out | 9 +++++ .../tinyApp/src/filters/stepIntoStdlib.kt | 2 +- .../src/filters/stepIntoStdlibFacadeClass.kt | 12 ++++++ .../debugger/KotlinSteppingTestGenerated.java | 6 +++ 7 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 idea/src/org/jetbrains/kotlin/idea/debugger/filter/KotlinSyntheticTypeComponentProvider.kt create mode 100644 idea/testData/debugger/tinyApp/outs/stepIntoStdlibFacadeClass.out create mode 100644 idea/testData/debugger/tinyApp/src/filters/stepIntoStdlibFacadeClass.kt diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index 673f6ef984a..fa797d8bc71 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -406,6 +406,7 @@ + diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/filter/KotlinSyntheticTypeComponentProvider.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/filter/KotlinSyntheticTypeComponentProvider.kt new file mode 100644 index 00000000000..e267c25053f --- /dev/null +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/filter/KotlinSyntheticTypeComponentProvider.kt @@ -0,0 +1,40 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.idea.debugger.filter + +import com.intellij.debugger.engine.SyntheticTypeComponentProvider +import com.sun.jdi.Method +import com.sun.jdi.TypeComponent +import org.jetbrains.kotlin.load.kotlin.PackageClassUtils +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.name.FqNameUnsafe + +public class KotlinSyntheticTypeComponentProvider: SyntheticTypeComponentProvider { + override fun isSynthetic(typeComponent: TypeComponent?): Boolean { + if (typeComponent !is Method) return false + + val typeName = typeComponent.declaringType().name() + if (!FqNameUnsafe.isValid(typeName)) return false + + if (PackageClassUtils.isPackageClassFqName(FqName(typeName))) { + val lineNumber = typeComponent.location().lineNumber() + return lineNumber == 1 + } + + return false + } +} \ No newline at end of file diff --git a/idea/testData/debugger/tinyApp/outs/stepIntoStdlib.out b/idea/testData/debugger/tinyApp/outs/stepIntoStdlib.out index 4e9d962fe3e..1eacbe33214 100644 --- a/idea/testData/debugger/tinyApp/outs/stepIntoStdlib.out +++ b/idea/testData/debugger/tinyApp/outs/stepIntoStdlib.out @@ -2,7 +2,6 @@ LineBreakpoint created at stepIntoStdlib.kt:6 !JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !APP_PATH!\classes;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! stepIntoStdlib.StepIntoStdlibPackage Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' stepIntoStdlib.kt:6 -KotlinPackage.!EXT! _Mapping.!EXT! Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' diff --git a/idea/testData/debugger/tinyApp/outs/stepIntoStdlibFacadeClass.out b/idea/testData/debugger/tinyApp/outs/stepIntoStdlibFacadeClass.out new file mode 100644 index 00000000000..d5f8c335b04 --- /dev/null +++ b/idea/testData/debugger/tinyApp/outs/stepIntoStdlibFacadeClass.out @@ -0,0 +1,9 @@ +LineBreakpoint created at stepIntoStdlibFacadeClass.kt:6 +!JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !APP_PATH!\classes;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! stepIntoStdlibFacadeClass.StepIntoStdlibFacadeClassPackage +Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' +stepIntoStdlibFacadeClass.kt:6 +KotlinPackage.!EXT! +_Mapping.!EXT! +Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' + +Process finished with exit code 0 diff --git a/idea/testData/debugger/tinyApp/src/filters/stepIntoStdlib.kt b/idea/testData/debugger/tinyApp/src/filters/stepIntoStdlib.kt index 357e701719d..fc423dce790 100644 --- a/idea/testData/debugger/tinyApp/src/filters/stepIntoStdlib.kt +++ b/idea/testData/debugger/tinyApp/src/filters/stepIntoStdlib.kt @@ -7,5 +7,5 @@ fun main(args: Array) { val b = 1 } -// STEP_INTO: 2 +// STEP_INTO: 1 // TRACING_FILTERS_ENABLED: false diff --git a/idea/testData/debugger/tinyApp/src/filters/stepIntoStdlibFacadeClass.kt b/idea/testData/debugger/tinyApp/src/filters/stepIntoStdlibFacadeClass.kt new file mode 100644 index 00000000000..0cdb9920f5d --- /dev/null +++ b/idea/testData/debugger/tinyApp/src/filters/stepIntoStdlibFacadeClass.kt @@ -0,0 +1,12 @@ +package stepIntoStdlibFacadeClass + +fun main(args: Array) { + val a = intArray(1) + //Breakpoint! + a.withIndex() + val b = 1 +} + +// STEP_INTO: 2 +// TRACING_FILTERS_ENABLED: false +// SKIP_SYNTHETIC_METHODS: false \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinSteppingTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinSteppingTestGenerated.java index 53728ddd1b4..41330c064f8 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinSteppingTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinSteppingTestGenerated.java @@ -333,5 +333,11 @@ public class KotlinSteppingTestGenerated extends AbstractKotlinSteppingTest { String fileName = JetTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/filters/stepIntoStdlib.kt"); doStepIntoTest(fileName); } + + @TestMetadata("stepIntoStdlibFacadeClass.kt") + public void testStepIntoStdlibFacadeClass() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/filters/stepIntoStdlibFacadeClass.kt"); + doStepIntoTest(fileName); + } } }