Class: Aidp::Analyze::TreeSitterScan

Inherits:
Object
  • Object
show all
Includes:
MessageDisplay
Defined in:
lib/aidp/analyze/tree_sitter_scan.rb

Constant Summary

Constants included from MessageDisplay

MessageDisplay::COLOR_MAP

Instance Method Summary collapse

Methods included from MessageDisplay

#display_message, #in_test_environment?, included, #message_display_prompt, #suppress_display_message?

Constructor Details

#initialize(root: Dir.pwd, kb_dir: ".aidp/kb", langs: %w[ruby],, threads: Etc.nprocessors, prompt: TTY::Prompt.new) ⇒ TreeSitterScan



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/aidp/analyze/tree_sitter_scan.rb', line 17

def initialize(root: Dir.pwd, kb_dir: ".aidp/kb", langs: %w[ruby], threads: Etc.nprocessors, prompt: TTY::Prompt.new)
  @root = File.expand_path(root)
  @kb_dir = File.expand_path(kb_dir, @root)
  @langs = Array(langs)
  @threads = threads
  @prompt = prompt
  @grammar_loader = TreeSitterGrammarLoader.new(@root, prompt: @prompt)

  # Data structures to accumulate analysis results
  @symbols = []
  @imports = []
  @calls = []
  @metrics = []
  @seams = []
  @hotspots = []
  @tests = []
  @cycles = []

  # Cache for parsed files
  @cache = {}
  @cache_file = File.join(@kb_dir, ".cache")
end

Instance Method Details

#runObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/aidp/analyze/tree_sitter_scan.rb', line 40

def run
  display_message("๐Ÿ” Starting Tree-sitter static analysis...", type: :highlight)
  display_message("๐Ÿ“ Root: #{@root}", type: :info)
  display_message("๐Ÿ—‚๏ธ  KB Directory: #{@kb_dir}", type: :info)
  display_message("๐ŸŒ Languages: #{@langs.join(", ")}", type: :info)
  display_message("๐Ÿงต Threads: #{@threads}", type: :info)

  files = discover_files
  display_message("๐Ÿ“„ Found #{files.length} files to analyze", type: :info)

  prepare_kb_dir
  load_cache

  parallel_parse(files)
  write_kb_files

  display_message("โœ… Tree-sitter analysis complete!", type: :success)
  display_message("๐Ÿ“Š Generated KB files in #{@kb_dir}", type: :success)
end