Skip to content

Commit

Permalink
Remove psi based default value extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
chippmann committed Mar 4, 2023
1 parent 5b419e0 commit 775779e
Show file tree
Hide file tree
Showing 13 changed files with 1 addition and 386 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ data class RegisteredProperty(
val isLateinit: Boolean = false,
val isOverridee: Boolean = false,
val annotations: List<PropertyAnnotation> = emptyList(),
val defaultValueTemplateAndArgs: () -> Pair<String, Array<out Any>>? = { "null" to arrayOf() }
) : GodotJvmSourceElement {
val name: String = fqName.substringAfterLast(".")
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,12 @@ package godot.annotation.processor.compiler

import com.google.devtools.ksp.processing.Resolver
import org.jetbrains.kotlin.com.intellij.openapi.project.Project
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.BindingTrace

object CompilerDataProvider {
private var _project: Project? = null
val project: Project
get() = _project ?: throw UninitializedPropertyAccessException("CompilerDataProvider not yet initialized")

private var _bindingContext: BindingContext? = null
val bindingContext: BindingContext
get() = _bindingContext
?: throw UninitializedPropertyAccessException("CompilerDataProvider not yet initialized")

private var _srcDirs: List<String>? = null
val srcDirs: List<String>
get() = _srcDirs ?: throw UninitializedPropertyAccessException("CompilerDataProvider not yet initialized")
Expand All @@ -27,13 +20,6 @@ object CompilerDataProvider {
it.isAccessible = true
(it.get(resolver) as Project)
}
//get bindingContext through reflection
//the underlying compiler plugin of ksp is a AnalysisExtension which provides the bindingTrace (which holds the bindingContext) in the `doAnalysis` function
//here we just access it to make use of it in the psi based default value extraction
_bindingContext = resolver::class.java.getDeclaredField("bindingTrace").let {
it.isAccessible = true
(it.get(resolver) as BindingTrace).bindingContext
}
_srcDirs = sourceDirs
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 775779e

Please sign in to comment.