class

Noir::GoCalleeExtractor::LazyPackageBodies

Inherits Reference < Object

Per-directory function/method tables, built for a directory only when someone asks for it.

The eager builders (GoEngine#collect_package_*) parse every .go file of the scan, but most callers only ever look up the directories that hold a route file — Go's name resolution is scoped to one package, so nothing else is consulted. On minio that was a parse of every file in the repo to answer lookups for a handful of router packages.

A directory's table is exactly what the eager builder would have stored for it: the same files, in the same order (grouped from file_contents insertion order), behind the same per-file substring gate, merged the same way (||= for functions, concat for methods). A directory with nothing in it yields an empty table, as the *_for_directory lookups already did. only_dirs, when given, keeps a builder's own restriction to a directory set: any other directory answers empty without parsing.

Use it only where the tables are looked up per directory. Callers that iterate every directory (the import-path indexes) still need the eager form.

Constructors

empty

An instance with no files: every lookup is empty. What callers get when the tables are not needed at all.

Source
new(file_contents : Hash(String, String), function_gate : String | Nil = nil, method_gate : String | Nil = "func (", only_dirs : Set(String) | Nil = nil)
Source

Instance methods

functions_for(dir : String) : Hash(String, FunctionBody)
Source
methods_for(dir : String) : Hash(String, Array(FunctionBody))
Source