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
26
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
120
Demystifying Memory Leaks in Android
yveskalume
2
110
L’essentiel de Git et Github en max 20 minutes
yveskalume
1
43
Modern Android Architecture
yveskalume
1
89
GDSC Alumni retour d’experience
yveskalume
0
23
Premier pas avec Jetpack compose
yveskalume
0
14
Flutter et Firebase
yveskalume
0
16
La modularisation dans le développement Android
yveskalume
0
15
Other Decks in Programming
See All in Programming
Updates on MLS on Ruby (and maybe more)
sylph01
1
180
AIでLINEスタンプを作ってみた
eycjur
1
230
GitHubとGitLabとAWS CodePipelineでCI/CDを組み比べてみた
satoshi256kbyte
4
250
HTMLの品質ってなんだっけ? “HTMLクライテリア”の設計と実践
unachang113
4
2.9k
Testing Trophyは叫ばない
toms74209200
0
890
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
410
個人軟體時代
ethanhuang13
0
330
Oracle Database Technology Night 92 Database Connection control FAN-AC
oracle4engineer
PRO
1
470
パッケージ設計の黒魔術/Kyoto.go#63
lufia
3
440
プロポーザル駆動学習 / Proposal-Driven Learning
mackey0225
2
1.3k
そのAPI、誰のため? Androidライブラリ設計における利用者目線の実践テクニック
mkeeda
2
1.8k
はじめてのMaterial3 Expressive
ym223
2
900
Featured
See All Featured
Agile that works and the tools we love
rasmusluckow
330
21k
Git: the NoSQL Database
bkeepers
PRO
431
66k
Writing Fast Ruby
sferik
628
62k
Into the Great Unknown - MozCon
thekraken
40
2k
Code Review Best Practice
trishagee
71
19k
Visualization
eitanlees
148
16k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
9
810
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.9k
Building Better People: How to give real-time feedback that sticks.
wjessup
368
19k
Building a Modern Day E-commerce SEO Strategy
aleyda
43
7.6k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
15k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
30
9.7k
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