Skip to content

Commit

Permalink
add else to when (#869)
Browse files Browse the repository at this point in the history
* add else to when
* remove the return in return null

(cherry picked from commit 504e184)
  • Loading branch information
sangyongchoi authored and KSP Auto Pick committed Mar 15, 2022
1 parent 39a4263 commit cbd02fc
Showing 1 changed file with 36 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,41 +235,42 @@ internal fun ModuleClassResolver.resolveContainingClass(psiMethod: PsiMethod): C
}

internal fun getInstanceForCurrentRound(node: KSNode): KSNode? {
when (node.origin) {
Origin.KOTLIN_LIB, Origin.JAVA_LIB -> return null
}
return when (node) {
is KSClassDeclarationImpl -> KSClassDeclarationImpl.getCached(node.ktClassOrObject)
is KSFileImpl -> KSFileImpl.getCached(node.file)
is KSFunctionDeclarationImpl -> KSFunctionDeclarationImpl.getCached(node.ktFunction)
is KSPropertyDeclarationImpl -> KSPropertyDeclarationImpl.getCached(node.ktProperty)
is KSPropertyGetterImpl -> KSPropertyGetterImpl.getCached(node.ktPropertyAccessor)
is KSPropertySetterImpl -> KSPropertySetterImpl.getCached(node.ktPropertyAccessor)
is KSTypeAliasImpl -> KSTypeAliasImpl.getCached(node.ktTypeAlias)
is KSTypeArgumentLiteImpl -> KSTypeArgumentLiteImpl.getCached(node.type, node.variance)
is KSTypeArgumentKtImpl -> KSTypeArgumentKtImpl.getCached(node.ktTypeArgument)
is KSTypeParameterImpl -> KSTypeParameterImpl.getCached(node.ktTypeParameter)
is KSTypeReferenceImpl -> KSTypeReferenceImpl.getCached(node.ktTypeReference)
is KSValueParameterImpl -> KSValueParameterImpl.getCached(node.ktParameter)
is KSClassDeclarationJavaEnumEntryImpl -> KSClassDeclarationJavaEnumEntryImpl.getCached(node.psi)
is KSClassDeclarationJavaImpl -> KSClassDeclarationJavaImpl.getCached(node.psi)
is KSFileJavaImpl -> KSFileJavaImpl.getCached(node.psi)
is KSFunctionDeclarationJavaImpl -> KSFunctionDeclarationJavaImpl.getCached(node.psi)
is KSPropertyDeclarationJavaImpl -> KSPropertyDeclarationJavaImpl.getCached(node.psi)
is KSTypeArgumentJavaImpl -> KSTypeArgumentJavaImpl.getCached(node.psi, node.parent)
is KSTypeParameterJavaImpl -> KSTypeParameterJavaImpl.getCached(node.psi)
is KSTypeReferenceJavaImpl ->
KSTypeReferenceJavaImpl.getCached(node.psi, (node.parent as? KSAnnotated)?.getInstanceForCurrentRound())
is KSValueParameterJavaImpl -> KSValueParameterJavaImpl.getCached(node.psi)
is KSPropertyGetterSyntheticImpl -> KSPropertyGetterSyntheticImpl.getCached(node.ksPropertyDeclaration)
is KSPropertySetterSyntheticImpl -> KSPropertySetterSyntheticImpl.getCached(node.ksPropertyDeclaration)
is KSValueParameterSyntheticImpl -> KSPropertySetterImpl.getCached(node.owner as KtPropertyAccessor).parameter
is KSAnnotationJavaImpl -> KSAnnotationJavaImpl.getCached(node.psi)
is KSAnnotationImpl -> KSAnnotationImpl.getCached(node.ktAnnotationEntry)
is KSClassifierReferenceJavaImpl -> KSClassifierReferenceJavaImpl.getCached(node.psi, node.parent)
is KSValueArgumentJavaImpl ->
KSValueArgumentJavaImpl.getCached(node.name, node.value, getInstanceForCurrentRound(node.parent!!))
else -> null
return when (node.origin) {
Origin.KOTLIN_LIB, Origin.JAVA_LIB -> null
else -> when (node) {
is KSClassDeclarationImpl -> KSClassDeclarationImpl.getCached(node.ktClassOrObject)
is KSFileImpl -> KSFileImpl.getCached(node.file)
is KSFunctionDeclarationImpl -> KSFunctionDeclarationImpl.getCached(node.ktFunction)
is KSPropertyDeclarationImpl -> KSPropertyDeclarationImpl.getCached(node.ktProperty)
is KSPropertyGetterImpl -> KSPropertyGetterImpl.getCached(node.ktPropertyAccessor)
is KSPropertySetterImpl -> KSPropertySetterImpl.getCached(node.ktPropertyAccessor)
is KSTypeAliasImpl -> KSTypeAliasImpl.getCached(node.ktTypeAlias)
is KSTypeArgumentLiteImpl -> KSTypeArgumentLiteImpl.getCached(node.type, node.variance)
is KSTypeArgumentKtImpl -> KSTypeArgumentKtImpl.getCached(node.ktTypeArgument)
is KSTypeParameterImpl -> KSTypeParameterImpl.getCached(node.ktTypeParameter)
is KSTypeReferenceImpl -> KSTypeReferenceImpl.getCached(node.ktTypeReference)
is KSValueParameterImpl -> KSValueParameterImpl.getCached(node.ktParameter)
is KSClassDeclarationJavaEnumEntryImpl -> KSClassDeclarationJavaEnumEntryImpl.getCached(node.psi)
is KSClassDeclarationJavaImpl -> KSClassDeclarationJavaImpl.getCached(node.psi)
is KSFileJavaImpl -> KSFileJavaImpl.getCached(node.psi)
is KSFunctionDeclarationJavaImpl -> KSFunctionDeclarationJavaImpl.getCached(node.psi)
is KSPropertyDeclarationJavaImpl -> KSPropertyDeclarationJavaImpl.getCached(node.psi)
is KSTypeArgumentJavaImpl -> KSTypeArgumentJavaImpl.getCached(node.psi, node.parent)
is KSTypeParameterJavaImpl -> KSTypeParameterJavaImpl.getCached(node.psi)
is KSTypeReferenceJavaImpl ->
KSTypeReferenceJavaImpl.getCached(node.psi, (node.parent as? KSAnnotated)?.getInstanceForCurrentRound())
is KSValueParameterJavaImpl -> KSValueParameterJavaImpl.getCached(node.psi)
is KSPropertyGetterSyntheticImpl -> KSPropertyGetterSyntheticImpl.getCached(node.ksPropertyDeclaration)
is KSPropertySetterSyntheticImpl -> KSPropertySetterSyntheticImpl.getCached(node.ksPropertyDeclaration)
is KSValueParameterSyntheticImpl ->
KSPropertySetterImpl.getCached(node.owner as KtPropertyAccessor).parameter
is KSAnnotationJavaImpl -> KSAnnotationJavaImpl.getCached(node.psi)
is KSAnnotationImpl -> KSAnnotationImpl.getCached(node.ktAnnotationEntry)
is KSClassifierReferenceJavaImpl -> KSClassifierReferenceJavaImpl.getCached(node.psi, node.parent)
is KSValueArgumentJavaImpl ->
KSValueArgumentJavaImpl.getCached(node.name, node.value, getInstanceForCurrentRound(node.parent!!))
else -> null
}
}
}

Expand Down

0 comments on commit cbd02fc

Please sign in to comment.