|
| 1 | +# Crontab Plugin |
| 2 | + |
| 3 | +JetBrains IDE plugin providing crontab/cron syntax support: highlighting, inspections, completions, folding, inlay |
| 4 | +hints, and crontab.guru integration. |
| 5 | + |
| 6 | +## Tech Stack |
| 7 | + |
| 8 | +- Kotlin (JVM 17), Gradle (Kotlin DSL) |
| 9 | +- IntelliJ Platform Plugin SDK (`org.jetbrains.intellij.platform` plugin) |
| 10 | +- GrammarKit: BNF grammar (`Crontab.bnf`) + JFlex lexer (`Crontab.flex`) |
| 11 | +- Target platform: PhpStorm (PS), since build 242 |
| 12 | +- Depends on `com.jetbrains.sh` (Shell Script plugin) |
| 13 | + |
| 14 | +## Project Structure |
| 15 | + |
| 16 | +``` |
| 17 | +src/main/kotlin/com/github/xepozz/crontab/ |
| 18 | + language/ # Language definition: file type, lexer adapter, parser, syntax highlighter, annotator, injector |
| 19 | + parser/ # Crontab.bnf (grammar), Crontab.flex (lexer), parser definition |
| 20 | + psi/ # PSI element types, tokens, visitors, impl utilities, base classes |
| 21 | + ide/ # IDE features |
| 22 | + actions/ # CrontabGuruIntention, OpenCrontabGuruAction, RunCommandAction |
| 23 | + completion/ # CrontabShortcutCompletionContributor |
| 24 | + describe/ # CronScheduleDescriber (human-readable descriptions) |
| 25 | + documentation/ # CrontabDocumentationProvider |
| 26 | + editor/ # EditorNotificationProvider |
| 27 | + inspections/ # CrontabScheduleTimeRangeInspection, CronPatterns, quick fixes |
| 28 | + structureView/ # Structure view factory/model |
| 29 | + Cron*.kt # Folding builder, commenter, inlay hints, run markers, time range utils |
| 30 | +src/main/gen/ # Generated parser & PSI (from BNF/flex, gitignored) |
| 31 | +src/main/resources/ |
| 32 | + META-INF/plugin.xml # Plugin descriptor |
| 33 | + messages/ # CrontabBundle (i18n) |
| 34 | +playground/ # Sample crontab files for testing |
| 35 | +``` |
| 36 | + |
| 37 | +## Build & Run |
| 38 | + |
| 39 | +```bash |
| 40 | +./gradlew build # Build the plugin |
| 41 | +./gradlew runIde # Run IDE sandbox with plugin installed |
| 42 | +./gradlew test # Run tests |
| 43 | +./gradlew buildPlugin # Build distributable plugin zip |
| 44 | +./gradlew publishPlugin # Publish to JetBrains Marketplace |
| 45 | +``` |
| 46 | + |
| 47 | +## Key Conventions |
| 48 | + |
| 49 | +- Generated code lives in `src/main/gen/` and is gitignored. Do NOT edit files there manually. Regenerate from |
| 50 | + `Crontab.bnf` and `Crontab.flex` using GrammarKit/JFlex in IDE. |
| 51 | +- PSI base classes (`*BaseImpl.kt`) extend generated PSI and add custom logic (e.g., `CrontabScheduleBaseImpl`, |
| 52 | + `CrontabTimeRangeBaseImpl`). |
| 53 | +- Utility methods used by generated PSI are in `CrontabImplUtil.kt` (referenced via `psiImplUtilClass` in BNF). |
| 54 | +- Plugin version follows `YYYY.MAJOR.MINOR` format (e.g., `2026.1.1`), set in `gradle.properties`. |
| 55 | +- Versions and plugin dependencies are managed in `gradle.properties` and `gradle/libs.versions.toml`. |
| 56 | +- Plugin descriptor: `src/main/resources/META-INF/plugin.xml`. Plugin description is extracted from `README.md` between |
| 57 | + `<!-- Plugin description -->` markers. |
| 58 | +- i18n strings are in `messages/CrontabBundle`. |
| 59 | + |
| 60 | +## Crontab Grammar |
| 61 | + |
| 62 | +Standard 5-field cron: `minute hour day month weekday command` |
| 63 | +Also supports: `@shortcut command`, variable definitions (`KEY=VALUE`), comments (`#`). |
| 64 | +Time fields support: exact numbers, ranges (`1-5`), steps (`*/2`, `1-5/2`), lists (`1,3,5`), wildcards (`*`), named |
| 65 | +days (`MON-FRI`), named months (`JAN-DEC`). |
0 commit comments