toadzky
11/17/2024, 5:38 AM@Annotation
fun myFunction(...) {
CoroutineScope(Dispatchers.Default).async {
// insert original function statements here
}
}
but the plugin context can't find either the CoroutineScope(CoroutineContext)
factory function or the async
extension function (though it's not particularly clear how to find extension functions since there's no docs). when i try to have the symbol provider look up top level functions for the coroutines package, it finds others, but not those (and not launch
either).
what's the correct way to go about finding those function symbols so i can have my plugin invoke them? this is what i'm currently doing:
pluginContext.referenceFunctions(CallableId(
packageName = StandardNames.COROUTINES_PACKAGE_FQ_NAME,
callableName = Name.identifier("CoroutineScope")
))
ephemient
11/17/2024, 9:19 AMasync
, but you might as well use GlobalScope
instead of CoroutineScope(Dispatchers.Default)
, as that's what you're effectively doing alreadydmitriy.novozhilov
11/18/2024, 7:16 AMreferenceFunctions
should work, if the CoroutineScope
is present in the compile classpath
Can you reference it just from the code?dmitriy.novozhilov
11/18/2024, 7:16 AMtoadzky
11/18/2024, 3:27 PMtoadzky
11/18/2024, 3:28 PMCoroutineScope
and other functions defined in the same file are available with referenceFunctions
or referenceClasses
- it's only having problems with specific functions it seemsdmitriy.novozhilov
11/18/2024, 3:40 PMStandardNames.COROUTINES_PACKAGE_FQ_NAME
is a kotlin.coroutines
And the function you are looking for in kotlinx.coroutines
toadzky
11/18/2024, 3:40 PMdmitriy.novozhilov
11/18/2024, 3:44 PMkotlin.coroutines
package, and StandardNames.COROUTINES_PACKAGE_FQ_NAME
is used to refer to them
kotlinx.corountines
is just a library (with a different base package) which provides all its capabilities based on this minimal entities declared in the stdlibdmitriy.novozhilov
11/18/2024, 3:44 PMkotlinx.coroutines
librarytoadzky
11/18/2024, 3:46 PMdmitriy.novozhilov
11/18/2024, 3:48 PMStandardNames
and StandardClassIds
is about kotlin stdlib and java stdlibtoadzky
11/18/2024, 3:51 PMtoadzky
11/18/2024, 4:03 PMkotlinx.coroutines
instead of the standard name workedtoadzky
11/18/2024, 4:04 PMtoadzky
11/18/2024, 4:05 PMasync
and launch
functions.toadzky
11/18/2024, 4:06 PMdmitriy.novozhilov
11/18/2024, 4:14 PMis that by chance documented somewhere?This definitely isn't There are some docs, but not much Also there are some readmes in compiler modules