code_formatting.md: add hint about inspecting formatting blocks

This commit is contained in:
Karol Lewandowski 2022-01-11 16:01:39 +01:00
parent 61d8e594a7
commit b6db963733
2 changed files with 5 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 197 KiB

View File

@ -27,6 +27,11 @@ Its children cover individual classes in the file, blocks on the next level cove
The formatter modifies only the characters between blocks, and the tree of blocks must be built so that the bottom-level blocks cover all non-whitespace characters in the file.
Otherwise, the characters between blocks may be deleted by the formatter.
For better understanding how to build the blocks structure, use [PsiViewer](https://plugins.jetbrains.com/docs/intellij/explore-api.html#31-use-internal-mode-and-psiviewer) and inspect formatting
blocks built for an existing language:
![Formatting Blocks Structure](psi_viewer_formatting_blocks.png){width="720"}
If the formatting operation does not affect the entire file (for example, if the formatter is called to format the pasted block of text), a complete tree of blocks is not built.
Rather, only blocks for the text range covered by the formatting operation and their parents are built.