Stepping: do not step into kotlin standard library
#KT-2076 Fixed
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
<root>
|
||||
<item name='com.intellij.debugger.settings.DebuggerSettings com.intellij.ui.classFilter.ClassFilter[] getSteppingFilters()'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
</root>
|
||||
@@ -19,6 +19,7 @@ package org.jetbrains.jet.plugin;
|
||||
import com.intellij.openapi.application.PathMacros;
|
||||
import com.intellij.openapi.components.ApplicationComponent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.plugin.debugger.filter.FilterPackage;
|
||||
import org.jetbrains.jet.plugin.quickfix.QuickFixRegistrar;
|
||||
import org.jetbrains.jet.utils.PathUtil;
|
||||
|
||||
@@ -35,6 +36,8 @@ public class PluginStartupComponent implements ApplicationComponent {
|
||||
public void initComponent() {
|
||||
registerPathVariable();
|
||||
QuickFixRegistrar.registerQuickFixes();
|
||||
|
||||
FilterPackage.addKotlinStdlibDebugFilterIfNeeded();
|
||||
}
|
||||
|
||||
private static void registerPathVariable() {
|
||||
|
||||
@@ -35,6 +35,7 @@ import java.util.Arrays
|
||||
State(name = "KotlinDebuggerSettings", storages = array(Storage(file = StoragePathMacros.APP_CONFIG + "/kotlin_debug.xml")))
|
||||
public class KotlinDebuggerSettings : XDebuggerSettings<KotlinDebuggerSettings>("kotlin_debugger"), Getter<KotlinDebuggerSettings> {
|
||||
public var DEBUG_DISABLE_KOTLIN_INTERNAL_CLASSES: Boolean = true
|
||||
public var DEBUG_IS_FILTER_FOR_STDLIB_ALREADY_ADDED: Boolean = false
|
||||
|
||||
class object {
|
||||
public fun getInstance(): KotlinDebuggerSettings {
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2010-2014 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.jet.plugin.debugger.filter
|
||||
|
||||
import com.intellij.debugger.settings.DebuggerSettings
|
||||
import com.intellij.ui.classFilter.ClassFilter
|
||||
import org.jetbrains.jet.plugin.debugger.KotlinDebuggerSettings
|
||||
|
||||
private val KOTLIN_STDLIB_FILTER = "kotlin.*"
|
||||
|
||||
public fun addKotlinStdlibDebugFilterIfNeeded() {
|
||||
if (!KotlinDebuggerSettings.getInstance().DEBUG_IS_FILTER_FOR_STDLIB_ALREADY_ADDED) {
|
||||
val settings = DebuggerSettings.getInstance()!!
|
||||
val newFilters = (settings.getSteppingFilters() + ClassFilter(KOTLIN_STDLIB_FILTER)).copyToArray()
|
||||
|
||||
settings.setSteppingFilters(newFilters)
|
||||
|
||||
KotlinDebuggerSettings.getInstance().DEBUG_IS_FILTER_FOR_STDLIB_ALREADY_ADDED = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
LineBreakpoint created at stdlibStep.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! stdlibStep.StdlibStepPackage
|
||||
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||
stdlibStep.kt:5
|
||||
stdlibStep.kt:6
|
||||
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||
|
||||
Process finished with exit code 0
|
||||
@@ -0,0 +1,8 @@
|
||||
package stdlibStep
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val a = intArray(1)
|
||||
//Breakpoint!
|
||||
a.withIndices()
|
||||
val b = 1
|
||||
}
|
||||
@@ -34,6 +34,8 @@ import com.intellij.debugger.settings.DebuggerSettings
|
||||
|
||||
public abstract class AbstractKotlinSteppingTest : KotlinDebuggerTestCase() {
|
||||
private var oldSettings: DebuggerSettings by Delegates.notNull()
|
||||
private var oldIsFilterForStdlibAlreadyAdded: Boolean by Delegates.notNull()
|
||||
private var oldDisableKoltinInternalClasses: Boolean by Delegates.notNull()
|
||||
|
||||
override fun initApplication() {
|
||||
super<KotlinDebuggerTestCase>.initApplication()
|
||||
@@ -67,17 +69,30 @@ public abstract class AbstractKotlinSteppingTest : KotlinDebuggerTestCase() {
|
||||
}
|
||||
|
||||
private fun configureSettings(fileText: String) {
|
||||
val kotlinSettings = KotlinDebuggerSettings.getInstance()
|
||||
kotlinSettings.DEBUG_IS_FILTER_FOR_STDLIB_ALREADY_ADDED = false
|
||||
kotlinSettings.DEBUG_DISABLE_KOTLIN_INTERNAL_CLASSES = fileText.getValueForSetting("DISABLE_KOTLIN_INTERNAL_CLASSES", oldDisableKoltinInternalClasses)
|
||||
|
||||
val debuggerSettings = DebuggerSettings.getInstance()!!
|
||||
debuggerSettings.SKIP_CONSTRUCTORS = findStringWithPrefixes(fileText, "// SKIP_CONSTRUCTORS: ")?.toBoolean() ?: oldSettings.SKIP_CONSTRUCTORS
|
||||
debuggerSettings.SKIP_CLASSLOADERS = findStringWithPrefixes(fileText, "// SKIP_CLASSLOADERS: ")?.toBoolean() ?: oldSettings.SKIP_CLASSLOADERS
|
||||
debuggerSettings.TRACING_FILTERS_ENABLED = findStringWithPrefixes(fileText, "// TRACING_FILTERS_ENABLED: ")?.toBoolean() ?: oldSettings.TRACING_FILTERS_ENABLED
|
||||
debuggerSettings.SKIP_CONSTRUCTORS = fileText.getValueForSetting("SKIP_CONSTRUCTORS", oldSettings.SKIP_CONSTRUCTORS)
|
||||
debuggerSettings.SKIP_CLASSLOADERS = fileText.getValueForSetting("SKIP_CLASSLOADERS", oldSettings.SKIP_CLASSLOADERS)
|
||||
debuggerSettings.TRACING_FILTERS_ENABLED = fileText.getValueForSetting("TRACING_FILTERS_ENABLED", oldSettings.TRACING_FILTERS_ENABLED)
|
||||
}
|
||||
|
||||
private fun String.getValueForSetting(name: String, defaultValue: Boolean): Boolean {
|
||||
return findStringWithPrefixes(this, "// $name: ")?.toBoolean() ?: defaultValue
|
||||
}
|
||||
|
||||
private fun saveDefaultSettings() {
|
||||
oldIsFilterForStdlibAlreadyAdded = KotlinDebuggerSettings.getInstance().DEBUG_IS_FILTER_FOR_STDLIB_ALREADY_ADDED
|
||||
oldDisableKoltinInternalClasses = KotlinDebuggerSettings.getInstance().DEBUG_DISABLE_KOTLIN_INTERNAL_CLASSES
|
||||
oldSettings = DebuggerSettings.getInstance()!!.clone()
|
||||
}
|
||||
|
||||
private fun restoreDefaultSettings() {
|
||||
KotlinDebuggerSettings.getInstance().DEBUG_IS_FILTER_FOR_STDLIB_ALREADY_ADDED = oldIsFilterForStdlibAlreadyAdded
|
||||
KotlinDebuggerSettings.getInstance().DEBUG_DISABLE_KOTLIN_INTERNAL_CLASSES = oldDisableKoltinInternalClasses
|
||||
|
||||
val debuggerSettings = DebuggerSettings.getInstance()!!
|
||||
debuggerSettings.SKIP_CONSTRUCTORS = oldSettings.SKIP_CONSTRUCTORS
|
||||
debuggerSettings.SKIP_CLASSLOADERS = oldSettings.SKIP_CLASSLOADERS
|
||||
|
||||
@@ -206,6 +206,11 @@ public class KotlinSteppingTestGenerated extends AbstractKotlinSteppingTest {
|
||||
doStepIntoTest("idea/testData/debugger/tinyApp/src/filters/skipConstructors.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("stdlibStep.kt")
|
||||
public void testStdlibStep() throws Exception {
|
||||
doStepIntoTest("idea/testData/debugger/tinyApp/src/filters/stdlibStep.kt");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
|
||||
Reference in New Issue
Block a user