Skip to content

Commit 40f01d0

Browse files
committed
fix: optimize java
1 parent c8db6af commit 40f01d0

File tree

4 files changed

+28
-17
lines changed

4 files changed

+28
-17
lines changed

codebase_rag/language_config.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,6 @@ class LanguageConfig:
249249
call_query="""
250250
(method_invocation
251251
name: (identifier) @name) @call
252-
(method_invocation
253-
object: (_)
254-
name: (identifier) @name) @call
255252
(object_creation_expression
256253
type: (type_identifier) @name) @call
257254
""",

codebase_rag/parsers/definition_processor.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,6 +1178,25 @@ def _ingest_classes_and_methods(
11781178
if not isinstance(method_node, Node):
11791179
continue
11801180

1181+
# Handle Java method overloading with parameter types
1182+
method_qualified_name = None
1183+
if language == "java":
1184+
from .java_utils import extract_java_method_info
1185+
1186+
method_info = extract_java_method_info(method_node)
1187+
method_name = method_info.get("name")
1188+
parameters = method_info.get("parameters", [])
1189+
if method_name:
1190+
if parameters:
1191+
# Create method signature with parameter types for overloading
1192+
param_signature = "(" + ",".join(parameters) + ")"
1193+
method_qualified_name = (
1194+
f"{class_qn}.{method_name}{param_signature}"
1195+
)
1196+
else:
1197+
# No parameters, use simple name
1198+
method_qualified_name = f"{class_qn}.{method_name}()"
1199+
11811200
ingest_method(
11821201
method_node,
11831202
class_qn,
@@ -1188,6 +1207,7 @@ def _ingest_classes_and_methods(
11881207
self._get_docstring,
11891208
language,
11901209
self._extract_decorators,
1210+
method_qualified_name,
11911211
)
11921212

11931213
# Note: OVERRIDES relationships will be processed later after all methods are collected

codebase_rag/parsers/java_type_inference.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from .import_processor import ImportProcessor
1010
from .java_utils import (
11+
extract_java_class_info,
1112
extract_java_field_info,
1213
extract_java_method_call_info,
1314
safe_decode_text,
@@ -1115,7 +1116,6 @@ def _find_field_type_in_class(
11151116
self, root_node: Node, class_name: str, field_name: str, module_qn: str
11161117
) -> str | None:
11171118
"""Find the type of a specific field in a class using tree-sitter AST analysis."""
1118-
from .java_utils import extract_java_class_info, extract_java_field_info
11191119

11201120
# Find the target class in the AST
11211121
for child in root_node.children:

codebase_rag/parsers/utils.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ def ingest_method(
9292
get_docstring_func: Any,
9393
language: str = "",
9494
extract_decorators_func: Any = None,
95+
method_qualified_name: str | None = None,
9596
) -> None:
9697
"""Ingest a method node into the graph database.
9798
@@ -105,6 +106,7 @@ def ingest_method(
105106
get_docstring_func: Function to extract docstring from a node.
106107
language: The programming language (used for C++ specific handling).
107108
extract_decorators_func: Optional function to extract decorators.
109+
method_qualified_name: Optional pre-computed qualified name to use instead of generating one.
108110
"""
109111
# Extract method name based on language
110112
if language == "cpp":
@@ -122,20 +124,12 @@ def ingest_method(
122124
return
123125
method_name = text.decode("utf8")
124126

125-
# Build qualified name (handle Java method overloading)
126-
if language == "java":
127-
from .java_utils import extract_java_method_info
128-
129-
method_info = extract_java_method_info(method_node)
130-
parameters = method_info.get("parameters", [])
131-
if parameters:
132-
# Create method signature with parameter types for overloading
133-
param_signature = "(" + ",".join(parameters) + ")"
134-
method_qn = f"{container_qn}.{method_name}{param_signature}"
135-
else:
136-
# No parameters, use simple name
137-
method_qn = f"{container_qn}.{method_name}()"
127+
# Build qualified name
128+
if method_qualified_name is not None:
129+
# Use pre-computed qualified name (for language-specific handling)
130+
method_qn = method_qualified_name
138131
else:
132+
# Default qualified name construction
139133
method_qn = f"{container_qn}.{method_name}"
140134

141135
# Extract decorators if function provided

0 commit comments

Comments
 (0)