public List<Block> generateSubBlocks() {

    //For binary expressions
    PsiElement blockPsi = myNode.getPsi();
    IElementType elementType = myNode.getElementType();

    if (blockPsi instanceof GrBinaryExpression && !(blockPsi.getParent() instanceof GrBinaryExpression)) {
      return generateForBinaryExpr();
    }

    //For multiline strings
    if (GroovyTokenSets.STRING_LITERALS.contains(elementType) && myBlock.getTextRange().equals(myNode.getTextRange())) {
      String text = myNode.getText();
      if (text.length() > 6) {
        if (text.startsWith("'''") && text.endsWith("'''") ||
            text.startsWith("\"\"\"") && text.endsWith("\"\"\"")) {
          return generateForMultiLineString();
        }
      }
    }

    //for gstrings
    if (elementType == GroovyElementTypes.GSTRING ||
        elementType == GroovyElementTypes.REGEX ||
        elementType == GroovyTokenTypes.mREGEX_LITERAL ||
        elementType == GroovyTokenTypes.mDOLLAR_SLASH_REGEX_LITERAL) {
      boolean isPlainGString = myNode.getPsi() instanceof GrString && ((GrString)myNode.getPsi()).isPlainString();
      final FormattingContext context = isPlainGString ? myContext.createContext(true, true) : myContext.createContext(false, true);

      final ArrayList<Block> subBlocks = new ArrayList<>();
      ASTNode[] children = getGroovyChildren(myNode);
      for (ASTNode childNode : children) {
        if (childNode.getTextRange().getLength() > 0) {
          subBlocks.add(context.createBlock(childNode, getIndent(childNode), Wrap.createWrap(WrapType.NONE, false)));
        }
      }
      return subBlocks;
    }

    final CommonCodeStyleSettings settings = myContext.getSettings();
    // chained properties, calls, indexing, etc
    if (NESTED.contains(elementType) && blockPsi.getParent() != null && !NESTED.contains(blockPsi.getParent().getNode().getElementType())) {
      final List<Block> subBlocks = new ArrayList<>();
      AlignmentProvider.Aligner dotsAligner = settings.ALIGN_MULTILINE_CHAINED_METHODS ? myAlignmentProvider.createAligner(false) : null;

      final Wrap wrap = myWrappingProcessor.getChainedMethodCallWrap();
      addNestedChildren(myNode.getPsi(), subBlocks, dotsAligner, true, wrap);
      return subBlocks;
    }

    if (blockPsi instanceof GrListOrMap && ((GrListOrMap)blockPsi).isMap() && myContext.getGroovySettings().ALIGN_NAMED_ARGS_IN_MAP) {
      AlignmentProvider.Aligner labels = myAlignmentProvider.createAligner(false);
      AlignmentProvider.Aligner exprs = myAlignmentProvider.createAligner(true);
      GrNamedArgument[] namedArgs = ((GrListOrMap)blockPsi).getNamedArguments();
      for (GrNamedArgument arg : namedArgs) {
        GrArgumentLabel label = arg.getLabel();
        if (label != null) labels.append(label);

        PsiElement colon = arg.getColon();
        if (colon == null) colon = arg.getExpression();
        if (colon != null) exprs.append(colon);
      }
    }

    if (blockPsi instanceof GrParameterList) {
      final List<ASTNode> children = visibleChildren(myNode);
      if (settings.ALIGN_MULTILINE_METHOD_BRACKETS) {
        PsiElement lParen = ((GrParameterList)blockPsi).getLParen();
        if (lParen != null) {
          PsiElement rParen = ((GrParameterList)blockPsi).getRParen();
          if (rParen != null) {
            myAlignmentProvider.addPair(lParen, rParen, false);
          }
        }
      }
      if (settings.ALIGN_MULTILINE_PARAMETERS) {
        final AlignmentProvider.Aligner aligner = myAlignmentProvider.createAligner(false);
        for (ASTNode node : children) {
          if (isKeyword(node)) continue;
          IElementType type = node.getElementType();
          if (type == T_LPAREN || type == T_RPAREN) continue;
          aligner.append(node.getPsi());
        }
      }
      return getGenericBlocks(children);
    }

    // For Parameter lists
    if (isListLikeClause(blockPsi)) {
      List<ASTNode> astNodes = visibleChildren(myNode);

      if (mustAlign(blockPsi, astNodes)) {
        final AlignmentProvider.Aligner aligner = myAlignmentProvider.createAligner(false);
        for (ASTNode node : astNodes) {
          if (!isKeyword(node)) aligner.append(node.getPsi());
        }
      }
      return getGenericBlocks(astNodes);
    }

    if (blockPsi instanceof GrSwitchElement) {
      final ArrayList<Block> subBlocks = new ArrayList<>();
      final ArrayList<Block> bodyBlocks = new ArrayList<>();
      List<ASTNode> astNodes = visibleChildren(myNode);
      boolean switchBody = false;
      for (ASTNode childNode : astNodes) {
        if (childNode.getElementType() == mLCURLY) {
          switchBody = true;
        }

        if (switchBody) {
          bodyBlocks.add(myContext.createBlock(childNode, getIndent(childNode), getChildWrap(childNode)));
        }
        else {
          subBlocks.add(myContext.createBlock(childNode, getIndent(childNode), getChildWrap(childNode)));
        }
      }
      if (!bodyBlocks.isEmpty()) {
        subBlocks.add(createSwitchBodyBlock(bodyBlocks));
      }
      return subBlocks;
    }

    boolean classLevel = blockPsi instanceof GrTypeDefinitionBody;
    if (blockPsi instanceof GrClosableBlock closableBlock &&
        closableBlock.getArrow() != null &&
        closableBlock.getParameters().length > 0 &&
        !getClosureBodyVisibleChildren(myNode).isEmpty()) {

      ArrayList<Block> blocks = new ArrayList<>();

      PsiElement lbrace = closableBlock.getLBrace();
      {
        ASTNode node = lbrace.getNode();
        blocks.add(myContext.createBlock(node, getIndent(node), Wrap.createWrap(WrapType.NONE, false)));
      }

      {
        Indent indent = getNormalIndent();
        ASTNode parameterListNode = closableBlock.getParameterList().getNode();
        boolean simpleClosure = shouldHandleAsSimpleClosure(closableBlock, settings);
        FormattingContext closureContext = myContext.createContext(simpleClosure, simpleClosure);
        ClosureBodyBlock bodyBlock = new ClosureBodyBlock(parameterListNode, indent, Wrap.createWrap(WrapType.NONE, false), closureContext);
        blocks.add(bodyBlock);
      }

      PsiElement rbrace = closableBlock.getRBrace();
      if (rbrace != null) {
        ASTNode node = rbrace.getNode();
        blocks.add(myContext.createBlock(node, getIndent(node), Wrap.createWrap(WrapType.NONE, false)));
      }

      return blocks;
    }

    if (blockPsi instanceof GrClosableBlock) {
      FormattingContext oldContext = myContext;
      try {
        boolean simpleClosure = shouldHandleAsSimpleClosure((GrClosableBlock)blockPsi, settings);
        myContext = myContext.createContext(simpleClosure, simpleClosure);
        return generateCodeSubBlocks(visibleChildren(myNode));
      } finally {
        myContext = oldContext;
      }
    }

    if (blockPsi instanceof GrCodeBlock || blockPsi instanceof GroovyFile) {
      return generateCodeSubBlocks(visibleChildren(myNode));
    }
    if (classLevel) {
      List<ASTNode> children = visibleChildren(myNode);
      calculateAlignments(children, true);
      return generateSubBlocks(children);
    }

    if (blockPsi instanceof GrTraditionalForClause) {
      if (settings.ALIGN_MULTILINE_FOR) {
        final GrTraditionalForClause clause = (GrTraditionalForClause)blockPsi;
        final AlignmentProvider.Aligner parenthesesAligner = myAlignmentProvider.createAligner(false);
        parenthesesAligner.append(clause.getInitialization());
        parenthesesAligner.append(clause.getCondition());
        parenthesesAligner.append(clause.getUpdate());
      }
    }

    else if (blockPsi instanceof GrBinaryExpression) {
      if (settings.ALIGN_MULTILINE_BINARY_OPERATION) {
        final GrBinaryExpression binary = (GrBinaryExpression)blockPsi;

        final GrExpression left = binary.getLeftOperand();
        final GrExpression right = binary.getRightOperand();
        if (right != null) {
          myAlignmentProvider.addPair(left, right, false);
        }
      }
    }

    else if (blockPsi instanceof GrAssignmentExpression) {
      if (settings.ALIGN_MULTILINE_ASSIGNMENT) {
        final GrAssignmentExpression assignment = (GrAssignmentExpression)blockPsi;

        final GrExpression lValue = assignment.getLValue();
        final GrExpression rValue = assignment.getRValue();
        if (rValue != null) {
          myAlignmentProvider.addPair(lValue, rValue, false);
        }
      }
    }

    else if (blockPsi instanceof GrConditionalExpression) {
      if (settings.ALIGN_MULTILINE_TERNARY_OPERATION) {
        final GrConditionalExpression conditional = (GrConditionalExpression)blockPsi;

        final AlignmentProvider.Aligner exprAligner = myAlignmentProvider.createAligner(false);
        exprAligner.append(conditional.getCondition());
        if (!(conditional instanceof GrElvisExpression)) {
          exprAligner.append(conditional.getThenBranch());
        }
        exprAligner.append(conditional.getElseBranch());

        ASTNode question = conditional.getNode().findChildByType(GroovyTokenTypes.mQUESTION);
        ASTNode colon = conditional.getNode().findChildByType(GroovyTokenTypes.mCOLON);
        if (question != null && colon != null) {
          AlignmentProvider.Aligner questionColonAligner = myAlignmentProvider.createAligner(false);
          questionColonAligner.append(question.getPsi());
          questionColonAligner.append(colon.getPsi());
        }
      }
    }

    // For other cases
    return getGenericBlocks(visibleChildren(myNode));
  }
public List<Block> generateSubBlocks()