MCPcopy
hub / github.com/HKUDS/DeepCode / find_relevant_references_in_cache

Function find_relevant_references_in_cache

tools/code_reference_indexer.py:175–195  ·  view source on GitHub ↗

Find reference code relevant to target file from provided cache

(
    target_file: str,
    index_cache: Dict[str, Dict],
    keywords: List[str] = None,
    max_results: int = 10,
)

Source from the content-addressed store, hash-verified

173
174
175def find_relevant_references_in_cache(
176 target_file: str,
177 index_cache: Dict[str, Dict],
178 keywords: List[str] = None,
179 max_results: int = 10,
180) -> List[Tuple[CodeReference, float]]:
181 """Find reference code relevant to target file from provided cache"""
182 all_references = []
183
184 # Collect reference information from all index files
185 for repo_name, index_data in index_cache.items():
186 references = extract_code_references(index_data)
187 for ref in references:
188 relevance_score = calculate_relevance_score(target_file, ref, keywords)
189 if relevance_score > 0.1: # Only keep results with certain relevance
190 all_references.append((ref, relevance_score))
191
192 # Sort by relevance score
193 all_references.sort(key=lambda x: x[1], reverse=True)
194
195 return all_references[:max_results]
196
197
198def find_direct_relationships_in_cache(

Callers 1

search_code_referencesFunction · 0.85

Calls 2

extract_code_referencesFunction · 0.85

Tested by

no test coverage detected