Simplify FirDelegationInInterfaceChecker
This commit is contained in:
+5
-20
@@ -5,13 +5,10 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.fir.analysis.checkers.declaration
|
package org.jetbrains.kotlin.fir.analysis.checkers.declaration
|
||||||
|
|
||||||
import com.intellij.lang.LighterASTNode
|
|
||||||
import com.intellij.util.diff.FlyweightCapableTreeStructure
|
|
||||||
import org.jetbrains.kotlin.KtNodeTypes
|
import org.jetbrains.kotlin.KtNodeTypes
|
||||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||||
import org.jetbrains.kotlin.fir.FirSourceElement
|
import org.jetbrains.kotlin.fir.FirSourceElement
|
||||||
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
|
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
|
||||||
import org.jetbrains.kotlin.fir.analysis.checkers.getChildren
|
|
||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter
|
||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirClass
|
import org.jetbrains.kotlin.fir.declarations.FirClass
|
||||||
@@ -23,23 +20,11 @@ object FirDelegationInInterfaceChecker : FirMemberDeclarationChecker() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
declaration.source?.findSuperTypeDelegation()?.let {
|
for (superTypeRef in declaration.superTypeRefs) {
|
||||||
reporter.report(declaration.superTypeRefs.getOrNull(it)?.source)
|
val source = superTypeRef.source ?: continue
|
||||||
}
|
if (source.treeStructure.getParent(source.lighterASTNode)?.tokenType == KtNodeTypes.DELEGATED_SUPER_TYPE_ENTRY) {
|
||||||
}
|
reporter.report(source)
|
||||||
|
}
|
||||||
private fun FirSourceElement.findSuperTypeDelegation(): Int =
|
|
||||||
lighterASTNode.findSuperTypeDelegation(treeStructure)
|
|
||||||
|
|
||||||
private fun LighterASTNode.findSuperTypeDelegation(tree: FlyweightCapableTreeStructure<LighterASTNode>): Int {
|
|
||||||
val children = getChildren(tree)
|
|
||||||
return if (children.isNotEmpty()) {
|
|
||||||
children.find { it?.tokenType == KtNodeTypes.SUPER_TYPE_LIST }
|
|
||||||
?.getChildren(tree)
|
|
||||||
?.indexOfFirst { it?.tokenType == KtNodeTypes.DELEGATED_SUPER_TYPE_ENTRY }
|
|
||||||
?: -1
|
|
||||||
} else {
|
|
||||||
-1
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user