refactor: Remove is_source_file function and check in FileWatcher

This commit is contained in:
Paul Gauthier 2024-12-11 20:30:47 -08:00 committed by Paul Gauthier (aider)
parent d3daf9d159
commit 365e7126d0

View file

@ -12,59 +12,6 @@ from aider.dump import dump # noqa
from aider.watch_prompts import watch_ask_prompt, watch_code_prompt
def is_source_file(path: Path) -> bool:
"""
Check if a file is a source file that uses # or // style comments.
This includes Python, JavaScript, TypeScript, C, C++, etc.
"""
COMMENT_STYLE_EXTENSIONS = {
# # style comments
".py",
".r",
".rb",
".pl",
".pm",
".sh",
".bash",
".zsh",
".bashrc",
".bash_profile",
".bash_login",
".bash_logout",
".zshrc",
".zprofile",
".zlogin",
".zlogout",
".profile",
".yaml",
".yml",
# // style comments
".js",
".ts",
".jsx",
".tsx",
".cpp",
".c",
".h",
".hpp",
".java",
".swift",
".kt",
".cs",
".go",
".rs",
".php",
# -- style comments
".sql",
".hs", # Haskell
".lua",
".elm",
".vhd", # VHDL
".vhdl",
}
return path.suffix.lower() in COMMENT_STYLE_EXTENSIONS
def load_gitignores(gitignore_paths: list[Path]) -> Optional[PathSpec]:
"""Load and parse multiple .gitignore files into a single PathSpec"""
if not gitignore_paths:
@ -151,9 +98,6 @@ class FileWatcher:
if self.gitignore_spec and self.gitignore_spec.match_file(str(rel_path)):
return False
if not is_source_file(path_obj):
return False
if self.verbose:
dump("ok", rel_path)