Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Traitement des annotations en Kotlin
Search
Yves Kalume
February 24, 2023
Programming
1
20
Traitement des annotations en Kotlin
Yves Kalume
February 24, 2023
Tweet
Share
More Decks by Yves Kalume
See All by Yves Kalume
Designing scalable Compose APIs
yveskalume
1
86
Demystifying Memory Leaks in Android
yveskalume
2
93
L’essentiel de Git et Github en max 20 minutes
yveskalume
1
36
Modern Android Architecture
yveskalume
1
76
GDSC Alumni retour d’experience
yveskalume
0
19
Premier pas avec Jetpack compose
yveskalume
0
10
Flutter et Firebase
yveskalume
0
11
La modularisation dans le développement Android
yveskalume
0
12
Other Decks in Programming
See All in Programming
テストケースの名前はどうつけるべきか?
orgachem
PRO
0
130
数十万行のプロジェクトを Scala 2から3に完全移行した
xuwei_k
0
260
useSyncExternalStoreを使いまくる
ssssota
6
1k
.NET 9アプリをCGIとして レンタルサーバーで動かす
mayuki
1
770
17年周年のWebアプリケーションにTanStack Queryを導入する / Implementing TanStack Query in a 17th Anniversary Web Application
saitolume
0
250
rails statsで大解剖 🔍 “B/43流” のRailsの育て方を歴史とともに振り返ります
shoheimitani
2
930
Security_for_introducing_eBPF
kentatada
0
110
これが俺の”自分戦略” プロセスを楽しんでいこう! - Developers CAREER Boost 2024
niftycorp
PRO
0
190
range over funcの使い道と非同期N+1リゾルバーの夢 / about a range over func
mackee
0
110
KubeCon + CloudNativeCon NA 2024 Overviewat Kubernetes Meetup Tokyo #68 / amsy810_k8sjp68
masayaaoyama
0
240
短期間での新規プロダクト開発における「コスパの良い」Goのテスト戦略」 / kamakura.go
n3xem
2
160
42 best practices for Symfony, a decade later
tucksaun
1
180
Featured
See All Featured
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
A Tale of Four Properties
chriscoyier
157
23k
4 Signs Your Business is Dying
shpigford
181
21k
Music & Morning Musume
bryan
46
6.2k
Mobile First: as difficult as doing things right
swwweet
222
9k
Thoughts on Productivity
jonyablonski
67
4.4k
The Cost Of JavaScript in 2023
addyosmani
45
7k
Building an army of robots
kneath
302
44k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
Git: the NoSQL Database
bkeepers
PRO
427
64k
A designer walks into a library…
pauljervisheath
204
24k
Transcript
Traitement des annotations en Kotlin Yves Kalume (@kalumeyves) Développeur Mobile
@Composable fun HomeScreen() @OptIn(ExperimentalPagerApi.:class) @Devscat @SuppressWarnings("deprecation") @Deprecated @Configuration @Autowired Annotation
Processing
Une annotation permet au programmeur d'intégrer des informations supplémentaires dans
un code source.
Déclaration d’une annotation annotation class Devscast @Target(AnnotationTarget.CLASS) @Retention(AnnotationRetention.SOURCE)
Utilisation d’une annotation @Devscast class Foo(val id: Int, val name:
String) fun main() { val annotations = Foo.:class.annotations print(annotations) ./ [] une liste vide... pourquoi ? }
Kotlin Symbol Processing (KSP)
KSP en action dependencies { implementation("com.google.devtools.ksp:symbol-processing-api:1.8.10-1.0.9") }
src/main/resources/META-INF/services/
Fournisseur de processeur class DevscastProcessorProvider : SymbolProcessorProvider { override fun
create( environment: SymbolProcessorEnvironment ): SymbolProcessor { return DevscastProcessor(environment) } }
Processeur class ListedProcessor( private val environment: SymbolProcessorEnvironment ) : SymbolProcessor
{ override fun process(resolver: Resolver): List<KSAnnotated>{ ./ traitement } }
val result = resolver.getSymbolsWithAnnotation( Devscast.:class.qualifiedName.toString() ) ./ ... return result.filterNot
{ it.validate() }.toList()
Prêt à être utilisée
dependencies { implementation(project(":lib") ) ksp(project(":lib")) } android { kotlin {
sourceSets.debug { kotlin.srcDirs += 'build/generated/ksp/debug/kotlin' } sourceSets.release { kotlin.srcDirs += 'build/generated/ksp/release/kotlin' } } }
Merci ! Yves Kalume - @kalumeyves Développeur Mobile