Delete/Move: Delete entire file when deleting top-level class or object and no other top-level declarations are present. Ask the user confirmation if deletion if caused by the Move refactoring

#KT-8033 Fixed
This commit is contained in:
Alexey Sedunov
2015-06-15 16:17:57 +03:00
parent e1e818858e
commit dda271d38d
4 changed files with 23 additions and 16 deletions
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.idea.core
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiWhiteSpace
import com.intellij.psi.impl.source.codeStyle.CodeEditUtil
import com.intellij.psi.util.PsiTreeUtil
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil
@@ -148,4 +149,8 @@ private fun deleteElementWithDelimiters(element: PsiElement) {
val parent = element.getParent()
parent.deleteChildRange(from, to)
}
public fun PsiElement.deleteSingle() {
CodeEditUtil.removeChild(getParent()?.getNode() ?: return, getNode() ?: return)
}