Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/thermondo/funlin

Kotlin Compiler Plugin for injecting function calls in the generated code using annotations.
https://github.com/thermondo/funlin

Last synced: 4 days ago
JSON representation

Kotlin Compiler Plugin for injecting function calls in the generated code using annotations.

Awesome Lists containing this project

README

        

## Funlin


### Installing

```kotlin
plugins {
//...
id("de.thermondo.funlin") version "latest_version"
}

```


### Setup

##### in your module `build.gradle.kts`

```kotlin
funlin {
enabled.set(true)
annoatation.set("TrackIt")
callableTargetPath.set("dev.thermondo.android.app.AnyObjectNameYouWant.anyFunctionName")
}
```

- Create your own `Annotation` and annotate your functions with it
- Create an `Object` that will be called when the function which is annotated with your `Annotation`
is called.

##### Annotation

```kotlin
@Retention(AnnotationRetention.BINARY)
@Target(AnnotationTarget.FUNCTION)
annotation class TrackIt
```

##### Object

```kotlin

package any.packagename.you.need

object AnyObjectNameYouWant {
// parameter names are not important, but the types or the order are important.
fun anyFunctionName(
name: String,
parent: String,
body: String,
args: Map,
) {
// your code here, logging/tracking events, etc.
}
}
```

> [!WARNING]
> Parameter names are not important, but the types or the order are important.

##### In your code

```kotlin
@TrackIt
fun anyFunctionName(
anyParameterName: Any,
) {
// your code here
}
```

> [!IMPORTANT]
> All arguments are supported as long as they give meaningful information when .toString() is called
> on them.
> If you want to use a custom object, make sure to override the `toString()` method for that object.

---

[Documentation](https://github.com/thermondo/funlin/blob/main/docs/docs.md)