5.2 KiB
5.2 KiB
Execution Plan for Extended Analysis (Revised for Robustness)
Phase 0: Surgical Refactoring (The Enrichment Hook)
- Create
AnalysisResultandCodebaseMetadatamodels. - Update
ExportService.generateOutputsto acceptAnalysisResult. - Implement
EnrichmentServiceandAnalysisEnricherinterface. - Wrap current parser outputs in
AnalysisResultwithinExportService.
Phase 1: Foundation & Semantic Core
- JDT Binding Resolution: Configure
ASTParserwith project classpath andsetResolveBindings(true). - Workspace Scoping: Implement scanner with configurable exclude patterns (
test/,build/,node_modules/). - ConstantResolver: Implement lookup for
public static finalconstants across class boundaries using JDT bindings. - Basic PropertyResolver: Scan
application.properties/ymlfor simple key-value pairs. - Implement
JdtIntelligenceProvideras the primary semantic analyzer.
Phase 2: Trigger Discovery & Instance Identity
- GenericEventDetector: Find
sendEventcalls usingASTVisitor. - InstanceIdentifier: Detect which State Machine is being targeted (via
@Qualifier, bean names, or generic typesStateMachine<S, E>). - Trigger Filter: Link
sendEventcalls to specific SM instances to avoid noise in multi-SM projects. - Enhance
CodebaseContextto provide mapping fromMethodDeclarationto its callers using bindings.
Phase 3: Entry Point Mapping
- SpringMvcDetector: Detect REST endpoints (using
ConstantResolverfor paths). - MessageListenerDetector: Detect Kafka/JMS listeners (using
ConstantResolverfor topics/queues). - ConfigurableTriggerDetector: Support user-defined patterns for custom frameworks.
Phase 4: Call Graph Integration
- Develop a call graph builder to link
Entry PointstoTrigger Pointsvia intermediate service calls. - Support inheritance in call graph resolution (using JDT bindings to resolve method overrides).
Phase 4.5: Hierarchical Robustness (Inheritance Support)
- Hierarchical Annotation Lookup: Update
SpringMvcDetectorto scan interfaces and superclasses for inherited mapping annotations. - Interface Implementation Mapping: Enhance
CodebaseContextto index "Class -> Interfaces" and "Interface -> Classes" relationships. - Polymorphic Call Trace: Update
CallGraphBuilderto follow calls from an interface method to all known implementations in the project. - Base Class Trigger Discovery: Ensure triggers in abstract base classes are correctly attributed to their concrete subclasses.
Phase 5: Visualization & Diagnostics
- Update
ExportServiceto include trigger information. - Update DOT/SCXML exporters to show entry points.
- Diagnostic Nodes: Show "Potential/Unresolved Trigger" nodes when a
sendEventis found but the event name or SM instance cannot be resolved.
Phase 6: Validation (Milestone 1)
- Create a "Complex Sample Project" with REST controllers, services, and multiple state machines.
- Add unit tests for each detector and the aggregator.
- Verify that inheritance in both state machine config and controllers is correctly handled.
Phase 7: Advanced Resolution & Data Flow
- Variable Propagation: Track values from fields/constructors to their usage in the State Machine configuration (e.g., resolving
initial(initialState)whereinitialStateis a field). - @Value Resolution: Link
@Valueannotations to thePropertyResolverto substitute placeholders with literal values in the diagram. - Spring Profile Support: Update
PropertyResolverto handleapplication-{profile}.propertiesand prioritize them based on an "active profiles" setting. - Complex ValueResolver: Handle string concatenations (e.g.,
"PREFIX_" + MyConstants.SUFFIX) and variable references. - Payload Analysis: Extract payload types from entry points and track field usage in
sendEventcalls.
Phase 8: Persistence & Lifecycle Mapping
- Detect persistence restoration logic (
persister.restore). - Map "Resume" points where the machine state is loaded from a DB based on external identifiers.
- Update metadata to distinguish between "New Instance" and "Restored Instance" triggers.
Phase 9: Advanced Ecosystem Support
- Reactive Chains: Analyze WebFlux/Project Reactor lambdas (
doOnNext,flatMap) for hidden triggers. - Interceptors & Filters: Detect
HandlerInterceptorandFilterimplementations and map them to endpoints.
Phase 10: External Dependency Interop
- Library Hints: Implementation complete. Supports
hints.jsonin project root orsrc/main/resources/.- Format:
[{"methodFqn": "class.method", "event": "EVENT"}] - Purpose: Maps external/compiled library calls to State Machine events when source code is unavailable.
- Format:
- External JAR Analysis: (Optional) Configure JDT to scan source-attachments of dependencies if available.
Note on Library Hints: This feature is an optional "Power User" escape hatch. The analyzer works automatically for all local source code; hints.json is only required to bridge the gap for third-party libraries.