Spacing (final AbstractSyntheticBlock syntheticBlock1, final AbstractSyntheticBlock syntheticBlock2) { if (syntheticBlock2.startsWithCDATA() || syntheticBlock1.endsWithCDATA()) { return Spacing.getReadOnlySpacing(); } if (syntheticBlock1.containsCDATA() && syntheticBlock2.isTagDescription() || syntheticBlock1.isTagDescription() && syntheticBlock2.containsCDATA()) { int lineFeeds = 0; switch (myXmlFormattingPolicy.getWhiteSpaceAroundCDATAOption()) { case XmlCodeStyleSettings.WS_AROUND_CDATA_NONE -> { } case XmlCodeStyleSettings.WS_AROUND_CDATA_NEW_LINES -> lineFeeds = 1; case XmlCodeStyleSettings.WS_AROUND_CDATA_PRESERVE -> { return Spacing.getReadOnlySpacing(); } default -> { assert false : "Unexpected whitespace around CDATA code style option."; } } return Spacing.createSpacing(0, 0, lineFeeds, myXmlFormattingPolicy.getShouldKeepLineBreaks(), myXmlFormattingPolicy.getKeepBlankLines()); } if (syntheticBlock2.isJspTextBlock() || syntheticBlock1.isJspTextBlock()) { return Spacing.createSafeSpacing(myXmlFormattingPolicy.getShouldKeepLineBreaks(), myXmlFormattingPolicy.getKeepBlankLines()); } if (syntheticBlock2.isJspxTextBlock() || syntheticBlock1.isJspxTextBlock()) { return Spacing.createSpacing(0, 0, 1, myXmlFormattingPolicy.getShouldKeepLineBreaks(), myXmlFormattingPolicy.getKeepBlankLines()); } if (myXmlFormattingPolicy.keepWhiteSpacesInsideTag(getTag())) return Spacing.getReadOnlySpacing(); if (myXmlFormattingPolicy.getShouldKeepWhiteSpaces()) { return Spacing.getReadOnlySpacing(); } if (syntheticBlock2.startsWithTag()) { final XmlTag startTag = syntheticBlock2.getStartTag(); if (myXmlFormattingPolicy.keepWhiteSpacesInsideTag(startTag) && startTag.textContains('\n')) { return getChildrenIndent() != Indent.getNoneIndent() ? Spacing.getReadOnlySpacing() : Spacing.createSpacing(0, 0, 0, true, myXmlFormattingPolicy.getKeepBlankLines()); } } boolean saveSpacesBetweenTagAndText = myXmlFormattingPolicy.shouldSaveSpacesBetweenTagAndText() && syntheticBlock1.getTextRange().getEndOffset() < syntheticBlock2.getTextRange().getStartOffset(); if (syntheticBlock1.endsWithTextElement() && syntheticBlock2.startsWithTextElement()) { return Spacing.createSafeSpacing(myXmlFormattingPolicy.getShouldKeepLineBreaksInText(), myXmlFormattingPolicy.getKeepBlankLines()); } if (syntheticBlock1.endsWithText()) { //text</tag if (syntheticBlock1.insertLineFeedAfter()) { return Spacing.createDependentLFSpacing(0, 0, getTag().getTextRange(), myXmlFormattingPolicy.getShouldKeepLineBreaks(), myXmlFormattingPolicy.getKeepBlankLines()); } if (saveSpacesBetweenTagAndText) { return Spacing.createSafeSpacing(myXmlFormattingPolicy.getShouldKeepLineBreaks(), myXmlFormattingPolicy.getKeepBlankLines()); } return Spacing.createSpacing(0, 0, 0, myXmlFormattingPolicy.getShouldKeepLineBreaks(), myXmlFormattingPolicy.getKeepBlankLines()); } else if (syntheticBlock1.isTagDescription() && syntheticBlock2.isTagDescription()) { //></ return Spacing.createSpacing(0, 0, 0, myXmlFormattingPolicy.getShouldKeepLineBreaks(), myXmlFormattingPolicy.getKeepBlankLines()); } else if (syntheticBlock2.startsWithText()) { //>text if (saveSpacesBetweenTagAndText) { return Spacing.createSafeSpacing(true, myXmlFormattingPolicy.getKeepBlankLines()); } return Spacing.createSpacing(0, 0, 0, true, myXmlFormattingPolicy.getKeepBlankLines()); } else if (syntheticBlock1.isTagDescription() && syntheticBlock2.startsWithTag()) { return Spacing.createSpacing(0, 0, myXmlFormattingPolicy.insertLineBreakAfterTagBegin(getTag()) ? 2 : 0, true, myXmlFormattingPolicy.getKeepBlankLines()); } else if (syntheticBlock1.insertLineFeedAfter()) { return Spacing.createSpacing(0, 0, 1, true, myXmlFormattingPolicy.getKeepBlankLines()); } else if (syntheticBlock1.endsWithTag() && syntheticBlock2.isTagDescription()) { return Spacing.createSpacing(0, 0, myXmlFormattingPolicy.insertLineBreakAfterTagBegin(getTag()) ? 2 : 0, true, myXmlFormattingPolicy.getKeepBlankLines()); } else { return createDefaultSpace(true, true); } }