Analyzer::Swift::Hummingbird
Inherits Analyzer::Swift::SwiftEngine < FileScanEngine < Analyzer < FileHelper < Reference < Object
Constants
var body: some RouterMiddleware<Context> / func routes() -> some RouterMiddleware<Context> — the controller body that hosts the DSL.
Whole-file DSL-presence gate, evaluated once per line to decide whether
the (expensive) DSL scan runs at all. One precompiled Regex.union
scan (PCRE2 JIT) replaces three naive String#includes? char scans per
line; union auto-escapes each literal so it is provably equivalent to
the OR-of-substrings it replaces.
The capitalized result-builder primitives exposed by the
HummingbirdRouter module. Unlike the receiver-based closure API
(router.get("x") { ... }), routes are declared structurally:
let router = RouterBuilder(context: Context.self) {
Get("/health") { _, _ in .ok } // GET /health
UserController(...) // splices its `body` here
RouteGroup("api") {
Post("login", handler: self.login) // POST /api/login
}
}
struct UserController: RouterController {
var body: some RouterMiddleware<Context> {
RouteGroup("user") {
Put(handler: self.create) // PUT /user
Post("signup", handler: self.signup) // POST /user/signup
}
}
}
A route primitive is only honored when it sits directly inside a
route-emitting scope — a RouterBuilder { } block, a RouteGroup { }
block, or a var/func ... some RouterMiddleware { } controller body —
never inside a handler closure. That gating keeps look-alike PascalCase
constructors (a Post(title:) model, a Get-named type) out of the
endpoint list.
let group = router.group("path") / var api = router.group("v1")
router.group("admin") { admin in ... } — closure-scoped group.
Route-registration methods exposed by Hummingbird's RouterMethods
protocol. They all return Self, which is what makes the fluent
builder chain (group.get(...).post(...)) possible.
route_definition? runs on every scanned line (route detection, param
lookahead, body-boundary checks). One precompiled Regex.union scan
(PCRE2 JIT) replaces seven naive String#includes? char scans; union
auto-escapes each literal so it is provably equivalent to the
OR-of-substrings it replaces.
let routes = RouteCollection(context: ...) — a mountable route group.
let router = Router() — establishes a root router-like receiver.
A function parameter typed as a router/router-group/router-methods.
Type declarations whose body can host a RouteCollection handler.
Class methods
Instance methods
Project-wide pre-pass: resolve RouteCollection prefixes before the per-file scan so controller bodies in one file can pick up the prefix declared at a call site in another.
Parse route path from route arguments. The path is the first quoted
string; {id}-style segments are normalized to :id.
Instance-side view of the same declaration. The per-file rescues live on
this base class, which has no way to name the analyzer that is running
inside them, so a skipped file could not be attributed to a tech.
Deriving it from analyzer_for keeps the name written exactly once.