diff --git a/api/api.base b/api/api.base index 3a7ec0ec91..b990727188 100644 --- a/api/api.base +++ b/api/api.base @@ -401,7 +401,7 @@ package com.google.devtools.ksp.symbol { method @NonNull public String getShortName(); } - public interface KSNode { + public sealed interface KSNode { method public R accept(@NonNull com.google.devtools.ksp.symbol.KSVisitor visitor, D data); method @NonNull public com.google.devtools.ksp.symbol.Location getLocation(); method @NonNull public com.google.devtools.ksp.symbol.Origin getOrigin(); diff --git a/api/src/main/kotlin/com/google/devtools/ksp/symbol/KSNode.kt b/api/src/main/kotlin/com/google/devtools/ksp/symbol/KSNode.kt index 08e2d7df2e..89e7b56ed7 100644 --- a/api/src/main/kotlin/com/google/devtools/ksp/symbol/KSNode.kt +++ b/api/src/main/kotlin/com/google/devtools/ksp/symbol/KSNode.kt @@ -19,7 +19,7 @@ package com.google.devtools.ksp.symbol /** * Base class of every visitable program elements. */ -interface KSNode { +sealed interface KSNode { val origin: Origin val location: Location val parent: KSNode? diff --git a/compiler-plugin/src/main/kotlin/com/google/devtools/ksp/processing/impl/ResolverImpl.kt b/compiler-plugin/src/main/kotlin/com/google/devtools/ksp/processing/impl/ResolverImpl.kt index f79e6914dc..9d8c24a28f 100644 --- a/compiler-plugin/src/main/kotlin/com/google/devtools/ksp/processing/impl/ResolverImpl.kt +++ b/compiler-plugin/src/main/kotlin/com/google/devtools/ksp/processing/impl/ResolverImpl.kt @@ -627,6 +627,11 @@ class ResolverImpl( resolverContext = resolverContext .childForClassOrPackage(resolveJavaDeclaration(e.psi) as ClassDescriptor, JavaClassImpl(e.psi)) } + is KSClassDeclaration, is KSFunctionDeclaration, is KSPropertyDeclaration, is KSTypeAlias, + is KSTypeParameter, is KSFile, is KSPropertyGetter, is KSPropertySetter, is KSTypeArgument, + is KSTypeReference, is KSValueArgument, is KSValueParameter, is KSAnnotation, is KSCallableReference, + is KSClassifierReference, is KSDefNonNullReference, is KSDynamicReference, is KSParenthesizedReference, + -> Unit } } return if (javaType is JavaArrayTypeImpl) diff --git a/compiler-plugin/src/main/kotlin/com/google/devtools/ksp/symbol/impl/binary/KSNodeDescriptorImpl.kt b/compiler-plugin/src/main/kotlin/com/google/devtools/ksp/symbol/impl/binary/KSNodeDescriptorImpl.kt deleted file mode 100644 index 0c82f750fd..0000000000 --- a/compiler-plugin/src/main/kotlin/com/google/devtools/ksp/symbol/impl/binary/KSNodeDescriptorImpl.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.google.devtools.ksp.symbol.impl.binary - -import com.google.devtools.ksp.symbol.KSNode -import com.google.devtools.ksp.symbol.Location -import com.google.devtools.ksp.symbol.NonExistLocation - -abstract class KSNodeDescriptorImpl(override val parent: KSNode?) : KSNode { - override val location: Location = NonExistLocation -} diff --git a/compiler-plugin/src/main/kotlin/com/google/devtools/ksp/symbol/impl/java/KSNodeJavaImpl.kt b/compiler-plugin/src/main/kotlin/com/google/devtools/ksp/symbol/impl/java/KSNodeJavaImpl.kt deleted file mode 100644 index 860fb5fa04..0000000000 --- a/compiler-plugin/src/main/kotlin/com/google/devtools/ksp/symbol/impl/java/KSNodeJavaImpl.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.google.devtools.ksp.symbol.impl.java - -import com.google.devtools.ksp.symbol.KSNode -import com.google.devtools.ksp.symbol.Location -import com.google.devtools.ksp.symbol.impl.toLocation -import com.intellij.psi.PsiElement - -abstract class KSNodeJavaImpl(private val psi: PsiElement, override val parent: KSNode?) : KSNode { - override val location: Location by lazy { - psi.toLocation() - } -} diff --git a/compiler-plugin/src/main/kotlin/com/google/devtools/ksp/symbol/impl/kotlin/KSNodeKtImpl.kt b/compiler-plugin/src/main/kotlin/com/google/devtools/ksp/symbol/impl/kotlin/KSNodeKtImpl.kt deleted file mode 100644 index 8c44b1453f..0000000000 --- a/compiler-plugin/src/main/kotlin/com/google/devtools/ksp/symbol/impl/kotlin/KSNodeKtImpl.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.google.devtools.ksp.symbol.impl.kotlin - -import com.google.devtools.ksp.symbol.KSNode -import com.google.devtools.ksp.symbol.Location -import com.google.devtools.ksp.symbol.impl.toLocation -import org.jetbrains.kotlin.psi.KtElement - -abstract class KSNodeKtImpl(private val element: KtElement) : KSNode { - override val location: Location by lazy { - element.toLocation() - } -}