Debugger: Add filter for Kotlin specific classes
#KT-2076 Fixed
This commit is contained in:
@@ -0,0 +1,8 @@
|
|||||||
|
<root>
|
||||||
|
<item
|
||||||
|
name='com.intellij.ui.classFilter.DebuggerClassFilterProvider java.util.List<com.intellij.ui.classFilter.ClassFilter> getFilters()'>
|
||||||
|
<annotation name='kotlin.jvm.KotlinSignature'>
|
||||||
|
<val name="value" val=""fun getFilters(): List<ClassFilter>?""/>
|
||||||
|
</annotation>
|
||||||
|
</item>
|
||||||
|
</root>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<root>
|
||||||
|
<item
|
||||||
|
name='com.intellij.xdebugger.settings.XDebuggerSettings java.util.Collection<? extends com.intellij.openapi.options.Configurable> createConfigurables(com.intellij.xdebugger.settings.DebuggerSettingsCategory)'>
|
||||||
|
<annotation name='kotlin.jvm.KotlinSignature'>
|
||||||
|
<val name="value"
|
||||||
|
val=""fun createConfigurables(category: DebuggerSettingsCategory): Collection<out Configurable?>""/>
|
||||||
|
</annotation>
|
||||||
|
</item>
|
||||||
|
</root>
|
||||||
@@ -429,3 +429,6 @@ kotlin.compiler.js.option.output.prefix=Output file &prefix:
|
|||||||
kotlin.compiler.js.option.output.postfix=Output file p&ostfix:
|
kotlin.compiler.js.option.output.postfix=Output file p&ostfix:
|
||||||
kotlin.compiler.js.option.output.prefix.browse.title=Choose output file prefix
|
kotlin.compiler.js.option.output.prefix.browse.title=Choose output file prefix
|
||||||
kotlin.compiler.js.option.output.postfix.browse.title=Choose output file postfix
|
kotlin.compiler.js.option.output.postfix.browse.title=Choose output file postfix
|
||||||
|
|
||||||
|
# Debugger
|
||||||
|
debugger.filter.ignore.internal.classes=Do not step into specific Kotlin classes
|
||||||
|
|||||||
@@ -334,6 +334,9 @@
|
|||||||
<debugger.positionManagerFactory implementation="org.jetbrains.jet.plugin.debugger.JetPositionManagerFactory"/>
|
<debugger.positionManagerFactory implementation="org.jetbrains.jet.plugin.debugger.JetPositionManagerFactory"/>
|
||||||
<debugger.codeFragmentFactory implementation="org.jetbrains.jet.plugin.debugger.evaluate.KotlinCodeFragmentFactory"/>
|
<debugger.codeFragmentFactory implementation="org.jetbrains.jet.plugin.debugger.evaluate.KotlinCodeFragmentFactory"/>
|
||||||
<debuggerEditorTextProvider language="jet" implementationClass="org.jetbrains.jet.plugin.debugger.KotlinEditorTextProvider"/>
|
<debuggerEditorTextProvider language="jet" implementationClass="org.jetbrains.jet.plugin.debugger.KotlinEditorTextProvider"/>
|
||||||
|
<debuggerClassFilterProvider implementation="org.jetbrains.jet.plugin.debugger.filter.KotlinDebuggerInternalClassesFilterProvider"/>
|
||||||
|
<xdebugger.settings implementation="org.jetbrains.jet.plugin.debugger.KotlinDebuggerSettings"/>
|
||||||
|
|
||||||
<codeInsight.implementMethod language="jet" implementationClass="org.jetbrains.jet.plugin.codeInsight.ImplementMethodsHandler"/>
|
<codeInsight.implementMethod language="jet" implementationClass="org.jetbrains.jet.plugin.codeInsight.ImplementMethodsHandler"/>
|
||||||
<codeInsight.overrideMethod language="jet" implementationClass="org.jetbrains.jet.plugin.codeInsight.OverrideMethodsHandler"/>
|
<codeInsight.overrideMethod language="jet" implementationClass="org.jetbrains.jet.plugin.codeInsight.OverrideMethodsHandler"/>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
|
||||||
|
import com.intellij.openapi.components.State
|
||||||
|
import com.intellij.openapi.components.Storage
|
||||||
|
import com.intellij.openapi.components.StoragePathMacros
|
||||||
|
import com.intellij.openapi.options.Configurable
|
||||||
|
import com.intellij.openapi.options.SimpleConfigurable
|
||||||
|
import com.intellij.openapi.util.Getter
|
||||||
|
import com.intellij.util.xmlb.XmlSerializerUtil
|
||||||
|
import com.intellij.xdebugger.settings.DebuggerSettingsCategory
|
||||||
|
import com.intellij.xdebugger.settings.XDebuggerSettings
|
||||||
|
|
||||||
|
import com.intellij.xdebugger.XDebuggerUtil
|
||||||
|
import com.intellij.ui.classFilter.ClassFilter
|
||||||
|
import com.intellij.debugger.settings.DebuggerSettings
|
||||||
|
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
|
||||||
|
|
||||||
|
class object {
|
||||||
|
public fun getInstance(): KotlinDebuggerSettings {
|
||||||
|
return XDebuggerUtil.getInstance()?.getDebuggerSettings(javaClass<KotlinDebuggerSettings>())!!
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun createConfigurables(category: DebuggerSettingsCategory): Collection<Configurable?> {
|
||||||
|
return when (category) {
|
||||||
|
DebuggerSettingsCategory.STEPPING ->
|
||||||
|
listOf(SimpleConfigurable.create(
|
||||||
|
"reference.idesettings.debugger.kotlin",
|
||||||
|
"Kotlin",
|
||||||
|
javaClass<KotlinSteppingConfigurableUi>(),
|
||||||
|
this))
|
||||||
|
else -> listOf()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getState() = this
|
||||||
|
override fun get() = this
|
||||||
|
|
||||||
|
override fun loadState(state: KotlinDebuggerSettings?) {
|
||||||
|
if (state != null) XmlSerializerUtil.copyBean<KotlinDebuggerSettings>(state, this)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.jet.plugin.debugger.KotlinSteppingConfigurableUi">
|
||||||
|
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
|
<margin top="0" left="0" bottom="0" right="0"/>
|
||||||
|
<constraints>
|
||||||
|
<xy x="20" y="20" width="500" height="400"/>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
<border type="none"/>
|
||||||
|
<children>
|
||||||
|
<component id="99d36" class="javax.swing.JCheckBox" binding="ignoreKotlinMethods">
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<selected value="false"/>
|
||||||
|
<text resource-bundle="org/jetbrains/jet/plugin/JetBundle" key="debugger.filter.ignore.internal.classes"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<vspacer id="c37da">
|
||||||
|
<constraints>
|
||||||
|
<grid row="1" column="0" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
</vspacer>
|
||||||
|
</children>
|
||||||
|
</grid>
|
||||||
|
</form>
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
|
||||||
|
import com.intellij.openapi.options.ConfigurableUi;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
public class KotlinSteppingConfigurableUi implements ConfigurableUi<KotlinDebuggerSettings> {
|
||||||
|
private JCheckBox ignoreKotlinMethods;
|
||||||
|
private JPanel myPanel;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset(@NotNull KotlinDebuggerSettings settings) {
|
||||||
|
boolean flag = settings.getDEBUG_DISABLE_KOTLIN_INTERNAL_CLASSES();
|
||||||
|
ignoreKotlinMethods.setSelected(flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isModified(@NotNull KotlinDebuggerSettings settings) {
|
||||||
|
return settings.getDEBUG_DISABLE_KOTLIN_INTERNAL_CLASSES() != ignoreKotlinMethods.isSelected();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void apply(@NotNull KotlinDebuggerSettings settings) {
|
||||||
|
settings.setDEBUG_DISABLE_KOTLIN_INTERNAL_CLASSES(ignoreKotlinMethods.isSelected());
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public JComponent getComponent() {
|
||||||
|
return myPanel;
|
||||||
|
}
|
||||||
|
}
|
||||||
+35
@@ -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.ui.classFilter.DebuggerClassFilterProvider
|
||||||
|
import com.intellij.ui.classFilter.ClassFilter
|
||||||
|
import org.jetbrains.jet.plugin.debugger.KotlinDebuggerSettings
|
||||||
|
|
||||||
|
private val FILTERS = listOf(
|
||||||
|
ClassFilter("kotlin.jvm*"),
|
||||||
|
ClassFilter("kotlin.reflect*"),
|
||||||
|
ClassFilter("kotlin.NoWhenBranchMatchedException"),
|
||||||
|
ClassFilter("kotlin.TypeCastException"),
|
||||||
|
ClassFilter("kotlin.KotlinNullPointerException")
|
||||||
|
)
|
||||||
|
|
||||||
|
public class KotlinDebuggerInternalClassesFilterProvider : DebuggerClassFilterProvider {
|
||||||
|
override fun getFilters(): List<ClassFilter>? {
|
||||||
|
return if (KotlinDebuggerSettings.getInstance().DEBUG_DISABLE_KOTLIN_INTERNAL_CLASSES) FILTERS else listOf()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
LineBreakpoint created at checkNotNull.kt:8
|
||||||
|
!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! checkNotNull.CheckNotNullPackage
|
||||||
|
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||||
|
checkNotNull.kt:7
|
||||||
|
MyJavaClass.java:11
|
||||||
|
checkNotNull.kt:7
|
||||||
|
checkNotNull.kt:8
|
||||||
|
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||||
|
|
||||||
|
Process finished with exit code 0
|
||||||
@@ -2,7 +2,7 @@ LineBreakpoint created at javaFun.kt:8
|
|||||||
!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! javaFun.JavaFunPackage
|
!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! javaFun.JavaFunPackage
|
||||||
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||||
javaFun.kt:7
|
javaFun.kt:7
|
||||||
MyJavaClass.java:4
|
MyJavaClass.java:6
|
||||||
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||||
|
|
||||||
Process finished with exit code 0
|
Process finished with exit code 0
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
LineBreakpoint created at npe.kt:7
|
||||||
|
!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! npe.NpePackage
|
||||||
|
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||||
|
npe.kt:6
|
||||||
|
npe.kt:9
|
||||||
|
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||||
|
|
||||||
|
Process finished with exit code 0
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
LineBreakpoint created at reflectKClass.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 !APP_PATH!\classes;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! reflectKClass.ReflectKClassPackage
|
||||||
|
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||||
|
reflectKClass.kt:4
|
||||||
|
reflectKClass.kt:5
|
||||||
|
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||||
|
|
||||||
|
Process finished with exit code 0
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package checkNotNull
|
||||||
|
|
||||||
|
import stepInto.MyJavaClass
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
val myClass = MyJavaClass()
|
||||||
|
//Breakpoint!
|
||||||
|
val a: String = myClass.testNotNullFun()
|
||||||
|
val b = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
// REPEAT: 3
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package npe
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
val a = null
|
||||||
|
try {
|
||||||
|
//Breakpoint!
|
||||||
|
a!!
|
||||||
|
}
|
||||||
|
catch (e: Exception) {
|
||||||
|
val b = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package reflectKClass
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
//Breakpoint!
|
||||||
|
val a = A()
|
||||||
|
val b = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
class A
|
||||||
@@ -1,7 +1,14 @@
|
|||||||
package stepInto;
|
package stepInto;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class MyJavaClass {
|
public class MyJavaClass {
|
||||||
public void testFun() {
|
public void testFun() {
|
||||||
int i = 1;
|
int i = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public String testNotNullFun() {
|
||||||
|
return "a";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,12 @@ public abstract class AbstractKotlinSteppingTest : KotlinDebuggerTestCase() {
|
|||||||
configureSettings(fileText)
|
configureSettings(fileText)
|
||||||
|
|
||||||
createDebugProcess(path)
|
createDebugProcess(path)
|
||||||
onBreakpoint { stepInto() }
|
val count = findStringWithPrefixes(fileText, "// REPEAT: ")?.toInt() ?: 1
|
||||||
|
|
||||||
|
for (i in 1..count) {
|
||||||
|
onBreakpoint { stepInto() }
|
||||||
|
}
|
||||||
|
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -181,6 +181,21 @@ public class KotlinSteppingTestGenerated extends AbstractKotlinSteppingTest {
|
|||||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/debugger/tinyApp/src/filters"), Pattern.compile("^(.+)\\.kt$"), true);
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/debugger/tinyApp/src/filters"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("checkNotNull.kt")
|
||||||
|
public void testCheckNotNull() throws Exception {
|
||||||
|
doStepIntoTest("idea/testData/debugger/tinyApp/src/filters/checkNotNull.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("npe.kt")
|
||||||
|
public void testNpe() throws Exception {
|
||||||
|
doStepIntoTest("idea/testData/debugger/tinyApp/src/filters/npe.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("reflectKClass.kt")
|
||||||
|
public void testReflectKClass() throws Exception {
|
||||||
|
doStepIntoTest("idea/testData/debugger/tinyApp/src/filters/reflectKClass.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("skipClassloader.kt")
|
@TestMetadata("skipClassloader.kt")
|
||||||
public void testSkipClassloader() throws Exception {
|
public void testSkipClassloader() throws Exception {
|
||||||
doStepIntoTest("idea/testData/debugger/tinyApp/src/filters/skipClassloader.kt");
|
doStepIntoTest("idea/testData/debugger/tinyApp/src/filters/skipClassloader.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user