Josh Friend
04/16/2024, 7:09 PMAnton Yalyshev [JB]
04/16/2024, 7:10 PMRoman Golyshev
04/16/2024, 7:34 PMJosh Friend
04/16/2024, 7:36 PM<depends>org.jetbrains.kotlin</depends>
which i am not sure is actually required for it to workRoman Golyshev
04/16/2024, 7:40 PMimport org.jetbrains.kotlin
Do you have any matches? If you do, what are the imported classes? Do they have prefixes like Kt
? Or maybe the word Descriptor
or BindingContext
or ResolutionFacade
in them?Josh Friend
04/16/2024, 7:49 PMorg.jetbrains.kotlin.idea.actions.JavaToKotlinAction
org.jetbrains.kotlin.idea.configuration.ExperimentalFeatures
org.jetbrains.kotlin.idea.core.getPackage
org.jetbrains.kotlin.idea.KotlinBundle
org.jetbrains.kotlin.j2k.getContainingClass
org.jetbrains.kotlin.j2k.getContainingMethod
org.jetbrains.kotlin.j2k.J2kConverterExtension
org.jetbrains.kotlin.psi.KtClass
org.jetbrains.kotlin.psi.KtNamedFunction
org.jetbrains.kotlin.psi.psiUtil.getParentOfType
org.jetbrains.kotlin.util.prefixIfNot
looks like KtClass
and KtNamedFunction
are used to provide some custom test running related actionsRoman Golyshev
04/16/2024, 8:20 PMJosh Friend
04/16/2024, 8:21 PM*.kt
first, then converts to kotlin so that at least some of the file history can be preserved in git-blameJosh Friend
04/16/2024, 8:23 PMJosh Friend
04/16/2024, 8:24 PM/**
* Given a [PsiElement], returns the containing method name once found (null otherwise).
*
* For Java, there's a convenience method named "getContainingMethod" that returns a PsiMethod.
* For Kotlin, there's no convenience, so we have use PsiTreeUtil to find the parent [KtNamedFunction].
*/
val PsiElement.containingMethodName: String?
get() = getContainingMethod()?.name ?: getParentOfType<KtNamedFunction>(false)?.name
/**
* Given a [PsiElement], returns a list of annotations mapped to a list of human readable strings.
* This method will only return the annotation name itself, even if the method is annotated with a
* fully-qualified annotation (i.e. will return "Test" for either "@Test" or "@org.junit.Test")
*
* Result will be mapped to a string representation of PsiAnnotations on a Java class, falling back to
* a string representation of KtAnnotationEntries on a Kotlin class. emptyList() if none are found.
*/
val PsiElement.annotationNames: List<String>
get() = getContainingMethod()?.annotations
?.map { it.qualifiedName.toString().substringAfterLast(".") }
?: getParentOfType<KtNamedFunction>(false)?.annotationEntries?.map { it.shortName.toString() }
?: emptyList()
/**
* Given a [PsiElement], returns the containing class name once found (null otherwise).
*
* For Java, return a [PsiClass] from a containing class.
* For Kotlin, walk up the tree to find the first instance of a [KtClass].
*/
val PsiElement.containingClassName: String?
get() = getContainingClass()?.name ?: getParentOfType<KtClass>(false)?.name
these are the majority of j2k imports, and its only used to retrieve class/method names for a right-click actionJosh Friend
04/16/2024, 8:26 PMJ2kConverterExtension.extension(useNewJ2k = ExperimentalFeatures.NewJ2k.isEnabled).doCheckBeforeConversion(project, module)
and aborts the conversion action if it failsRoman Golyshev
04/16/2024, 8:30 PMWhat is required of plugin authors to support K2 mode for intellij plugins?We do not have an “official” recommendation/API at the moment; however, we’re going to provide some migration guidance for the plugins authors in the foreseeable future Currently, any plugin which depends on Kotlin is disabled automatically to avoid exceptions and unexpected behaviours
Emil Kantis
05/21/2024, 5:20 PMhenrik
05/24/2024, 11:26 AM