Debugger: check that file isn't shorter than breakpoint line (ex. after deleting some lines in file during debug)
This commit is contained in:
@@ -30,6 +30,7 @@ import com.intellij.openapi.progress.ProcessCanceledException
|
|||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
import com.intellij.openapi.vfs.CharsetToolkit
|
import com.intellij.openapi.vfs.CharsetToolkit
|
||||||
import com.intellij.psi.JavaPsiFacade
|
import com.intellij.psi.JavaPsiFacade
|
||||||
|
import com.intellij.psi.PsiDocumentManager
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
import com.intellij.psi.PsiFileFactory
|
import com.intellij.psi.PsiFileFactory
|
||||||
import com.intellij.psi.impl.PsiFileFactoryImpl
|
import com.intellij.psi.impl.PsiFileFactoryImpl
|
||||||
@@ -101,6 +102,13 @@ object KotlinEvaluationBuilder: EvaluatorBuilder {
|
|||||||
throw EvaluateExceptionUtil.createEvaluateException("Couldn't evaluate kotlin expression at $position")
|
throw EvaluateExceptionUtil.createEvaluateException("Couldn't evaluate kotlin expression at $position")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file)
|
||||||
|
if (document == null || document.getLineCount() < position.getLine()) {
|
||||||
|
throw EvaluateExceptionUtil.createEvaluateException(
|
||||||
|
"Couldn't evaluate kotlin expression: breakpoint is placed outside the file. " +
|
||||||
|
"It may happen when you've changed source file after starting a debug process.")
|
||||||
|
}
|
||||||
|
|
||||||
if (codeFragment.getContext() !is JetElement) {
|
if (codeFragment.getContext() !is JetElement) {
|
||||||
val attachments = arrayOf(attachmentByPsiFile(position.getFile()),
|
val attachments = arrayOf(attachmentByPsiFile(position.getFile()),
|
||||||
attachmentByPsiFile(codeFragment),
|
attachmentByPsiFile(codeFragment),
|
||||||
|
|||||||
Reference in New Issue
Block a user