decembrist-revolt / decembrist-kotlin2js-reflection Goto Github PK
View Code? Open in Web Editor NEWPlugin for kotlin js annotation processing
Plugin for kotlin js annotation processing
Last time I was trying to port MockK to Kotlin JS, the problem was in Kotlin JS reflection. Just've trapped on a post in discuss about your plugin and thinking if I can give a second try to this direction.
Just a few questions (I didn't want to explore it myself, because hope will have correct and up-to-date answers through communication rather than code):
Can we use this library with kotlin("multiplatform")
plugin (build.gradle.kts
)?
Can we get the qualifiedName
or the package
of a class with this library?
For example, I've seen that we can do something like:
@JsName("_")
external val `_`: dynamic
fun checkAndReturnPackage(package_: String, class_: KClass<*>): String {
if (
class_.js.name
=== eval("get_js(Kotlin.getKClassFromExpression(_.$package_.${class_.simpleName})).name")
) {
return package_
}
throw IllegalArgumentException(
"""
The package $package_ isn't the correct package for the class $class_.
"""
)
}
fun checkExamplePackageAndReturnIt(): String {
val expectedPackage = "com.my.package.js"
if (
Example::class.js.name
=== `_`.com.my.package.js.Example::class.js.name
) {
return expectedPackage
}
throw IllegalArgumentException(
"""
The "$expectedPackage" isn't the correct package for the class "${Example::class.simpleName}".
"""
)
}
but I cannot really get the js package yet, so I was wondering if we can do something like this.
I am getting the following error when adding reflection to my project:
org.decembrist.parser.KotlinParser$CompanionObjectContext cannot be cast to org.decembrist.parser.KotlinParser$ClassDeclarationContext
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.