diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinPositionManager.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinPositionManager.kt index c5f6c09c535..3d7724fe499 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinPositionManager.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinPositionManager.kt @@ -133,20 +133,19 @@ class KotlinPositionManager(private val myDebugProcess: DebugProcess) : MultiReq -1 } - - if (lineNumber >= 0) { - val lambdaOrFunIfInside = getLambdaOrFunIfInside(location, psiFile as KtFile, lineNumber) - if (lambdaOrFunIfInside != null) { - return SourcePosition.createFromElement(lambdaOrFunIfInside.bodyExpression!!) - } - val property = getParameterIfInConstructor(location, psiFile, lineNumber) - if (property != null) { - return SourcePosition.createFromElement(property) - } - return SourcePosition.createFromLine(psiFile, lineNumber) + if (lineNumber < 0) { + throw NoDataException.INSTANCE } - throw NoDataException.INSTANCE + val lambdaOrFunIfInside = getLambdaOrFunIfInside(location, psiFile as KtFile, lineNumber) + if (lambdaOrFunIfInside != null) { + return SourcePosition.createFromElement(lambdaOrFunIfInside.bodyExpression!!) + } + val property = getParameterIfInConstructor(location, psiFile, lineNumber) + if (property != null) { + return SourcePosition.createFromElement(property) + } + return SourcePosition.createFromLine(psiFile, lineNumber) } private fun getParameterIfInConstructor(location: Location, file: KtFile, lineNumber: Int): KtParameter? { @@ -281,16 +280,14 @@ class KotlinPositionManager(private val myDebugProcess: DebugProcess) : MultiReq if (DumbService.getInstance(myDebugProcess.project).isDumb) { return emptyList() } - else { - val baseElement = getElementToCalculateClassName(element) ?: return emptyList() - return getOrComputeClassNames(baseElement) { - element -> - val file = element.readAction { it.containingFile as KtFile } - val isInLibrary = LibraryUtil.findLibraryEntry(file.virtualFile, file.project) != null - val typeMapper = KotlinDebuggerCaches.getOrCreateTypeMapper(element) - getInternalClassNameForElement(element, typeMapper, file, isInLibrary, withInlines) - } + val baseElement = getElementToCalculateClassName(element) ?: return emptyList() + return getOrComputeClassNames(baseElement) { element -> + val file = element.readAction { it.containingFile as KtFile } + val isInLibrary = LibraryUtil.findLibraryEntry(file.virtualFile, file.project) != null + val typeMapper = KotlinDebuggerCaches.getOrCreateTypeMapper(element) + + getInternalClassNameForElement(element, typeMapper, file, isInLibrary, withInlines) } } diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/extractFunctionForDebuggerUtil.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/extractFunctionForDebuggerUtil.kt index c18c9011d84..25f0cea5ae4 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/extractFunctionForDebuggerUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/extractFunctionForDebuggerUtil.kt @@ -22,8 +22,6 @@ import com.intellij.openapi.diagnostic.Attachment import com.intellij.openapi.util.Key import com.intellij.psi.PsiElement import com.intellij.psi.PsiFile -import com.intellij.psi.PsiManager -import com.intellij.psi.impl.PsiModificationTrackerImpl import com.intellij.util.ExceptionUtil import org.jetbrains.kotlin.idea.actions.internal.KotlinInternalMode import org.jetbrains.kotlin.idea.caches.resolve.analyze @@ -214,7 +212,7 @@ private fun getExpressionToAddDebugExpressionBefore(tmpFile: KtFile, contextElem fun shouldStop(el: PsiElement?, p: PsiElement?) = p is KtBlockExpression || el is KtDeclaration || el is KtFile - var elementAt = tmpFile.findContextElement() + val elementAt = tmpFile.findContextElement() var parent = elementAt?.parent if (shouldStop(elementAt, parent)) {