class

Analyzer::Javascript::Oak

Inherits Analyzer::Javascript::JavascriptEngine < Analyzer < FileHelper < Reference < Object

Oak's Router API is deliberately close to Koa's — router.get(path, handler), :param path syntax, a ctx handed to every handler — so this analyzer largely mirrors Analyzer::Javascript::Koa: both share Noir::JSRouteExtractor for verb-call extraction, path-param scanning, and callee attachment. See js_route_extractor.cr's :oak entry in SHARED_EXTRACTOR_FRAMEWORK_MARKERS — it, and the Oak-specific ctx.request.* param patterns added alongside it, are what make reuse possible.

Two shapes Oak supports that the shared JSParser already resolves with no framework-specific code here:

  • new Router({ prefix: '/api/v1' }) — the constructor-level prefix is generic in JSParser#scan_router_constructor_prefixes (keyed on any Router-named constructor, not a specific framework).
  • parent.use('/prefix', child.routes()) mounted within the same file — the generic same-file router-mount scan in JSParser#parse_routes handles this already (it only needs child to appear as a bare identifier inside the .use(...) call, and child.routes() still exposes child as that identifier).

What the shared parser can't do — because it operates on one file's token stream — is a router assembled in one file and mounted with a prefix in another. resolve_oak_mount_prefixes below handles that cross-file case, the same way Koa#resolve_koa_mount_prefixes does.

Class methods

tech_name
Source

Instance methods

analyze
Source
tech

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.

Source