-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,60 @@ | ||
# composer-function-reference-diagnostic-suppressor | ||
## composer-function-reference-diagnostic-suppressor | ||
|
||
`COMPOSABLE_FUNCTION_REFERENCE` diagnostic suppression Kotlin compiler plugin | ||
`COMPOSABLE_FUNCTION_REFERENCE` diagnostic suppression Kotlin compiler plugin | ||
|
||
### Why? | ||
|
||
We can use `.name` on reflection via double-clone(`::`) the function to get the name of the function. | ||
|
||
```kotlin | ||
fun main() { | ||
println(::hi.name) | ||
} | ||
|
||
fun hi() { | ||
println("Say bye.") // hi | ||
} | ||
``` | ||
|
||
This can be useful to avoid hardcoding function names. | ||
However, in the case of a Composable function, reference access is blocked. | ||
|
||
![](assets/composable_function_reference.png) | ||
|
||
Because of this limitation, hardcoding is required to get the name of the Composable function. | ||
This Kotlin compiler plugin was developed to avoid this limitation. | ||
|
||
### Download | ||
|
||
| version | kotlin compatibility | | ||
|:-------------------------------------------------------------------------------:|:----------------------------------------------------------------------------------------:| | ||
| ![maven-central](https://img.shields.io/badge/maven--central-1.0.0-brightgreen) | ![kotlin-compatibility](https://img.shields.io/badge/kotlin%20compatibility-1.7.20-blue) | | ||
|
||
|
||
```kotlin | ||
repositories { | ||
maven { | ||
// we need a dev repository to keep the Compose Compiler always up-to-date. | ||
url = uri("https://maven.pkg.jetbrains.space/public/p/compose/dev") | ||
} | ||
} | ||
|
||
dependencies { | ||
add( | ||
org.jetbrains.kotlin.gradle.plugin.PLUGIN_CLASSPATH_CONFIGURATION_NAME, | ||
"land.sungbin:composable.reference.suppressor.plugin:${version}", | ||
) | ||
} | ||
``` | ||
|
||
### Caveats | ||
|
||
Currently, no IDE support. [[similar issue]](https://github.com/ZacSweers/redacted-compiler-plugin/issues/8) | ||
|
||
So if you try to reference a Composable function, you still get an error in the IDE. | ||
**But when you actually run the build, it succeeds.** | ||
|
||
### Copyright | ||
|
||
This project is licensed under the MIT License. | ||
Please refer to the [LICENSE file](LICENSE) for details. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.