Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class KSFunctionDeclarationImpl private constructor(internal val ktFunctionSymbo
}
}
KaSymbolLocation.TOP_LEVEL -> FunctionKind.TOP_LEVEL
KaSymbolLocation.PROPERTY -> FunctionKind.MEMBER
else -> throw IllegalStateException("Unexpected location ${ktFunctionSymbol.location}")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ open class FunctionKindProcessor : AbstractTestProcessor() {
override fun process(resolver: Resolver): List<KSAnnotated> {
fun KSFunctionDeclaration.pretty(): String {
val name = if (parentDeclaration != null) {
val className = parentDeclaration?.simpleName?.asString() ?: ""
val parentClass = when (val parent = parentDeclaration) {
// Fix for https://github.com/google/ksp/issues/2498. Must be removed after fixing the original issue.
is KSPropertyDeclaration -> parent.parentDeclaration
else -> parentDeclaration
}
val className = parentClass?.simpleName?.asString() ?: ""
if (className.isNotEmpty()) {
"$className.${simpleName.asString()}"
} else {
Expand Down
13 changes: 13 additions & 0 deletions test-utils/testData/api/functionKinds.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
// MyClass.suspendMethod: MEMBER
// MyInterface.method: MEMBER
// MyInterface.methodWithImpl: MEMBER
// MyInterfaceImplJava.<init>: MEMBER
// MyInterfaceImplJava.getProperty: MEMBER
// MyInterfaceImplJava.method: MEMBER
// topLevelMethod: TOP_LEVEL
// topLevelSuspendMethod: TOP_LEVEL
// END
Expand All @@ -51,6 +54,7 @@ class MyClass {
interface MyInterface {
fun method()
fun methodWithImpl() {}
val property: Int
}

// FILE: JavaClass.java
Expand All @@ -64,3 +68,12 @@ interface JavaInterface {
void methodInInterface();
static void staticMethodInInterface() {}
}

// FILE: MyInterfaceImplJava.java
class MyInterfaceImplJava implements MyInterface {
@Override
public void method() {}

@Override
public int getProperty() { return 0; }
}