MCPcopy Index your code
hub / github.com/HKUDS/DeepCode / build_all_indexes

Method build_all_indexes

tools/code_indexer.py:1189–1268  ·  view source on GitHub ↗

Build indexes for all repositories in code_base

(self)

Source from the content-addressed store, hash-verified

1187 gc.collect()
1188
1189 async def build_all_indexes(self) -> Dict[str, str]:
1190 """Build indexes for all repositories in code_base"""
1191 if not self.code_base_path.exists():
1192 raise FileNotFoundError(
1193 f"Code base path does not exist: {self.code_base_path}"
1194 )
1195
1196 # Get all repository directories
1197 repo_dirs = [
1198 d
1199 for d in self.code_base_path.iterdir()
1200 if d.is_dir() and not d.name.startswith(".")
1201 ]
1202
1203 if not repo_dirs:
1204 raise ValueError(f"No repositories found in {self.code_base_path}")
1205
1206 self.logger.info(f"Found {len(repo_dirs)} repositories to process")
1207
1208 # Process each repository
1209 output_files = {}
1210 statistics_data = []
1211
1212 for repo_dir in repo_dirs:
1213 try:
1214 # Process repository
1215 repo_index = await self.process_repository(repo_dir)
1216
1217 # Generate output filename using configured pattern
1218 output_filename = self.index_filename_pattern.format(
1219 repo_name=repo_index.repo_name
1220 )
1221 output_file = self.output_dir / output_filename
1222
1223 # Get output configuration
1224 output_config = self.indexer_config.get("output", {})
1225 json_indent = output_config.get("json_indent", 2)
1226 ensure_ascii = not output_config.get("ensure_ascii", False)
1227
1228 # Save to JSON file
1229 with open(output_file, "w", encoding="utf-8") as f:
1230 if self.include_metadata:
1231 json.dump(
1232 asdict(repo_index),
1233 f,
1234 indent=json_indent,
1235 ensure_ascii=ensure_ascii,
1236 )
1237 else:
1238 # Save without metadata if disabled
1239 index_data = asdict(repo_index)
1240 index_data.pop("analysis_metadata", None)
1241 json.dump(
1242 index_data, f, indent=json_indent, ensure_ascii=ensure_ascii
1243 )
1244
1245 output_files[repo_index.repo_name] = str(output_file)
1246 self.logger.info(

Callers 2

mainFunction · 0.95
run_indexing_workflowMethod · 0.80

Calls 5

process_repositoryMethod · 0.95
getMethod · 0.80

Tested by

no test coverage detected