Skip to content

Commit 286ad39

Browse files
sangyongchoiting-yuan
authored andcommitted
add else to when (google#869)
* add else to when * remove the return in return null (cherry picked from commit 504e184)
1 parent 3d4d873 commit 286ad39

File tree

1 file changed

+36
-35
lines changed
  • compiler-plugin/src/main/kotlin/com/google/devtools/ksp/symbol/impl

1 file changed

+36
-35
lines changed

Diff for: compiler-plugin/src/main/kotlin/com/google/devtools/ksp/symbol/impl/utils.kt

+36-35
Original file line numberDiff line numberDiff line change
@@ -235,41 +235,42 @@ internal fun ModuleClassResolver.resolveContainingClass(psiMethod: PsiMethod): C
235235
}
236236

237237
internal fun getInstanceForCurrentRound(node: KSNode): KSNode? {
238-
when (node.origin) {
239-
Origin.KOTLIN_LIB, Origin.JAVA_LIB -> return null
240-
}
241-
return when (node) {
242-
is KSClassDeclarationImpl -> KSClassDeclarationImpl.getCached(node.ktClassOrObject)
243-
is KSFileImpl -> KSFileImpl.getCached(node.file)
244-
is KSFunctionDeclarationImpl -> KSFunctionDeclarationImpl.getCached(node.ktFunction)
245-
is KSPropertyDeclarationImpl -> KSPropertyDeclarationImpl.getCached(node.ktProperty)
246-
is KSPropertyGetterImpl -> KSPropertyGetterImpl.getCached(node.ktPropertyAccessor)
247-
is KSPropertySetterImpl -> KSPropertySetterImpl.getCached(node.ktPropertyAccessor)
248-
is KSTypeAliasImpl -> KSTypeAliasImpl.getCached(node.ktTypeAlias)
249-
is KSTypeArgumentLiteImpl -> KSTypeArgumentLiteImpl.getCached(node.type, node.variance)
250-
is KSTypeArgumentKtImpl -> KSTypeArgumentKtImpl.getCached(node.ktTypeArgument)
251-
is KSTypeParameterImpl -> KSTypeParameterImpl.getCached(node.ktTypeParameter)
252-
is KSTypeReferenceImpl -> KSTypeReferenceImpl.getCached(node.ktTypeReference)
253-
is KSValueParameterImpl -> KSValueParameterImpl.getCached(node.ktParameter)
254-
is KSClassDeclarationJavaEnumEntryImpl -> KSClassDeclarationJavaEnumEntryImpl.getCached(node.psi)
255-
is KSClassDeclarationJavaImpl -> KSClassDeclarationJavaImpl.getCached(node.psi)
256-
is KSFileJavaImpl -> KSFileJavaImpl.getCached(node.psi)
257-
is KSFunctionDeclarationJavaImpl -> KSFunctionDeclarationJavaImpl.getCached(node.psi)
258-
is KSPropertyDeclarationJavaImpl -> KSPropertyDeclarationJavaImpl.getCached(node.psi)
259-
is KSTypeArgumentJavaImpl -> KSTypeArgumentJavaImpl.getCached(node.psi, node.parent)
260-
is KSTypeParameterJavaImpl -> KSTypeParameterJavaImpl.getCached(node.psi)
261-
is KSTypeReferenceJavaImpl ->
262-
KSTypeReferenceJavaImpl.getCached(node.psi, (node.parent as? KSAnnotated)?.getInstanceForCurrentRound())
263-
is KSValueParameterJavaImpl -> KSValueParameterJavaImpl.getCached(node.psi)
264-
is KSPropertyGetterSyntheticImpl -> KSPropertyGetterSyntheticImpl.getCached(node.ksPropertyDeclaration)
265-
is KSPropertySetterSyntheticImpl -> KSPropertySetterSyntheticImpl.getCached(node.ksPropertyDeclaration)
266-
is KSValueParameterSyntheticImpl -> KSPropertySetterImpl.getCached(node.owner as KtPropertyAccessor).parameter
267-
is KSAnnotationJavaImpl -> KSAnnotationJavaImpl.getCached(node.psi)
268-
is KSAnnotationImpl -> KSAnnotationImpl.getCached(node.ktAnnotationEntry)
269-
is KSClassifierReferenceJavaImpl -> KSClassifierReferenceJavaImpl.getCached(node.psi, node.parent)
270-
is KSValueArgumentJavaImpl ->
271-
KSValueArgumentJavaImpl.getCached(node.name, node.value, getInstanceForCurrentRound(node.parent!!))
272-
else -> null
238+
return when (node.origin) {
239+
Origin.KOTLIN_LIB, Origin.JAVA_LIB -> null
240+
else -> when (node) {
241+
is KSClassDeclarationImpl -> KSClassDeclarationImpl.getCached(node.ktClassOrObject)
242+
is KSFileImpl -> KSFileImpl.getCached(node.file)
243+
is KSFunctionDeclarationImpl -> KSFunctionDeclarationImpl.getCached(node.ktFunction)
244+
is KSPropertyDeclarationImpl -> KSPropertyDeclarationImpl.getCached(node.ktProperty)
245+
is KSPropertyGetterImpl -> KSPropertyGetterImpl.getCached(node.ktPropertyAccessor)
246+
is KSPropertySetterImpl -> KSPropertySetterImpl.getCached(node.ktPropertyAccessor)
247+
is KSTypeAliasImpl -> KSTypeAliasImpl.getCached(node.ktTypeAlias)
248+
is KSTypeArgumentLiteImpl -> KSTypeArgumentLiteImpl.getCached(node.type, node.variance)
249+
is KSTypeArgumentKtImpl -> KSTypeArgumentKtImpl.getCached(node.ktTypeArgument)
250+
is KSTypeParameterImpl -> KSTypeParameterImpl.getCached(node.ktTypeParameter)
251+
is KSTypeReferenceImpl -> KSTypeReferenceImpl.getCached(node.ktTypeReference)
252+
is KSValueParameterImpl -> KSValueParameterImpl.getCached(node.ktParameter)
253+
is KSClassDeclarationJavaEnumEntryImpl -> KSClassDeclarationJavaEnumEntryImpl.getCached(node.psi)
254+
is KSClassDeclarationJavaImpl -> KSClassDeclarationJavaImpl.getCached(node.psi)
255+
is KSFileJavaImpl -> KSFileJavaImpl.getCached(node.psi)
256+
is KSFunctionDeclarationJavaImpl -> KSFunctionDeclarationJavaImpl.getCached(node.psi)
257+
is KSPropertyDeclarationJavaImpl -> KSPropertyDeclarationJavaImpl.getCached(node.psi)
258+
is KSTypeArgumentJavaImpl -> KSTypeArgumentJavaImpl.getCached(node.psi, node.parent)
259+
is KSTypeParameterJavaImpl -> KSTypeParameterJavaImpl.getCached(node.psi)
260+
is KSTypeReferenceJavaImpl ->
261+
KSTypeReferenceJavaImpl.getCached(node.psi, (node.parent as? KSAnnotated)?.getInstanceForCurrentRound())
262+
is KSValueParameterJavaImpl -> KSValueParameterJavaImpl.getCached(node.psi)
263+
is KSPropertyGetterSyntheticImpl -> KSPropertyGetterSyntheticImpl.getCached(node.ksPropertyDeclaration)
264+
is KSPropertySetterSyntheticImpl -> KSPropertySetterSyntheticImpl.getCached(node.ksPropertyDeclaration)
265+
is KSValueParameterSyntheticImpl ->
266+
KSPropertySetterImpl.getCached(node.owner as KtPropertyAccessor).parameter
267+
is KSAnnotationJavaImpl -> KSAnnotationJavaImpl.getCached(node.psi)
268+
is KSAnnotationImpl -> KSAnnotationImpl.getCached(node.ktAnnotationEntry)
269+
is KSClassifierReferenceJavaImpl -> KSClassifierReferenceJavaImpl.getCached(node.psi, node.parent)
270+
is KSValueArgumentJavaImpl ->
271+
KSValueArgumentJavaImpl.getCached(node.name, node.value, getInstanceForCurrentRound(node.parent!!))
272+
else -> null
273+
}
273274
}
274275
}
275276

0 commit comments

Comments
 (0)