Code Monkey home page Code Monkey logo

decembrist-kotlin2js-reflection's People

Contributors

decembrist-revolt avatar robstoll avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

decembrist-kotlin2js-reflection's Issues

Wondering if may be used for mocking library

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):

  • how mature is a plugin? production ready enough?
  • who supports it?
  • are there any known issues?
  • does it play well with multiplatform projects?
  • does it need to be applied to all modules separately or just finally at the bundling stage?
  • how big is additional space needed?
  • is it using Kotlin reflection API or separate API?
  • changing Kotlin metadata?
  • does it support Kotlin standard library classes?
  • fallback for native Javascript?

How to get the package name or the qualified name of a class?

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.

Casting error when building with gradle

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.