факит
This commit is contained in:
@@ -5,16 +5,19 @@ from pathspec import PathSpec
|
||||
from pathspec.patterns import GitWildMatchPattern
|
||||
|
||||
from ..utils.logger import log
|
||||
from .file_analyzer import FileAnalyzer
|
||||
|
||||
|
||||
class ProjectMap:
|
||||
def __init__(self, project_path: str):
|
||||
self.project_path = project_path
|
||||
self.gitignore_rules = self._load_gitignore()
|
||||
self.file_analyzer = FileAnalyzer()
|
||||
|
||||
def generate_map(self) -> str:
|
||||
"""
|
||||
Создает карту структуры проекта, игнорируя файлы из .gitignore и директорию .git/.
|
||||
Добавляет информацию о функциях в файлы .ts, .tsx, .js, .jsx.
|
||||
"""
|
||||
log("Generating project structure map...")
|
||||
structure = self._traverse_directory(self.project_path)
|
||||
@@ -44,6 +47,15 @@ class ProjectMap:
|
||||
result += self._traverse_directory(full_path, level + 1)
|
||||
else:
|
||||
result += f"{indent}- {entry}\n"
|
||||
|
||||
# Если это файл TypeScript/JavaScript, добавляем информацию о функциях
|
||||
if entry.endswith((".ts", ".tsx", ".js", ".jsx")):
|
||||
functions_info = self.file_analyzer.analyze_file(full_path)
|
||||
if functions_info:
|
||||
for func_name, details in functions_info.items():
|
||||
params = ", ".join(details["params"])
|
||||
return_type = details.get("return_type", "unknown")
|
||||
result += f"{indent} FUNCTION {func_name}({params}): {return_type}\n"
|
||||
return result
|
||||
|
||||
def save_map(self, output_file: str = "react_app_map.txt"):
|
||||
@@ -78,4 +90,4 @@ class ProjectMap:
|
||||
spec = PathSpec.from_lines(GitWildMatchPattern, self.gitignore_rules)
|
||||
|
||||
# Проверяем, соответствует ли путь правилам
|
||||
return spec.match_file(path)
|
||||
return spec.match_file(path)
|
||||
Reference in New Issue
Block a user