Minor: invert if, clean up

This commit is contained in:
Nikolay Krasko
2016-07-15 19:00:55 +03:00
parent 097288d15f
commit 50e196dfb9
2 changed files with 19 additions and 24 deletions
@@ -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)
}
}
@@ -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)) {