Module: ActiveMutator::DefinedConstants

Defined in:
lib/active_mutator/defined_constants.rb

Overview

Deepest fully qualified names of classes/modules a source file defines ("Billing::Invoice"). Two shorthands are deliberately never emitted, because either would let a single common token match half of any real spec suite and trip BaselineDelta's full-run fallback on every edit:

- bare leaves ("Config" for MyApp::Config)
- pure namespace wrappers ("MyApp" for `module MyApp; class Config`):
every file in a namespaced app reopens the top module, and every
spec mentions it.

A wrapper is a node whose non-empty direct body contains ONLY nested class/module definitions. A module with its own defs/macros/constants is a real edit target and IS emitted; so is an empty or def-less leaf class (macro-only ActiveRecord models).

Guard is errors.any?, not warnings: Prism produces a complete AST for warnings-only input (if a = 2), and those definitions are real.

Class Method Summary collapse

Class Method Details

.in_source(source) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/active_mutator/defined_constants.rb', line 20

def self.in_source(source)
  result = Prism.parse(source)
  return [] if result.errors.any?

  names = []
  walk(result.value, [], names)
  names.uniq
end