class CodeLocator

Defined in:

models/code_locator.cr

Constant Summary

DEFAULT_CONTENT_CACHE_BUDGET = (512_i64 * 1024) * 1024

Default content cache budget (bytes). Override via NOIR_CONTENT_CACHE_MAX_MB (value in megabytes). Set to 0 or the env NOIR_CONTENT_CACHE_DISABLE=true to disable caching entirely, in which case #content_for always returns nil and analyzers fall through to File.read.

Constructors

Instance Method Summary

Constructor Detail

def self.instance : CodeLocator #

[View source]
def self.new #

[View source]

Instance Method Detail

def all(key : String) : Array(String) #

[View source]
def build_extension_index #

Build extension index from file_map for fast lookups


[View source]
def clear(key : String) #

[View source]
def clear_all #

[View source]
def content_cache_stats : NamedTuple(bytes: Int64, files: Int32, skipped: Int32, budget: Int64) #

[View source]
def content_for(path : String) : String | Nil #

Returns cached file content or nil if the file was not cached (budget exhausted, caching disabled, or read after cache was cleared). Callers should fall back to File.read on nil.


[View source]
def file_usage_stats : Hash(String, Int32) #

Get file usage statistics


[View source]
def files_by_extension(extension : String) : Array(String) #

Get files by extension using the index (O(1) lookup)


[View source]
def get(key : String) : String | Array(String) #

[View source]
def push(key : String, value : String) #

[View source]
def register_file(path : String, content : String) #

One-shot used by the detector's file reader: push the path into file_map and (budget permitting) cache the content so analyzers can skip the second File.read. Files whose content exceeds the remaining budget are still registered in file_map but not cached, and #content_for(path) returns nil for them — callers must keep a File.read fallback.


[View source]
def set(key : String, value : String) #

[View source]
def show_file_stats #

Show file usage statistics


[View source]
def show_table #

[View source]