diff --git a/platform/code-style-impl/src/com/intellij/formatting/engine/AlignmentHelper.java b/platform/code-style-impl/src/com/intellij/formatting/engine/AlignmentHelper.java index 00077ebe12cc..4c2ce32c749c 100644 --- a/platform/code-style-impl/src/com/intellij/formatting/engine/AlignmentHelper.java +++ b/platform/code-style-impl/src/com/intellij/formatting/engine/AlignmentHelper.java @@ -20,12 +20,34 @@ public class AlignmentHelper { ALIGNMENT_PROCESSORS.put(Alignment.Anchor.RIGHT, new RightEdgeAlignmentProcessor()); } + /** + * There is a possible case that we detect a 'cycled alignment' rules (see {@link #myBackwardShiftedAlignedBlocks}). We want + * just to skip processing for such alignments then. + *
+ * This container holds 'bad alignment' objects that should not be processed. + */ private final Set+ * int i1 = 1; + * int i2, i3 = 2; + *+ * + * There is a possible case that
'i1', 'i2' and 'i3' blocks re-use
+ * the same alignment, hence, 'i1' is shifted to right during 'i3' processing but
+ * that causes 'i2' to be shifted right as wll because it's aligned to 'i1' that
+ * increases offset of 'i3' that, in turn, causes backward shift of 'i1' etc.
+ *
+ * This map remembers such backward shifts in order to be able to break such infinite cycles.
+ */
private final Map