Scratch: report errors at the correct line

^KT-24364 Fixed
This commit is contained in:
Natalia Selezneva
2018-05-14 14:50:23 +03:00
parent 6427c79110
commit 4ee41d502a
4 changed files with 14 additions and 3 deletions
@@ -207,9 +207,8 @@ class KtCompilingExecutor(file: ScratchFile) : ScratchExecutor(file) {
}
private fun ScratchFile.findExpression(psiElement: PsiElement): ScratchExpression? {
val lineStart = psiElement.getLineNumber(true)
val lineEnd = psiElement.getLineNumber(false)
return getExpressions().firstOrNull { it.lineStart == lineStart || it.lineEnd == lineEnd }
val elementLine = psiElement.getLineNumber()
return getExpressions().firstOrNull { elementLine in it.lineStart..it.lineEnd }
}
private fun ScratchFile.findExpression(lineStart: Int, lineEnd: Int): ScratchExpression? {
+4
View File
@@ -1,3 +1,7 @@
foo.forEach { // ERROR: Unresolved reference: foo; Cannot choose among the following candidates wi...
1 + 1
}
fun goo(a: String) { // ERROR: Unresolved reference: goo
super.goo(a)
}
+4
View File
@@ -1,3 +1,7 @@
foo.forEach {
1 + 1
}
fun goo(a: String) {
super.goo(a)
}
+4
View File
@@ -1,3 +1,7 @@
foo.forEach { // ERROR: error: unresolved reference: foo
1 + 1
}
fun goo(a: String) { // ERROR: error: unresolved reference: goo
super.goo(a)
}