Commit c3ae26e
feat(parsers): add Kotlin language support
Handles .kt and .kts files using tree-sitter-language-pack's kotlin
grammar (transitive dep, no new installs). Extracts:
- Top-level functions (fun main, suspend fun fetch, ...)
- Classes, interfaces, data classes, objects, enum classes
- Methods inside class_body and enum_class_body
- Parameters from function_value_parameters and their user_type /
type_identifier / nullable_type annotations
- Return types from the type node following `:` on the signature
- Imports — captured as graph.dependencies
Entrypoint detectors for Kotlin:
- Spring MVC / WebFlux annotations (@GetMapping, @PostMapping, etc.)
reusing the existing Java detector since the annotations are identical
across the two languages.
- Android component lifecycle methods: onCreate, onStart, onResume,
onNewIntent, onActivityResult, onReceive, onBind, onHandleIntent.
These are attacker-reachable when the component is exported — we
over-detect on purpose and rely on the override file to tighten.
Known gap (parallel to Swift, documented in parser docstring): `throw`
statements share their AST node type with `return`/`break`/`continue`
via `jump_expression`, so exception-type capture needs a Kotlin-specific
walk filtered by the leading `throw` token. Deferred.
14 new tests: Kotlin parser, Kotlin entrypoint detection. README
supported-languages and framework-coverage tables updated.
Roadmap left before v0.2.0: Dart/Flutter parser, Go/Ruby/C++ entrypoint
detectors (Option A), branches + docstring in JSON export (Option B).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 5ea4cc4 commit c3ae26e
7 files changed
Lines changed: 540 additions & 0 deletions
File tree
- src/trailmark
- analysis
- parsers/kotlin
- query
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| |||
293 | 294 | | |
294 | 295 | | |
295 | 296 | | |
| 297 | + | |
296 | 298 | | |
297 | 299 | | |
298 | 300 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
171 | 192 | | |
172 | 193 | | |
173 | 194 | | |
| |||
260 | 281 | | |
261 | 282 | | |
262 | 283 | | |
| 284 | + | |
| 285 | + | |
263 | 286 | | |
264 | 287 | | |
265 | 288 | | |
| |||
652 | 675 | | |
653 | 676 | | |
654 | 677 | | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
655 | 713 | | |
656 | 714 | | |
657 | 715 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
0 commit comments