Language Specific Resolvers
Relevant source files
The following files were used as context for generating this wiki page:
Language Specific Resolvers are specialized modules within the code-review-graph project designed to enhance the accuracy of the structural knowledge graph. While the primary parser uses Tree-sitter for general syntax extraction, these resolvers handle complex, language-specific patterns that cannot be fully resolved through static syntax analysis alone, such as Dependency Injection (DI) in Java, path aliases in TypeScript, and dynamic type resolution in Python.
The primary purpose of these resolvers is to map ambiguous "bare" references (like a method call on an interface) to their concrete implementations or actual file paths. This ensures that features like impact analysis, dead code detection, and execution flow tracing remain accurate even in projects utilizing modern frameworks and advanced configuration patterns.
Sources: code_review_graph/parser.py:27-30, code_review_graph/spring_resolver.py:1-10
Java Framework Resolvers
The project includes specialized logic for resolving dependencies within the Java ecosystem, specifically targeting the Spring Framework and Temporal workflows. These resolvers work by analyzing metadata captured during the parsing phase, such as annotations and interface relationships.
Spring Dependency Injection Resolver
The Spring resolver addresses the ambiguity of Dependency Injection. In Spring, a class might call a method on an interface field (e.g., @Autowired private OrderRepository repo). Static analysis only sees the interface, but the spring_resolver.py maps these calls to the concrete @Repository or @Service implementation.
The resolver specifically looks for classes marked with @Component, @Service, or @Repository and matches them against INJECTS edges found in consumer classes.
Sources: code_review_graph/spring_resolver.py:12-45, code_review_graph/parser.py:317-321
Temporal Workflow Resolver
The Temporal resolver handles the unique "stub" pattern used in Temporal.io. Activities and Workflows are often invoked via stubs rather than direct instantiation. The temporal_resolver.py identifies fields designated as TEMPORAL_STUB (Activity or Workflow stubs) and links calls made through them to the actual methods defined in the interface implementations.
Sources: code_review_graph/temporal_resolver.py:10-50, code_review_graph/parser.py:328-331
JavaScript and TypeScript Resolvers
For the JavaScript and TypeScript ecosystems, the project focuses on resolving module paths and component references, particularly when non-standard configurations are present.
tsconfig Path Alias Resolver
Modern TypeScript projects often use path aliases (e.g., import { foo } from "@/utils") defined in a tsconfig.json. The TsconfigResolver class parses these configuration files to map aliases back to actual relative or absolute file paths.
| Feature | Description |
|---|---|
| Path Mapping | Maps prefixes like @/* or ~/* to specific source directories. |
| Config Discovery | Searches for tsconfig.json or jsconfig.json in parent directories. |
| Resolution Priority | Prioritizes specific aliases over wildcard patterns. |
Sources: code_review_graph/tsconfig_resolver.py:15-60, code_review_graph/parser.py:1418-1425
JSX Component Resolver
The parser handles React/JSX component invocations by treating uppercase tags as potential function calls. The resolver attempts to link these tags (e.g., <MyComponent />) to the corresponding file that exports that component, following barrel patterns (index files) if necessary.
Sources: code_review_graph/parser.py:1225-1240, code_review_graph/parser.py:1438-1455
Python Jedi Resolver
Python resolution presents challenges due to its dynamic nature. The project optionally utilizes the jedi library to provide deep type inference and call resolution.
Dynamic Type Inference
While the standard parser captures explicit imports, the JediResolver can resolve calls where the target is not immediately obvious from the local scope. It analyzes the context of a call to determine the most likely destination in the codebase.
Note: This resolver requires the code-review-graph[enrichment] extra to be installed.
Sources: code_review_graph/jedi_resolver.py:5-35, code_review_graph/parser.py:12-15
Summary of Resolver Capabilities
The following table summarizes the primary resolvers and the specific logic they implement:
| Language | Resolver Type | Target Problem | Key Logic |
|---|---|---|---|
| Java | Spring Resolver | Dependency Injection | Maps @Autowired interfaces to concrete @Repository types. |
| Java | Temporal Resolver | Distributed Workflows | Resolves calls made through Activity and Workflow stubs. |
| TypeScript | tsconfig Resolver | Path Aliases | Maps custom prefixes (e.g., @/) to real file paths. |
| Python | Jedi Resolver | Dynamic Resolution | Uses Jedi to infer types and resolve ambiguous call sites. |
| General | Cross-Module | Barrel Exports | Follows export * from chains to find original definitions. |
Sources: code_review_graph/spring_resolver.py, code_review_graph/temporal_resolver.py, code_review_graph/tsconfig_resolver.py, code_review_graph/jedi_resolver.py, code_review_graph/parser.py