Skip to content

Commit

Permalink
fix package name for library based symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
neetopia committed May 7, 2024
1 parent 486e131 commit 6b8a9ed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,19 @@ abstract class AbstractKSDeclarationImpl(val ktDeclarationSymbol: KtDeclarationS

override val packageName: KSName by lazy {
// source
containingFile?.packageName
if (origin == Origin.KOTLIN || origin == Origin.JAVA) {
containingFile!!.packageName
} else {
// top level declaration
?: when (ktDeclarationSymbol) {
when (ktDeclarationSymbol) {
is KtClassLikeSymbol -> ktDeclarationSymbol.classIdIfNonLocal?.packageFqName?.asString()
is KtCallableSymbol -> ktDeclarationSymbol.callableIdIfNonLocal?.packageName?.asString()
else -> null
}?.let { KSNameImpl.getCached(it) }
// null -> non top level declaration, find in parent
?: ktDeclarationSymbol.getContainingKSSymbol()?.packageName
?: throw IllegalStateException("failed to find package name for $this")
// null -> non top level declaration, find in parent
?: ktDeclarationSymbol.getContainingKSSymbol()?.packageName
?: throw IllegalStateException("failed to find package name for $this")
}
}

override val typeParameters: List<KSTypeParameter> by lazy {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ open class FunctionTypeProcessor : AbstractTestProcessor() {
val type = property.type.resolve()
val propertyName = property.simpleName.asString()
val typeName = type.declaration.simpleName.asString()
results.add("$propertyName: $typeName : ${type.isFunctionType}, ${type.isSuspendFunctionType}, ${type.declaration.qualifiedName!!.asString()}, ${type.declaration.packageName.asString()}")
results.add(
"$propertyName: $typeName : ${type.isFunctionType}, " +
"${type.isSuspendFunctionType}, ${type.declaration.qualifiedName!!.asString()}, " +
"${type.declaration.packageName.asString()}"
)
}
},
Unit
Expand Down

0 comments on commit 6b8a9ed

Please sign in to comment.