Minor: find tested element with <caret> in ResolveElementCacheTest.kt

This commit is contained in:
Nikolay Krasko
2018-07-06 18:19:25 +03:00
parent 66e68fbb53
commit 90f1829fb8
2 changed files with 28 additions and 24 deletions
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.test.util
import com.intellij.psi.*
import com.intellij.psi.util.PsiTreeUtil
import com.intellij.testFramework.fixtures.CodeInsightTestFixture
import com.intellij.util.SmartFMap
import org.jetbrains.kotlin.psi.KtDeclaration
import org.jetbrains.kotlin.psi.KtPackageDirective
@@ -59,4 +60,9 @@ fun PsiFile.findElementsByCommentPrefix(prefix: String): Map<PsiElement, String>
fun findLastModifiedFile(dir: File, skipFile: (File) -> Boolean): File {
return dir.walk().filterNot(skipFile).maxBy { it.lastModified() }!!
}
}
val CodeInsightTestFixture.elementByOffset: PsiElement
get() {
return file.findElementAt(editor.caretModel.offset) ?: error("Can't find element at offset. Probably <caret> is missing.")
}