Module: SimpleCov::SourceFile::BuilderContext

Included in:
SimpleCov::SourceFile
Defined in:
lib/simplecov/source_file/builder_context.rb,
sig/simplecov.rbs

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

Instance Method Details

#filenameString

Provided by the including class (SourceFile).

Returns:

  • (String)


1099
# File 'sig/simplecov.rbs', line 1099

def filename: () -> String

#real_source_positionsreal_positions?

Memoized set of real source positions 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.

Returns:

  • (real_positions, nil)


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) ⇒ Array[Range[Integer]]

Skip-chunk lookup for the named criterion (:line, :branch, :method).

Parameters:

  • (criterion)

Returns:

  • (Array[Range[Integer]])


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

#srcArray[String]

Returns:

  • (Array[String])


1100
# File 'sig/simplecov.rbs', line 1100

def src: () -> Array[String]