FIR: Fix visitors/transformers and testData
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
package org.jetbrains.kotlin.fir
|
||||
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFile
|
||||
import org.jetbrains.kotlin.fir.types.ConeClassErrorType
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinErrorType
|
||||
@@ -71,12 +72,30 @@ fun doFirResolveTestBench(
|
||||
|
||||
firFiles.forEach {
|
||||
it.accept(object : FirVisitorVoid() {
|
||||
|
||||
fun reportProblem(problem: String, psi: PsiElement) {
|
||||
val document = try {
|
||||
fileDocumentManager.getDocument(psi.containingFile.virtualFile)
|
||||
} catch (t: Throwable) {
|
||||
throw Exception("for file ${psi.containingFile}", t)
|
||||
}
|
||||
val line = (document?.getLineNumber(psi.startOffset) ?: 0)
|
||||
val char = psi.startOffset - (document?.getLineStartOffset(line) ?: 0)
|
||||
val report = "u: ${psi.containingFile?.virtualFile?.path}: (${line + 1}:$char): $problem"
|
||||
errorTypesReports[problem] = report
|
||||
}
|
||||
override fun visitElement(element: FirElement) {
|
||||
element.acceptChildren(this)
|
||||
}
|
||||
|
||||
override fun visitTypeRef(typeRef: FirTypeRef) {
|
||||
unresolvedTypes++
|
||||
|
||||
if (typeRef.psi != null) {
|
||||
val psi = typeRef.psi!!
|
||||
val problem = typeRef.renderWithType()
|
||||
reportProblem(problem, psi)
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitResolvedTypeRef(resolvedTypeRef: FirResolvedTypeRef) {
|
||||
@@ -88,16 +107,7 @@ fun doFirResolveTestBench(
|
||||
} else {
|
||||
val psi = resolvedTypeRef.psi!!
|
||||
val problem = "$type with psi `${psi.text}`"
|
||||
val document = try {
|
||||
fileDocumentManager.getDocument(psi.containingFile.virtualFile)
|
||||
} catch (t: Throwable) {
|
||||
throw Exception("for file ${psi.containingFile}", t)
|
||||
}
|
||||
val line = document?.getLineNumber(psi.startOffset) ?: 0
|
||||
val char = psi.startOffset - (document?.getLineStartOffset(line) ?: 0)
|
||||
val report = "e: ${psi.containingFile?.virtualFile?.path}: ($line:$char): $problem"
|
||||
errorTypesReports[problem] = report
|
||||
errorTypes++
|
||||
reportProblem(problem, psi)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user