搜索

PythonReactSEOPDF
GitHub Skill

add-ktnip-collector

Adds a new collector to the ktnip KSP processor. Use when implementing a new handler type (e.g. new annotation like @MyHandler), adding a collector for a new activity pattern, or extending the ktnip processor to collect additional annotated functions.

vendelieu☆ 244 仓库 Stars18 仓库 Forks

安装与使用

请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。

查看来源 ↗使用指南

技能说明

Add Ktnip Collector

Workflow

1. Create Annotation (if new)
  • Define annotation in telegram-bot module (annotations package)
  • Ensure it can be discovered via findAnnotationRecursively (meta-annotations supported)
2. Add Annotation Parser (if new annotation)
  • In AnnotationParser.kt: add parseMyAnnotation(arguments) returning parsed data
  • Use parseValueList, parseScopes patterns from existing parsers
3. Create Collector Class
4. Collector Implementation
  • Discovery: resolver.getAnnotatedFnSymbols(ctx.pkg, MyAnnotation::class)
  • Parse: function.annotations.findAnnotationRecursively(MyAnnotation::class)?.arguments
  • Metadata: extractActivityMetadata(function) (from BaseCollector)
  • Generate: generateAndRegisterActivity(function, metadata, ctx, parameters, updateType)
  • Register: ctx.loadFun.addStatement("registerX(%S, %L.id)", id, activityId)
5. Register in ActivityProcessor
  • Add to collectors list in ActivityProcessor.kt processPackage:
    • Order matters: BotCtxCollector, CommandCollector, InputCollector, CommonCollector, UpdateHandlerCollector, UnprocessedHandlerCollector, WizardCollector
6. ResolverExtensions (if needed)
  • getAnnotatedFnSymbols(pkg, MyAnnotation::class) works for any annotation (generic)
  • Custom discovery logic only if collecting non-function symbols
7. Add KSP Tests
  • Add test data in ktnip/src/jvmTest/resources/test-data/ (or extend DefaultHandlers.kt, WizardHandlers.kt, etc.)
  • Add runTest("test-data/YourFile.kt") in ProcessorTest.kt
  • Use /* G-EXPECT ... */ block for golden output checks (see add-ktnip-ksp-tests skill)

Reference

使用示例

查看来源仓库中的使用示例与配置说明。

查看来源 ↗

来源历史

收录时间
2026-03-11
索引更新时间
2026-03-11
Branch
main

收录与同步日期属于本站记录。源码修改历史请查看来源仓库。

GitHub ↗

chat Comments (0)

chat_bubble_outline

No comments yet. Be the first to share your thoughts!