abstract class Analyzer::Rust::RustEngine

Direct Known Subclasses

Defined in:

analyzer/engines/rust_engine.cr

Constant Summary

ANY_FAN_OUT_VERBS = ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]

Standard set of HTTP methods that axum::routing::any(...) / actix web::route() / similar method-agnostic registrations accept. Mirrors the Go .fan_out_verbs set so output formats see real HTTP methods instead of a non-HTTP "ANY" string.

Class Method Summary

Instance Method Summary

Instance methods inherited from class Analyzer

analyze analyze, base_path : String base_path, base_paths : Array(String) base_paths, callees_needed? : Bool callees_needed?, logger : NoirLogger logger, parallel_analyze(channel : Channel(String), &block : String -> Nil) parallel_analyze, read_file_content(path : String) : String read_file_content, result : Array(Endpoint) result, url : String url

Constructor methods inherited from class Analyzer

new(options : Hash(String, YAML::Any)) new

Macros inherited from class Analyzer

define_getter_methods(names) define_getter_methods

Instance methods inherited from module FileHelper

all_files : Array(String) all_files, get_files_by_extension(extension : String) : Array(String) get_files_by_extension, get_files_by_prefix(prefix : String) : Array(String) get_files_by_prefix, get_files_by_prefix_and_extension(prefix : String, extension : String) : Array(String) get_files_by_prefix_and_extension, get_public_dir_files(base_path : String, folder : String) : Array(String) get_public_dir_files, get_public_files(base_path : String, anchors : Array(String) = ["shard.yml", "Gemfile"]) : Array(String) get_public_files, populate_channel_with_files(channel : Channel(String)) populate_channel_with_files, populate_channel_with_filtered_files(channel : Channel(String), extension : String)
populate_channel_with_filtered_files(channel : Channel(String), extensions : Array(String))
populate_channel_with_filtered_files

Class Method Detail

def self.collect_cfg_test_regions(source : String) : Array(Tuple(Int32, Int32)) #

Scan the source for #[cfg(test)] annotations, then capture the byte range of the following mod/fn/impl block via simple brace counting. String/char literals are skipped so a { inside "foo {" doesn't shift the depth. Rust lifetimes like 'a look like char literals to a naive quote scanner and would otherwise drop the close-brace search into oblivion — see skip_char_or_lifetime.

Shared with all Rust analyzers: axum's extract/path/mod.rs, salvo's crates/core/src/routing.rs, and similar framework source files mix production routes with #[cfg(test)] mod tests { ... } blocks. Each analyzer that uses tree-sitter can call this once per file, then drop any route call whose ts_node_start_byte falls in one of the returned ranges.


[View source]
def self.fan_out_verbs(verb : String) : Array(String) #

Expand any / all (case-insensitive) into the seven canonical HTTP methods. Anything else passes through as a single-element list.


[View source]
def self.inside_test_region?(node : LibTreeSitter::TSNode, regions : Array(Tuple(Int32, Int32))) : Bool #

[View source]
def self.test_path?(path : String) : Bool #

Cargo convention: every .rs immediately under a crate's tests/ directory is an integration-test binary, never a production endpoint. The _test.rs / _tests.rs suffix is equally rigid for unit tests in sibling files. Framework repos (rocket/Rocket's core/codegen/tests/, actix-web's actix-web-codegen/tests/, poem's poem-openapi/tests/) all park hundreds of route registrations under one of these patterns. Promoted from axum.cr#test_only_path? (#1569) to the shared engine so the rest of the Rust family benefits.


[View source]

Instance Method Detail

def analyze #

[View source]
abstract def analyze_file(path : String) : Array(Endpoint) #

[View source]