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. Dependencies are detected from the run method and called methods (SomeTask.method calls).

Static dependencies are used for:

  • Tree display visualization
  • Circular dependency detection
  • Task execution ordering

Parameters:

  • task_class (Class)

    The task class to analyze

Returns:

  • (Set<Class>)

    Set of task classes that are static dependencies



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

def self.analyze(task_class)
  source_location = extract_method_location(task_class, :run)
  return Set.new unless source_location

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

  visitor = Visitor.new(task_class, :run)
  visitor.visit(parse_result.value)
  # Follow method calls to analyze dependencies in called methods
  visitor.follow_method_calls
  visitor.dependencies
end