Skip to content

Commit

Permalink
use proper scope for getting declared static memberscope
Browse files Browse the repository at this point in the history
  • Loading branch information
neetopia authored and ting-yuan committed Apr 3, 2024
1 parent d87c083 commit 88b78d4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ internal inline fun <R> analyze(crossinline action: KtAnalysisSession.() -> R):
internal fun KtSymbolWithMembers.declarations(): Sequence<KSDeclaration> {
return analyze {
this@declarations.let {
it.getDeclaredMemberScope().getAllSymbols() + it.getStaticMemberScope().getAllSymbols()
it.getDeclaredMemberScope().getAllSymbols() + it.getStaticDeclaredMemberScope().getAllSymbols()
}.distinct().map { symbol ->
when (symbol) {
is KtNamedClassOrObjectSymbol -> KSClassDeclarationImpl.getCached(symbol)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package com.google.devtools.ksp.processor

import com.google.devtools.ksp.getClassDeclarationByName
import com.google.devtools.ksp.getDeclaredFunctions
import com.google.devtools.ksp.getDeclaredProperties
import com.google.devtools.ksp.isAbstract
import com.google.devtools.ksp.processing.Resolver
import com.google.devtools.ksp.symbol.KSAnnotated
Expand Down Expand Up @@ -100,6 +101,9 @@ class DefaultFunctionProcessor : AbstractTestProcessor() {
result.add("${aProperty.simpleName.asString()}: ${aProperty.isAbstract()}")
val D = resolver.getClassDeclarationByName("D")!!
D.getAllProperties().forEach { result.add("${it.simpleName.asString()}: isMutable: ${it.isMutable}") }
resolver.getClassDeclarationByName("JavaDerived")!!.getDeclaredProperties().forEach {
result.add(it.toString())
}
return emptyList()
}

Expand Down
10 changes: 10 additions & 0 deletions test-utils/testData/api/interfaceWithDefault.kt
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,13 @@ class D {

final int finalField;
}

// FILE: JavaBase.java

class JavaBase {
static String staticField;
}

// FILE: JavaDerived.java
class JavaDerived extends JavaBase {
}

0 comments on commit 88b78d4

Please sign in to comment.