|
8 | 8 | from codegen.sdk.core.expressions.expression import Expression |
9 | 9 | from codegen.sdk.core.interfaces.has_name import HasName |
10 | 10 | from codegen.sdk.core.node_id_factory import NodeId |
| 11 | +from codegen.sdk.core.symbol import Symbol |
11 | 12 | from codegen.sdk.enums import EdgeType |
12 | 13 | from codegen.sdk.extensions.autocommit import commiter |
13 | 14 | from codegen.sdk.extensions.sort import sort_editables |
|
17 | 18 | from codegen.sdk.codebase.codebase_graph import CodebaseGraph |
18 | 19 | from codegen.sdk.core.import_resolution import Import |
19 | 20 | from codegen.sdk.core.interfaces.editable import Editable |
20 | | - from codegen.sdk.core.symbol import Symbol |
21 | 21 |
|
22 | 22 | Parent = TypeVar("Parent", bound="Editable") |
23 | 23 |
|
@@ -76,10 +76,10 @@ def get_dependencies_to_depth(self, depth: Optional[int] = None) -> list[Union[" |
76 | 76 | @noapidoc |
77 | 77 | def get_dependencies(self, usage_types: UsageType) -> list[Union["Symbol", "Import"]]: |
78 | 78 | """Internal method for getting dependencies by usage type. |
79 | | - |
| 79 | +
|
80 | 80 | This is kept for backward compatibility and internal use. |
81 | 81 | New code should use the dependencies property or get_dependencies_to_depth method. |
82 | | - |
| 82 | +
|
83 | 83 | Opposite of `usages` |
84 | 84 | """ |
85 | 85 | avoid = set(self.descendant_symbols) |
@@ -138,24 +138,24 @@ def _remove_internal_edges(self, edge_type: EdgeType | None = None) -> None: |
138 | 138 | @noapidoc |
139 | 139 | def _get_all_dependencies(self, max_depth: Optional[int] = None) -> list[Union["Symbol", "Import"]]: |
140 | 140 | """Gets all dependencies up to specified depth. |
141 | | - |
| 141 | +
|
142 | 142 | Internal implementation of depth-based dependency traversal. |
143 | 143 | """ |
144 | | - dependency_map: dict[Self, list[Union["Symbol", "Import"]]] = {} |
| 144 | + dependency_map: dict[Self, list[Union[Symbol, Import]]] = {} |
145 | 145 | current_depth = 1 |
146 | | - |
| 146 | + |
147 | 147 | def _collect_deps(symbol: Self, depth: int) -> None: |
148 | 148 | if depth > max_depth if max_depth is not None else False: |
149 | 149 | return |
150 | | - |
| 150 | + |
151 | 151 | direct_deps = symbol.get_dependencies(UsageType.DIRECT) |
152 | 152 | if symbol not in dependency_map: |
153 | 153 | dependency_map[symbol] = direct_deps |
154 | | - |
| 154 | + |
155 | 155 | for dep in direct_deps: |
156 | 156 | if isinstance(dep, Symbol): |
157 | 157 | _collect_deps(dep, depth + 1) |
158 | | - |
| 158 | + |
159 | 159 | _collect_deps(self, current_depth) |
160 | 160 | all_deps = [] |
161 | 161 | for deps in dependency_map.values(): |
|
0 commit comments