From fb13b9dec4725562ba2034c608205bcb309504c8 Mon Sep 17 00:00:00 2001 From: Yaroslav Lepenkin Date: Fri, 17 Jun 2016 18:42:44 +0300 Subject: [PATCH] [indent-detector] do not build injected blocks in xml --- .../autodetect/AbstractIndentAutoDetectionTest.java | 10 +++++++--- .../intellij/psi/formatter/xml/AbstractXmlBlock.java | 7 +++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/platform/platform-tests/testSrc/com/intellij/psi/autodetect/AbstractIndentAutoDetectionTest.java b/platform/platform-tests/testSrc/com/intellij/psi/autodetect/AbstractIndentAutoDetectionTest.java index 1dc0817e7349..ca14e158a157 100644 --- a/platform/platform-tests/testSrc/com/intellij/psi/autodetect/AbstractIndentAutoDetectionTest.java +++ b/platform/platform-tests/testSrc/com/intellij/psi/autodetect/AbstractIndentAutoDetectionTest.java @@ -56,8 +56,14 @@ public abstract class AbstractIndentAutoDetectionTest extends LightPlatformCodeI } protected void doTestIndentSize(int expectedIndent) { + configureByFile(getFileNameWithExtension()); doTestIndentSize(null, expectedIndent); } + + protected void doTestIndentSizeFromText(String text, @Nullable CommonCodeStyleSettings.IndentOptions options, int expectedIndent) { + configureFromFileText(getFileNameWithExtension(), text); + doTestIndentSize(options, expectedIndent); + } protected void doTestTabsUsed(@Nullable CommonCodeStyleSettings.IndentOptions defaultIndentOptions) { configureByFile(getFileNameWithExtension()); @@ -70,9 +76,7 @@ public abstract class AbstractIndentAutoDetectionTest extends LightPlatformCodeI Assert.assertTrue("Tab usage not detected", options.USE_TAB_CHARACTER); } - private void doTestIndentSize(@Nullable CommonCodeStyleSettings.IndentOptions defaultIndentOptions, int expectedIndent) { - configureByFile(getFileNameWithExtension()); - + private static void doTestIndentSize(@Nullable CommonCodeStyleSettings.IndentOptions defaultIndentOptions, int expectedIndent) { if (defaultIndentOptions != null) { setIndentOptions(defaultIndentOptions); } diff --git a/xml/impl/src/com/intellij/psi/formatter/xml/AbstractXmlBlock.java b/xml/impl/src/com/intellij/psi/formatter/xml/AbstractXmlBlock.java index 324d9d1f5537..e3a23d3aa87a 100644 --- a/xml/impl/src/com/intellij/psi/formatter/xml/AbstractXmlBlock.java +++ b/xml/impl/src/com/intellij/psi/formatter/xml/AbstractXmlBlock.java @@ -201,10 +201,11 @@ public abstract class AbstractXmlBlock extends AbstractBlock { processSimpleChild(child, indent, result, wrap, alignment); return child; } - else { + else if (!isBuildIndentsOnly()) { myInjectedBlockBuilder.addInjectedLanguageBlockWrapper(result, child, indent, 0, null); - return child; } + + return child; } protected boolean doesNotIntersectSubTagsWith(final PsiElement tag) { @@ -435,6 +436,8 @@ public abstract class AbstractXmlBlock extends AbstractBlock { } protected boolean buildInjectedPsiBlocks(List result, final ASTNode child, Wrap wrap, Alignment alignment, Indent indent) { + if (isBuildIndentsOnly()) return false; + if (myInjectedBlockBuilder.addInjectedBlocks(result, child, wrap, alignment, indent)) { return true; }