From f7e35fab42391c984e98af0894c8ac44cb598e57 Mon Sep 17 00:00:00 2001 From: Natalia Ukhorskaya Date: Tue, 14 Jul 2015 16:36:37 +0300 Subject: [PATCH] Minor: extract class --- .../stepping/KotlinBasicStepMethodFilter.kt | 44 +++++++++++++++++++ .../stepping/KotlinSmartStepIntoHandler.kt | 18 -------- 2 files changed, 44 insertions(+), 18 deletions(-) create mode 100644 idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinBasicStepMethodFilter.kt diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinBasicStepMethodFilter.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinBasicStepMethodFilter.kt new file mode 100644 index 00000000000..bb15ab24135 --- /dev/null +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinBasicStepMethodFilter.kt @@ -0,0 +1,44 @@ +/* + * 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.stepping + +import com.intellij.debugger.engine.BasicStepMethodFilter +import com.intellij.debugger.engine.DebugProcessImpl +import com.sun.jdi.Location +import org.jetbrains.kotlin.idea.debugger.MockSourcePosition +import org.jetbrains.kotlin.idea.util.application.runReadAction +import org.jetbrains.kotlin.psi.JetFile + +public class KotlinBasicStepMethodFilter( + val stepTarget: KotlinMethodSmartStepTarget +): BasicStepMethodFilter(stepTarget.getMethod(), stepTarget.getCallingExpressionLines()) { + override fun locationMatches(process: DebugProcessImpl, location: Location): Boolean { + if (super.locationMatches(process, location)) return true + + val containingFile = runReadAction { stepTarget.resolvedElement.getContainingFile() } + if (containingFile !is JetFile) return false + + val positionManager = process.getPositionManager() ?: return false + + val classes = positionManager.getAllClasses(MockSourcePosition(_file = containingFile, _elementAt = stepTarget.resolvedElement)) + + val method = location.method() + return stepTarget.getMethod().getName() == method.name() && + myTargetMethodSignature?.getName(process) == method.signature() && + classes.contains(location.declaringType()) + } +} \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSmartStepIntoHandler.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSmartStepIntoHandler.kt index 7d6c71fbbdb..b4ecdd03891 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSmartStepIntoHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSmartStepIntoHandler.kt @@ -182,22 +182,4 @@ public class KotlinSmartStepIntoHandler : JvmSmartStepIntoHandler() { } return super.createMethodFilter(stepTarget) } - - class KotlinBasicStepMethodFilter(val stepTarget: KotlinMethodSmartStepTarget): BasicStepMethodFilter(stepTarget.getMethod(), stepTarget.getCallingExpressionLines()) { - override fun locationMatches(process: DebugProcessImpl, location: Location): Boolean { - if (super.locationMatches(process, location)) return true - - val containingFile = runReadAction { stepTarget.resolvedElement.getContainingFile() } - if (containingFile !is JetFile) return false - - val positionManager = process.getPositionManager() ?: return false - - val classes = positionManager.getAllClasses(MockSourcePosition(_file = containingFile, _elementAt = stepTarget.resolvedElement)) - - val method = location.method() - return stepTarget.getMethod().getName() == method.name() && - myTargetMethodSignature?.getName(process) == method.signature() && - classes.contains(location.declaringType()) - } - } }