Module: SimpleCov::SourceFile::BuilderContext
- Included in:
- SimpleCov::SourceFile
- Defined in:
- lib/simplecov/source_file/builder_context.rb
Overview
Helpers shared by the per-criterion builders (LineBuilder / BranchBuilder / MethodBuilder). Mixed into SourceFile so each builder can ask the file for its skip-chunk ranges and Prism-derived real source positions without duplicating the memoization.
Instance Method Summary collapse
-
#real_source_positions ⇒ Object
Memoized set of real source positions (branch start lines, method name+line pairs) extracted via Prism.
-
#skip_chunks_for(criterion) ⇒ Object
Skip-chunk lookup for the named criterion (‘:line`, `:branch`, `:method`).
Instance Method Details
#real_source_positions ⇒ Object
Memoized set of real source positions (branch start lines, method name+line pairs) extracted via Prism. Returns nil when Prism is unavailable or parsing fails, signaling callers to keep every Coverage entry (no false drops). The ‘defined?` guard preserves a nil memoization across calls.
21 22 23 24 25 |
# File 'lib/simplecov/source_file/builder_context.rb', line 21 def real_source_positions return @real_source_positions if defined?(@real_source_positions) @real_source_positions = StaticCoverageExtractor.real_source_positions(src.join) end |
#skip_chunks_for(criterion) ⇒ Object
Skip-chunk lookup for the named criterion (‘:line`, `:branch`, `:method`).
12 13 14 |
# File 'lib/simplecov/source_file/builder_context.rb', line 12 def skip_chunks_for(criterion) (@skip_chunks ||= SkipChunks.new(filename, src)).for(criterion) end |