From ff0a06490860c320f77276d3afaf103463e0dfa4 Mon Sep 17 00:00:00 2001 From: Natalia Ukhorskaya Date: Tue, 14 Jul 2015 15:55:04 +0300 Subject: [PATCH] Debugger: Implement SourcePositionHighlighter to highlight lambda expressions during debug --- idea/src/META-INF/plugin.xml | 1 + .../KotlinSourcePositionHighlighter.kt | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 idea/src/org/jetbrains/kotlin/idea/debugger/KotlinSourcePositionHighlighter.kt diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index ffb92cec889..ec3e3fa9140 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -432,6 +432,7 @@ + diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinSourcePositionHighlighter.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinSourcePositionHighlighter.kt new file mode 100644 index 00000000000..0cddefb0198 --- /dev/null +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinSourcePositionHighlighter.kt @@ -0,0 +1,32 @@ +/* + * 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 + +import com.intellij.debugger.SourcePosition +import com.intellij.debugger.engine.SourcePositionHighlighter +import com.intellij.openapi.util.TextRange +import org.jetbrains.kotlin.psi.JetFunctionLiteral + +public class KotlinSourcePositionHighlighter: SourcePositionHighlighter() { + override fun getHighlightRange(sourcePosition: SourcePosition?): TextRange? { + val lambda = sourcePosition?.elementAt?.parent + if (lambda is JetFunctionLiteral) { + return lambda.textRange + } + return null + } +}