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
19
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
73
Demystifying Memory Leaks in Android
yveskalume
2
82
L’essentiel de Git et Github en max 20 minutes
yveskalume
1
32
Modern Android Architecture
yveskalume
1
75
GDSC Alumni retour d’experience
yveskalume
0
18
Premier pas avec Jetpack compose
yveskalume
0
8
Flutter et Firebase
yveskalume
0
9
La modularisation dans le développement Android
yveskalume
0
9
Other Decks in Programming
See All in Programming
コードレビューと私の過去と未来
jxmtst
0
280
モジュラモノリス、その前に / Modular monolith, before that
euglena1215
6
690
"noncopyable types" の使いどころについて考えてみた
andpad
0
150
CSC509 Lecture 04
javiergs
PRO
0
140
Real-time message handling and notifications with API Platform and Symfony
alli83
1
110
型付きで行うVSCode拡張機能開発 / VSCode Meetup #31
mazrean
0
240
Cloud Adoption Frameworkにみる組織とクラウド導入戦略(縮小版)
tomokusaba
1
210
Re:PandasAI:生成AIがデータ分析業務にもたらすパラダイムシフト【増補改訂版】
negi111111
1
1k
現場から考えるソフトウェアエンジニアリングの価値と実験
nomuson
1
130
CSC509 Lecture 03
javiergs
PRO
0
140
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
1.2k
UnJSで簡単に始めるCLIツール開発 / cli-tool-development-with-unjs
aoseyuu
2
300
Featured
See All Featured
Design by the Numbers
sachag
278
19k
Why You Should Never Use an ORM
jnunemaker
PRO
53
9k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
228
52k
Mobile First: as difficult as doing things right
swwweet
222
8.8k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
The Language of Interfaces
destraynor
154
24k
Imperfection Machines: The Place of Print at Facebook
scottboms
264
13k
The Mythical Team-Month
searls
218
43k
It's Worth the Effort
3n
183
27k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Learning to Love Humans: Emotional Interface Design
aarron
272
40k
A designer walks into a library…
pauljervisheath
202
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