[FIR] Report missing UNRESOLVED_IMPORT

#KT-54781 Fixed
This commit is contained in:
Kirill Rakhman
2023-03-29 13:52:44 +02:00
committed by Space Team
parent f18591ffef
commit 7dde3603b5
12 changed files with 47 additions and 17 deletions
@@ -1,4 +1,4 @@
import incorrect.directory.My
import <!UNRESOLVED_IMPORT!>incorrect<!>.directory.My
open class My : <!CYCLIC_INHERITANCE_HIERARCHY!>My<!>()
@@ -1,4 +1,4 @@
import incorrect.directory.Your
import <!UNRESOLVED_IMPORT!>incorrect<!>.directory.Your
typealias My = <!UNRESOLVED_REFERENCE!>incorrect.directory.My<!>
@@ -1,6 +1,6 @@
// IGNORE_REVERSED_RESOLVE
// Ignore reason: KT-57619
import my.println
import <!UNRESOLVED_IMPORT!>my<!>.println
enum class Order {
FIRST,
@@ -10,7 +10,7 @@ interface ByteArray {
package use
import test.*
import <!UNRESOLVED_IMPORT!>test<!>.*
interface My {
// Should be kotlin.ByteArray
@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.fir.analysis.checkers.syntax
import com.intellij.psi.tree.TokenSet
import org.jetbrains.kotlin.KtNodeTypes
import org.jetbrains.kotlin.KtSourceElement
import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
@@ -90,6 +91,11 @@ object FirUnresolvedInMiddleOfImportChecker : FirDeclarationSyntaxChecker<FirFil
return enumClass.collectEnumEntries().any { it.callableId.callableName == classId.shortClassName }
}
private fun KtSourceElement.dotQualifiedExpression() = getChild(KtNodeTypes.DOT_QUALIFIED_EXPRESSION, depth = 1)
private fun KtSourceElement.selectorExpression() = getChild(KtNodeTypes.REFERENCE_EXPRESSION, depth = 1, reverse = true)
private val IMPORT_PARENT_TOKEN_TYPES = TokenSet.create(KtNodeTypes.DOT_QUALIFIED_EXPRESSION, KtNodeTypes.REFERENCE_EXPRESSION)
private fun KtSourceElement.dotQualifiedExpression(): KtSourceElement? = getChild(IMPORT_PARENT_TOKEN_TYPES, depth = 1)
private fun KtSourceElement.selectorExpression(): KtSourceElement? =
takeIf { it.elementType == KtNodeTypes.REFERENCE_EXPRESSION }
?: getChild(KtNodeTypes.REFERENCE_EXPRESSION, depth = 1, reverse = true)
}