diff --git a/src/serena/project.py b/src/serena/project.py index a2360c3..f193b65 100644 --- a/src/serena/project.py +++ b/src/serena/project.py @@ -21,22 +21,23 @@ class Project: self.project_config = project_config # gather ignored paths from the project configuration and gitignore files - ignored_paths = project_config.ignored_paths - if len(ignored_paths) > 0: - log.info(f"Using {len(ignored_paths)} ignored paths from the explicit project configuration.") - log.debug(f"Ignored paths: {ignored_paths}") + ignored_patterns = project_config.ignored_paths + if len(ignored_patterns) > 0: + log.info(f"Using {len(ignored_patterns)} ignored paths from the explicit project configuration.") + log.debug(f"Ignored paths: {ignored_patterns}") if project_config.ignore_all_files_in_gitignore: log.info(f"Parsing all gitignore files in {self.project_root}") gitignore_parser = GitignoreParser(self.project_root) log.info(f"Found {len(gitignore_parser.get_ignore_specs())} gitignore files.") for spec in gitignore_parser.get_ignore_specs(): log.debug(f"Adding {len(spec.patterns)} patterns from {spec.file_path} to the ignored paths.") - ignored_paths.extend(spec.patterns) + ignored_patterns.extend(spec.patterns) + self._ignored_patterns = ignored_patterns # Set up the pathspec matcher for the ignored paths # for all absolute paths in ignored_paths, convert them to relative paths processed_patterns = [] - for pattern in set(ignored_paths): + for pattern in set(ignored_patterns): # Normalize separators (pathspec expects forward slashes) pattern = pattern.replace(os.path.sep, "/") processed_patterns.append(pattern) @@ -261,24 +262,9 @@ class Project: :param trace_lsp_communication: whether to trace LSP communication :return: the language server """ - # TODO: This is duplicated in Project.__init__ - project_config = self.project_config - ignored_paths = project_config.ignored_paths - if len(ignored_paths) > 0: - log.info(f"Using {len(ignored_paths)} ignored paths from the explicit project configuration.") - log.debug(f"Ignored paths: {ignored_paths}") - if project_config.ignore_all_files_in_gitignore: - log.info(f"Parsing all gitignore files in {self.project_root}") - gitignore_parser = GitignoreParser(self.project_root) - log.info(f"Found {len(gitignore_parser.get_ignore_specs())} gitignore files.") - for spec in gitignore_parser.get_ignore_specs(): - log.debug(f"Adding {len(spec.patterns)} patterns from {spec.file_path} to the ignored paths.") - ignored_paths.extend(spec.patterns) - log.debug(f"Using {len(ignored_paths)} ignored paths in total.") - ls_config = LanguageServerConfig( code_language=self.language, - ignored_paths=ignored_paths, + ignored_paths=self._ignored_patterns, trace_lsp_communication=trace_lsp_communication, ) ls_logger = LanguageServerLogger(log_level=log_level)