Class: Taski::StaticAnalysis::Analyzer

Inherits:
Object
  • Object
show all
Defined in:
lib/taski/static_analysis/analyzer.rb

Class Method Summary collapse

Class Method Details

.analyze(task_class) ⇒ Set<Class>

Analyzes a task class and returns its static dependencies. For Task: dependencies detected from run method (SomeTask.method calls) For Section: impl candidates detected from impl method (constants returned)

Static dependencies are used for:

  • Tree display visualization

  • Circular dependency detection

  • Task execution (for Task only; Section resolves impl at runtime)

Parameters:

  • task_class (Class)

    The task class to analyze

Returns:

  • (Set<Class>)

    Set of task classes that are static dependencies



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/taski/static_analysis/analyzer.rb', line 20

def self.analyze(task_class)
  target_method = target_method_for(task_class)
  source_location = extract_method_location(task_class, target_method)
  return Set.new unless source_location

  file_path, _line_number = source_location
  parse_result = Prism.parse_file(file_path)

  visitor = Visitor.new(task_class, target_method)
  visitor.visit(parse_result.value)
  visitor.dependencies
end