Skip to content

feat(java): detect @Scheduled methods and emit TRIGGERS edges#590

Open
YutenC wants to merge 1 commit into
tirth8205:mainfrom
YutenC:feat/spring-scheduled-triggers
Open

feat(java): detect @Scheduled methods and emit TRIGGERS edges#590
YutenC wants to merge 1 commit into
tirth8205:mainfrom
YutenC:feat/spring-scheduled-triggers

Conversation

@YutenC

@YutenC YutenC commented Jun 30, 2026

Copy link
Copy Markdown

Problem

Spring @Scheduled methods are scheduler entry points with no static caller in the codebase. CRG previously had no way to discover them via graph queries — users had to fall back to rg "@Scheduled".

Solution

Emit TRIGGERS edges from virtual scheduler source nodes to annotated methods at parse time. No post-build resolver needed — schedule parameters are statically present in the annotation.

@Scheduled param Source node
cron = "..." SCHEDULER::cron
fixedRate = N SCHEDULER::fixedRate
fixedDelay = N SCHEDULER::fixedDelay
(none / unrecognised) SCHEDULER::scheduled

Schedule metadata (cron expression, rate value, etc.) is stored in edge extra for traceability.

Usage after this change

# Find all methods the scheduler triggers
query_graph(callers_of="SCHEDULER::cron")
query_graph(callers_of="SCHEDULER::fixedRate")

Changes

  • code_review_graph/parser.py_SPRING_SCHEDULED_ANNOTATIONS constant + _emit_scheduled_edges_from_method() + hook in _extract_functions
  • tests/fixtures/ScheduledTasks.java — fixture with cron / fixedRate / fixedDelay / plain methods
  • tests/test_multilang.pyTestSpringScheduledParsing (8 assertions)

Spring @scheduled methods are scheduler entry points with no static
caller in the codebase. CRG previously had no way to discover them
via graph queries, forcing users to fall back to Grep.

This change emits TRIGGERS edges from virtual scheduler source nodes
to the annotated method:
  - SCHEDULER::cron     <- @scheduled(cron = "...")
  - SCHEDULER::fixedRate <- @scheduled(fixedRate = N)
  - SCHEDULER::fixedDelay <- @scheduled(fixedDelay = N)
  - SCHEDULER::scheduled  <- unrecognised / missing schedule param

Schedule metadata (cron expression, fixedRate value, etc.) is stored
in edge extra for traceability.

No post-build resolver is required — schedule parameters are
statically present in the annotation.

Tests: TestSpringScheduledParsing (8 assertions) in test_multilang.py
Fixture: tests/fixtures/ScheduledTasks.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant