Reads the indent from .editorconfig, or from the caller
All 10 scenarios hold
The formatter carries no indent setting of its own. It asks EditorConfig, the convention the surrounding project already states. The search starts in the directory of the source file and walks up. The indent_style and indent_size it finds become the style and the size the Indentation feature applies.
The formatter resolves the style and the size one at a time. A file that sets only one of them leaves the caller's default in force for the other. Anything else the search cannot use leaves both defaults in force. A broken .editorconfig never fails a build.
Each row writes the file it shows into a temporary project with one Java source file. An indent takes the form style:size.
expected outcome
broken scenario
| Scenario | Config file lines | Sits | Caller's default | Indent used? |
|---|---|---|---|---|
| Two-space Java indent |
| BESIDE | space:4 | space:2 |
| Tabs, one per level |
| BESIDE | space:4 | tab:1 |
| Setting from a parent |
| ANCESTOR | space:4 | tab:1 |
| A file that ends the search |
| BESIDE | space:4 | space:4 |
| A style but no size |
| BESIDE | space:4 | tab:4 |
| A size but no style |
| BESIDE | tab:1 | tab:2 |
| A section for other files |
| BESIDE | space:4 | space:4 |
| No .editorconfig at all | [] | NOWHERE | space:4 | space:4 |
| A file that cannot be read |
| BESIDE | space:4 | space:4 |
| Caller asking for no indent | [] | NOWHERE | space:0 | space:0 |