Skip to content

Commit 32581a7

Browse files
gkorlandCopilot
andcommitted
fix: address review — fix return types, indentation, path normalization
- Fix resolve_symbol return type annotation: Entity -> list[Entity] in abstract and Kotlin implementations to match actual behavior - Fix pyproject.toml indentation for tree-sitter-kotlin dependency - Add path.resolve() in analyze_sources for LSP compatibility - Remove unused exception variable Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent a96e20f commit 32581a7

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

api/analyzers/analyzer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def resolve(self, files: dict[Path, File], lsp: SyncLanguageServer, file_path: P
5656
try:
5757
locations = lsp.request_definition(str(file_path), node.start_point.row, node.start_point.column)
5858
return [(files[Path(self.resolve_path(location['absolutePath'], path))], files[Path(self.resolve_path(location['absolutePath'], path))].tree.root_node.descendant_for_point_range(Point(location['range']['start']['line'], location['range']['start']['character']), Point(location['range']['end']['line'], location['range']['end']['character']))) for location in locations if location and Path(self.resolve_path(location['absolutePath'], path)) in files]
59-
except Exception as e:
59+
except Exception:
6060
return []
6161

6262
@abstractmethod
@@ -133,9 +133,9 @@ def add_symbols(self, entity: Entity) -> None:
133133
pass
134134

135135
@abstractmethod
136-
def resolve_symbol(self, files: dict[Path, File], lsp: SyncLanguageServer, file_path: Path, path: Path, key: str, symbol: Node) -> Entity:
136+
def resolve_symbol(self, files: dict[Path, File], lsp: SyncLanguageServer, file_path: Path, path: Path, key: str, symbol: Node) -> list[Entity]:
137137
"""
138-
Resolve a symbol to an entity.
138+
Resolve a symbol to entities.
139139
140140
Args:
141141
lsp (SyncLanguageServer): The language server.
@@ -144,7 +144,7 @@ def resolve_symbol(self, files: dict[Path, File], lsp: SyncLanguageServer, file_
144144
symbol (Node): The symbol node.
145145
146146
Returns:
147-
Entity: The entity.
147+
list[Entity]: The resolved entities.
148148
"""
149149

150150
pass

api/analyzers/kotlin/analyzer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def resolve_method(self, files: dict[Path, File], lsp: SyncLanguageServer, file_
145145
break
146146
return res
147147

148-
def resolve_symbol(self, files: dict[Path, File], lsp: SyncLanguageServer, file_path: Path, path: Path, key: str, symbol: Node) -> Entity:
148+
def resolve_symbol(self, files: dict[Path, File], lsp: SyncLanguageServer, file_path: Path, path: Path, key: str, symbol: Node) -> list[Entity]:
149149
if key in ["implement_interface", "base_class", "parameters", "return_type"]:
150150
return self.resolve_type(files, lsp, file_path, path, symbol)
151151
elif key in ["call"]:

api/analyzers/source_analyzer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ def analyze_files(self, files: list[Path], path: Path, graph: Graph) -> None:
173173
self.second_pass(graph, files, path)
174174

175175
def analyze_sources(self, path: Path, ignore: list[str], graph: Graph) -> None:
176+
path = path.resolve()
176177
files = list(path.rglob("*.java")) + list(path.rglob("*.py")) + list(path.rglob("*.kt")) + list(path.rglob("*.kts"))
177178
# First pass analysis of the source code
178179
self.first_pass(path, files, ignore, graph)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dependencies = [
1313
"tree-sitter-c>=0.24.1,<0.25.0",
1414
"tree-sitter-python>=0.25.0,<0.26.0",
1515
"tree-sitter-java>=0.23.5,<0.24.0",
16-
"tree-sitter-kotlin>=1.1.0,<2.0.0",
16+
"tree-sitter-kotlin>=1.1.0,<2.0.0",
1717
"tree-sitter-c-sharp>=0.23.1,<0.24.0",
1818
"fastapi>=0.115.0,<1.0.0",
1919
"uvicorn[standard]>=0.34.0,<1.0.0",

0 commit comments

Comments
 (0)