class

Analyzer::Crystal::Kemal

Inherits Analyzer::Crystal::CrystalEngine < FileScanEngine < Analyzer < FileHelper < Reference < Object

Constants

KEMAL_EXTRA_ROUTES = [{"QUERY", QUERY_ROUTE_PATTERN}] of Tuple(String, Regex)
MACRO_VAR_PATTERN = /\{\{\s*(\w+)\s*=\s*([A-Za-z_][\w:]*)\s*\}\}/

Compile-time macro var assignment, e.g. {{namespace = Routes::API::V1}}. invidious sets it once, then registers 50+ routes as get "/…", {{namespace}}::Videos, :videos — substituting it back lets those routes resolve their controller and carry callees.

MOUNT_PATTERN = /^\s*mount\s+["'](.+?)["']\s*,\s*(\w+)/
NAMESPACE_PATTERN = /^(\s*)(?:(\w+)\.)?namespace\s+["'](.+?)["']/
QUERY_ROUTE_PATTERN = /(?:^|[^.\w])query\s*(?:\(\s*)?['"](.+?)['"]/

Kemal's query route DSL (RFC 10008, kemalcr/kemal#769) is Kemal-specific, unlike get/post/etc. which the shared engine's SIMPLE_ROUTE_RE already covers for every Crystal analyzer (Amber, Lucky). It's stitched in via match_crystal_simple_route(..., extra:) instead of touching that shared pattern, mirroring Lucky's TRACE extra route. The same (?:^|[^.\w]) lead-in that keeps before_get / after_get from matching get also keeps before_query / after_query filters from matching here — they must not emit endpoints.

ROUTER_PATTERN = /^\s*(\w+)\s*=\s*Kemal::Router\.new/
SERVE_STATIC_DISABLED_RE = Regex.union("serve_static false", "serve_static(false)")

serve_static false / serve_static(false) — checked on every source line, so the two fixed OR-ed String#includes? substring scans are precompiled into a single regex union (one PCRE2 JIT scan per line instead of two naive substring scans).

Class methods

tech_name
Source

Instance methods

analyze
Source
analyze_file(path : String) : Array(Endpoint)
Source
line_to_endpoint(content : String) : Endpoint
Source
line_to_param(content : String) : Param
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