Skip to content

Commit b28bf59

Browse files
committed
. d Intellij Mircofeature
1 parent 4bda03e commit b28bf59

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# IntelliJReporter
2+
3+
## Purpose
4+
Automatically detects a running JetBrains IDE process and uses it to display diffs when an approval test fails — no manual configuration required.
5+
6+
## Behavior
7+
1. **Scans running processes**: Uses `ProcessHandle` (via reflection for Java 8 compatibility) to list all running OS processes
8+
2. **Identifies JetBrains IDEs**: Looks for known keywords in process paths (`idea`, `pycharm`, `webstorm`, `phpstorm`, `goland`, `rider`, `clion`, `rubymine`, `appcode`, `datagrip`)
9+
3. **Verifies it's the main executable**: Checks that the path ends with `macos/<keyword>` or contains `bin/<keyword>` or `bin\<keyword>` to avoid matching helper processes
10+
4. **Returns the path**: Returns the first matching executable path, or `""` if none found
11+
5. **Falls back gracefully**: If no JetBrains IDE is running, the reporter path is empty and `GenericDiffReporter` will report itself as unavailable
12+
13+
## Usage Example
14+
```java
15+
// Use the singleton
16+
Approvals.verify("text", new Options().withReporter(IntelliJReporter.INSTANCE));
17+
18+
// Or register as the default reporter
19+
```
20+
21+
## Supported IDEs
22+
- IntelliJ IDEA (`idea`)
23+
- PyCharm (`pycharm`)
24+
- WebStorm (`webstorm`)
25+
- PhpStorm (`phpstorm`)
26+
- GoLand (`goland`)
27+
- Rider (`rider`)
28+
- CLion (`clion`)
29+
- RubyMine (`rubymine`)
30+
- AppCode (`appcode`)
31+
- DataGrip (`datagrip`)
32+
33+
## Diff Command
34+
Uses `diff %s %s` with the detected IDE executable, passing the received file and approved file as arguments.
35+
36+
## Integration
37+
`IntelliJReporter` is part of the reporter auto-detection chain. `findJetBrainsIdes(String[])` is public and testable independently of running processes.

0 commit comments

Comments
 (0)