module SimpleCov::StaticCoverageExtractor
def call(source)
when Prism isn't available; callers should treat that as "couldn't
`Coverage.result[path]` produces. Returns nil on parse failure or
`{"branches" => {...}, "methods" => {...}}` matching the shape that
Parse `source` (a string of Ruby) and return a hash of the form
def call(source) # simplecov:disable branch — `then` arm unreachable when Prism IS loadable return nil unless available? # simplecov:enable branch result = ::Prism.parse(source) return nil if result.failure? visitor = Visitor.new visitor.visit(result.value) {"branches" => visitor.branches, "methods" => visitor.methods} rescue StandardError # simplecov:disable line # Parser errors beyond the .failure? check, unsupported AST shapes, # or anything else: fall back to empty hashes rather than crashing # the whole report. Defensive; hard to trigger from a real source # input that Prism accepts at parse time. nil # simplecov:enable line end