Add code analyzers (Python, JS, Go, Rust) with tree-sitter
Some checks failed
CI / build (push) Has been cancelled
CI / release (push) Has been cancelled
CI / test (push) Has been cancelled

This commit is contained in:
2026-02-05 08:42:32 +00:00
parent 837e727b4d
commit c2603e5993

View File

@@ -0,0 +1,39 @@
"""Code analyzer factory for routing to correct analyzer."""
from pathlib import Path
from typing import Optional
from . import CodeAnalyzer
from .python_analyzer import PythonAnalyzer
from .javascript_analyzer import JavaScriptAnalyzer
from .go_analyzer import GoAnalyzer
from .rust_analyzer import RustAnalyzer
class CodeAnalyzerFactory:
"""Factory for creating appropriate code analyzers."""
ANALYZERS = [
PythonAnalyzer(),
JavaScriptAnalyzer(),
GoAnalyzer(),
RustAnalyzer(),
]
@classmethod
def get_analyzer(cls, path: Path) -> Optional[CodeAnalyzer]:
"""Get the appropriate analyzer for a file."""
for analyzer in cls.ANALYZERS:
if analyzer.can_analyze(path):
return analyzer
return None
@classmethod
def get_all_analyzers(cls) -> list[CodeAnalyzer]:
"""Get all available analyzers."""
return cls.ANALYZERS.copy()
@classmethod
def can_analyze(cls, path: Path) -> bool:
"""Check if any analyzer can handle the file."""
return cls.get_analyzer(path) is not None