Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/codegraphcontext/tools/code_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ def _normalize_identifier(s: str) -> str:

Examples::

_normalize_identifier('myFunction') -> 'myfunction'
_normalize_identifier('my_function') -> 'myfunction'
_normalize_identifier('my function') -> 'myfunction'
_normalize_identifier('MyFunc tion') -> 'myfunction'
_normalize_identifier('myFunction') -> 'myfunction'
_normalize_identifier('my_function') -> 'myfunction'
_normalize_identifier('my function') -> 'myfunction'
_normalize_identifier('MyFunc tion') -> 'myfunction'
"""
return s.lower().replace('_', '').replace(' ', '')

Expand Down Expand Up @@ -241,8 +241,8 @@ def _find_by_name_fuzzy_portable(
rows = session.run(query, **params).data()

# Two query forms:
# q_raw – lowercased original (e.g. "myFuncton" → "myfuncton")
# q_norm – separator-stripped (e.g. "my_functon" → "myfuncton")
# q_raw – lowercased original (e.g. "myFuncton" → "myfuncton")
# q_norm – separator-stripped (e.g. "my_functon" → "myfuncton")
# Using the minimum of both distances avoids the space-inflation bug where
# the handler's replace('_', ' ') turns "my_functon" into "my functon",
# which compares poorly against camelCase stored names.
Expand Down Expand Up @@ -1276,7 +1276,8 @@ def analyze_code_relationships(self, query_type: str, target: str, context: Opti
}

elif query_type == "find_complexity":
limit = int(context) if context and context.isdigit() else 10
limit_val = context if context else target
limit = int(limit_val) if limit_val and str(limit_val).isdigit() else 10
results = self.find_most_complex_functions(limit, repo_path=repo_path)
return {
"query_type": "find_complexity", "limit": limit, "results": results,
Expand All @@ -1300,8 +1301,7 @@ def analyze_code_relationships(self, query_type: str, target: str, context: Opti
elif query_type in ["call_chain", "path", "chain"]:
if '->' in target:
start_func, end_func = target.split('->', 1)
# max_depth can be passed as context, default to 5 if not provided or invalid
max_depth = int(context) if context and context.isdigit() else 5
max_depth = int(context) if context and str(context).isdigit() else 5
results = self.find_function_call_chain(start_func.strip(), end_func.strip(), max_depth, repo_path=repo_path)
return {
"query_type": "call_chain", "target": target, "results": results,
Expand Down
Loading