LeafBlockWrapper applyAlignment(final AlignmentImpl alignment, final LeafBlockWrapper currentBlock) {
    BlockAlignmentProcessor alignmentProcessor = ALIGNMENT_PROCESSORS.get(alignment.getAnchor());
    if (alignmentProcessor == null) {
      LOG.error(String.format("Can't find alignment processor for alignment anchor %s", alignment.getAnchor()));
      return null;
    }

    BlockAlignmentProcessor.Context context = new BlockAlignmentProcessor.Context(
      myDocument, alignment, currentBlock, myAlignmentMappings, myBackwardShiftedAlignedBlocks,
      myBlockIndentOptions.getIndentOptions(currentBlock));
    final LeafBlockWrapper offsetResponsibleBlock = alignment.getOffsetRespBlockBefore(currentBlock);
    if (offsetResponsibleBlock != null) {
      if (!myCyclesDetector.registerRealignment(offsetResponsibleBlock, currentBlock)) {
        reportAlignmentProcessingError(context);
        return null;
      }
    }
    BlockAlignmentProcessor.Result result = alignmentProcessor.applyAlignment(context);
    return switch (result) {
      case TARGET_BLOCK_PROCESSED_NOT_ALIGNED -> null;
      case TARGET_BLOCK_ALIGNED -> {
        storeAlignmentMapping(currentBlock);
        yield null;
      }
      case BACKWARD_BLOCK_ALIGNED -> {
        if (offsetResponsibleBlock == null) {
          yield null;
        }
        Set<LeafBlockWrapper> blocksCausedRealignment = new HashSet<>();
        myBackwardShiftedAlignedBlocks.clear();
        myBackwardShiftedAlignedBlocks.put(offsetResponsibleBlock, blocksCausedRealignment);
        blocksCausedRealignment.add(currentBlock);
        storeAlignmentMapping(currentBlock, offsetResponsibleBlock);
        yield offsetResponsibleBlock.getNextBlock();
      }
      case RECURSION_DETECTED -> {
        myAlignmentsToSkip.add(alignment);
        yield offsetResponsibleBlock; // Fall through to the 'register alignment to skip'.
      }
      case UNABLE_TO_ALIGN_BACKWARD_BLOCK -> {
        myAlignmentsToSkip.add(alignment);
        yield null;
      }
    };
  }
LeafBlockWrapper applyAlignment(final AlignmentImpl alignment, final LeafBlockWrapper currentBlock)