Noir::TreeSitterKotlinRouteExtractor
Tree-sitter-backed Kotlin route extractor.
Spring-style annotation routing — class-level @RequestMapping-family
annotations composing with method-level mapping annotations. Mirrors
TreeSitterJavaRouteExtractor but for Kotlin's distinct AST shape
(annotations live in modifiers, functions use
function_declaration, primary constructors carry DTO fields, etc.).
This file holds the class-tree walking, mapping prefixes and controller/interface/Feign routes; the sibling files in this directory reopen the module with one concern each (STOMP, GraphQL, gateway, WebFlux functional DSL, shared decoding helpers).
Ktor's DSL routing { get("/x") { ... } } is a different authoring
style and lives in a separate walker
(kotlin_ktor_route_extractor_ts.cr).
Constants
Spring mapping annotation names → HTTP verb. nil means look at
the annotation's method = argument. Same table as the Java
extractor for consistency.
Instance methods
Resolve Kotlin string-template interpolations inside collected
constant values, e.g. const val STATIC_URL = "$PUBLIC_URL/static"
with PUBLIC_URL = "/public" becomes /public/static. The regex
capture in extract_string_constants stores the raw $PUBLIC_URL
text, so without this a path built from such a constant keeps the
literal $VAR (or, as an inline annotation literal, mis-parses it
as a {VAR} path placeholder). Unresolved references (e.g. Spring
${config.property} placeholders) are left untouched. Bounded
iterations resolve transitive chains.
_from(root, source) — accept a pre-parsed root so the Kotlin
Spring analyzer can amortise the parse across multiple
extractions on the same file. Tree lifetime is the caller's
responsibility.