Minor cleanup: prefer actual body with return statement
This commit is contained in:
committed by
Dmitriy Novozhilov
parent
7e2c365b79
commit
1ba943eb4a
@@ -9,14 +9,16 @@ import com.intellij.psi.tree.IElementType
|
||||
import com.intellij.psi.tree.TokenSet
|
||||
import org.jetbrains.kotlin.fir.*
|
||||
|
||||
fun FirSourceElement.getChild(type: IElementType, index: Int = 0, depth: Int = -1): FirSourceElement? =
|
||||
getChild(setOf(type), index, depth)
|
||||
fun FirSourceElement.getChild(type: IElementType, index: Int = 0, depth: Int = -1): FirSourceElement? {
|
||||
return getChild(setOf(type), index, depth)
|
||||
}
|
||||
|
||||
fun FirSourceElement.getChild(types: TokenSet, index: Int = 0, depth: Int = -1): FirSourceElement? =
|
||||
getChild(types.types.toSet(), index, depth)
|
||||
fun FirSourceElement.getChild(types: TokenSet, index: Int = 0, depth: Int = -1): FirSourceElement? {
|
||||
return getChild(types.types.toSet(), index, depth)
|
||||
}
|
||||
|
||||
fun FirSourceElement.getChild(types: Set<IElementType>, index: Int = 0, depth: Int = -1): FirSourceElement? =
|
||||
when (this) {
|
||||
fun FirSourceElement.getChild(types: Set<IElementType>, index: Int = 0, depth: Int = -1): FirSourceElement? {
|
||||
return when (this) {
|
||||
is FirPsiSourceElement<*> -> {
|
||||
getChild(types, index, depth)
|
||||
}
|
||||
@@ -25,6 +27,7 @@ fun FirSourceElement.getChild(types: Set<IElementType>, index: Int = 0, depth: I
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
private fun FirPsiSourceElement<*>.getChild(types: Set<IElementType>, index: Int, depth: Int): FirSourceElement? {
|
||||
val visitor = PsiElementFinderByType(types, index, depth)
|
||||
|
||||
+9
-6
@@ -19,20 +19,23 @@ import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyAccessor
|
||||
import org.jetbrains.kotlin.fir.types.FirImplicitTypeRef
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
|
||||
internal fun isInsideExpectClass(containingClass: FirRegularClass, context: CheckerContext): Boolean =
|
||||
isInsideSpecificClass(containingClass, context) { klass -> klass.isExpect }
|
||||
internal fun isInsideExpectClass(containingClass: FirRegularClass, context: CheckerContext): Boolean {
|
||||
return isInsideSpecificClass(containingClass, context) { klass -> klass.isExpect }
|
||||
}
|
||||
|
||||
internal fun isInsideExternalClass(containingClass: FirRegularClass, context: CheckerContext): Boolean =
|
||||
isInsideSpecificClass(containingClass, context) { klass -> klass.isExternal }
|
||||
internal fun isInsideExternalClass(containingClass: FirRegularClass, context: CheckerContext): Boolean {
|
||||
return isInsideSpecificClass(containingClass, context) { klass -> klass.isExternal }
|
||||
}
|
||||
|
||||
// Note that the class that contains the currently visiting declaration will *not* be in the context's containing declarations *yet*.
|
||||
private inline fun isInsideSpecificClass(
|
||||
containingClass: FirRegularClass,
|
||||
context: CheckerContext,
|
||||
predicate: (FirRegularClass) -> Boolean
|
||||
): Boolean =
|
||||
predicate.invoke(containingClass) ||
|
||||
): Boolean {
|
||||
return predicate.invoke(containingClass) ||
|
||||
context.containingDeclarations.asReversed().any { it is FirRegularClass && predicate.invoke(it) }
|
||||
}
|
||||
|
||||
internal fun FirMemberDeclaration.isEffectivelyExpect(
|
||||
containingClass: FirRegularClass?,
|
||||
|
||||
Reference in New Issue
Block a user