diff --git a/java/java-tests/testData/psi/autodetect/KotlinComment.xml b/java/java-tests/testData/psi/autodetect/KotlinComment.xml
deleted file mode 100644
index cb4ea9b2607e..000000000000
--- a/java/java-tests/testData/psi/autodetect/KotlinComment.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/java/java-tests/testData/psi/autodetect/XmlContinuationWithoutFirst.xml b/java/java-tests/testData/psi/autodetect/XmlContinuationWithoutFirst.xml
deleted file mode 100644
index 59deea200bf8..000000000000
--- a/java/java-tests/testData/psi/autodetect/XmlContinuationWithoutFirst.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/java/java-tests/testData/psi/autodetect/firstBlockOnNewLineNotStartsIt.xml b/java/java-tests/testData/psi/autodetect/firstBlockOnNewLineNotStartsIt.xml
deleted file mode 100644
index 0beebd746e23..000000000000
--- a/java/java-tests/testData/psi/autodetect/firstBlockOnNewLineNotStartsIt.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/java/java-tests/testSrc/com/intellij/psi/codeStyle/autodetect/FormatterBasedLineInfoBuilderTest.java b/java/java-tests/testSrc/com/intellij/psi/codeStyle/autodetect/FormatterBasedLineInfoBuilderTest.java
index 8ed5cc75f174..0af0d0304f90 100644
--- a/java/java-tests/testSrc/com/intellij/psi/codeStyle/autodetect/FormatterBasedLineInfoBuilderTest.java
+++ b/java/java-tests/testSrc/com/intellij/psi/codeStyle/autodetect/FormatterBasedLineInfoBuilderTest.java
@@ -16,10 +16,10 @@
package com.intellij.psi.codeStyle.autodetect;
import com.intellij.JavaTestUtil;
-import com.intellij.formatting.FormattingModelXmlReader;
-import com.intellij.formatting.TestBlock;
-import com.intellij.formatting.TestFormattingModel;
+import com.intellij.formatting.engine.FormatterEngineTestsKt;
+import com.intellij.formatting.engine.TestData;
import com.intellij.openapi.editor.Document;
+import com.intellij.openapi.editor.EditorFactory;
import com.intellij.testFramework.LightPlatformCodeInsightTestCase;
import org.jdom.JDOMException;
import org.jetbrains.annotations.NotNull;
@@ -37,19 +37,19 @@ public class FormatterBasedLineInfoBuilderTest extends LightPlatformCodeInsightT
}
public void testKotlinComment() throws IOException, JDOMException {
- String text = "/**\n" +
- " *\n" +
- " */";
+ String text = "[i_cont]([i_norm]/**\n" +
+ " [i_norm]([i_space_1]*)\n" +
+ " [i_space_1]*/)";
List infos = getLineInfos(text);
assertLinesWithNormalIndent(infos, 0);
}
public void testXmlContinuationWithoutFirst() throws IOException, JDOMException {
- String text = "\n" +
- " \n" +
- " \n" +
- "";
+ String text = "[i_none]\n" +
+ " [i_none]([i_norm]([i_none]<[i_none]name/>)\n" +
+ " [i_norm]([i_none]([]<[i_none]id/>)))\n" +
+ "[i_none]";
List infos = getLineInfos(text);
assertLinesWithNormalIndent(infos, 4);
@@ -60,12 +60,10 @@ public class FormatterBasedLineInfoBuilderTest extends LightPlatformCodeInsightT
assertEquals(expected, linesWithNormalIndent);
}
- private List getLineInfos(String text) throws IOException, JDOMException {
- String file = getTestName(false) + ".xml";
- TestFormattingModel model = new TestFormattingModel(text);
- Document document = model.getDocument();
- TestBlock block = new FormattingModelXmlReader(model).readTestBlock(getTestDataPath(), file);
- FormatterBasedLineIndentInfoBuilder builder = new FormatterBasedLineIndentInfoBuilder(document, block, null);
+ private static List getLineInfos(String text) throws IOException, JDOMException {
+ TestData data = FormatterEngineTestsKt.extractFormattingTestData(text);
+ Document document = EditorFactory.getInstance().createDocument(data.getTextToFormat());
+ FormatterBasedLineIndentInfoBuilder builder = new FormatterBasedLineIndentInfoBuilder(document, data.getRootBlock(), null);
return builder.build();
}
}
\ No newline at end of file
diff --git a/java/java-tests/testSrc/com/intellij/psi/codeStyle/autodetect/NewLineBlocksIteratorTest.java b/java/java-tests/testSrc/com/intellij/psi/codeStyle/autodetect/NewLineBlocksIteratorTest.java
index 8f3edd58d57a..3e4056e9b596 100644
--- a/java/java-tests/testSrc/com/intellij/psi/codeStyle/autodetect/NewLineBlocksIteratorTest.java
+++ b/java/java-tests/testSrc/com/intellij/psi/codeStyle/autodetect/NewLineBlocksIteratorTest.java
@@ -17,10 +17,10 @@ package com.intellij.psi.codeStyle.autodetect;
import com.intellij.JavaTestUtil;
import com.intellij.formatting.Block;
-import com.intellij.formatting.FormattingModelXmlReader;
-import com.intellij.formatting.TestBlock;
-import com.intellij.formatting.TestFormattingModel;
+import com.intellij.formatting.engine.FormatterEngineTestsKt;
+import com.intellij.formatting.engine.TestData;
import com.intellij.openapi.editor.Document;
+import com.intellij.openapi.editor.EditorFactory;
import com.intellij.psi.formatter.common.NewLineBlocksIterator;
import org.jdom.JDOMException;
import org.jetbrains.annotations.NotNull;
@@ -58,11 +58,14 @@ public class NewLineBlocksIteratorTest extends AbstractNewLineBlocksIteratorTest
}
public void testFirstBlockOnNewLineNotStartsIt() throws IOException, JDOMException {
- String text = "var x = r'''\n" +
- "''';";
-
- Iterator it = newIteratorFromTestFormattingModel(text);
- checkStartOffsets(new int[] {0}, it);
+ String text = "[]varx []=r'''\n" +
+ "'''";
+
+ TestData data = FormatterEngineTestsKt.extractFormattingTestData(text);
+ Document document = EditorFactory.getInstance().createDocument(data.getTextToFormat());
+ NewLineBlocksIterator iterator = new NewLineBlocksIterator(data.getRootBlock(), document);
+
+ checkStartOffsets(new int[] {0}, iterator);
}
@@ -73,11 +76,5 @@ public class NewLineBlocksIteratorTest extends AbstractNewLineBlocksIteratorTest
iterator.next();
}
}
-
- protected Iterator newIteratorFromTestFormattingModel(String text) throws IOException, JDOMException {
- TestFormattingModel model = new TestFormattingModel(text);
- Document document = model.getDocument();
- TestBlock block = new FormattingModelXmlReader(model).readTestBlock(getTestDataPath(), getFileName() + ".xml");
- return new NewLineBlocksIterator(block, document);
- }
+
}
diff --git a/platform/platform-tests/testData/newGeneralFormatter/lineIndent.xml b/platform/platform-tests/testData/newGeneralFormatter/lineIndent.xml
deleted file mode 100644
index 83a57843bea6..000000000000
--- a/platform/platform-tests/testData/newGeneralFormatter/lineIndent.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/platform/platform-tests/testSrc/com/intellij/formatting/FormattingModelXmlReader.java b/platform/platform-tests/testSrc/com/intellij/formatting/FormattingModelXmlReader.java
deleted file mode 100644
index b32b4d5910d8..000000000000
--- a/platform/platform-tests/testSrc/com/intellij/formatting/FormattingModelXmlReader.java
+++ /dev/null
@@ -1,143 +0,0 @@
-package com.intellij.formatting;
-
-import com.intellij.openapi.util.JDOMUtil;
-import com.intellij.openapi.util.TextRange;
-import com.intellij.testFramework.PlatformTestUtil;
-import com.intellij.util.containers.HashMap;
-import org.jdom.Element;
-import org.jdom.JDOMException;
-import org.jetbrains.annotations.NonNls;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-
-@NonNls public class FormattingModelXmlReader {
-
- private final Map myIdToAlignemt = new HashMap<>();
- private final Map myIdToWrap = new HashMap<>();
- private final FormattingDocumentModel myModel;
-
- public FormattingModelXmlReader(final FormattingDocumentModel model) {
- myModel = model;
- }
-
- public TestBlock readTestBlock(String dataName) throws IOException, JDOMException {
- final File dataFile = new File( PlatformTestUtil.getCommunityPath().replace(File.separatorChar, '/') +
- "/platform/platform-tests/testData/newGeneralFormatter", dataName + ".xml");
- return readBlock(JDOMUtil.load(dataFile));
- }
-
- public TestBlock readTestBlock(String path, String file) throws IOException, JDOMException {
- final File dataFile = new File(path, file);
- return readBlock(JDOMUtil.load(dataFile));
- }
-
- private TestBlock readBlock(final Element rootElement) {
- final int startOffset = Integer.parseInt(rootElement.getAttributeValue("start"));
- final int endOffset = Integer.parseInt(rootElement.getAttributeValue("end"));
- final TextRange textRange = new TextRange(startOffset, endOffset);
- final TestBlock result = new TestBlock(textRange);
- result.setIsIncomplete(Boolean.valueOf(rootElement.getAttributeValue("incomplete")).booleanValue());
- final CharSequence text = myModel.getText(textRange);
- if (text != null) {
- result.setText(text.toString());
- }
- final Element indentElement = rootElement.getChild("Indent");
- if (indentElement != null) {
- result.setIndent(readIndent(indentElement));
- }
- final Element alignmentElement = rootElement.getChild("Alignment");
- if (alignmentElement != null) {
- result.setAlignment(readAlignment(alignmentElement));
- }
-
- final Element wrapElement = rootElement.getChild("Wrap");
- if (wrapElement != null) {
- result.setWrap(readWrap(wrapElement));
- }
- final List children = rootElement.getChildren();
- for (final Object aChildren : children) {
- Element element = (Element)aChildren;
- if (element.getName().equals("Space")) {
- result.addSpace(readSpace(element));
- }
- else if (element.getName().equals("Block")) {
- result.addBlock(readBlock(element));
- }
- }
- return result;
- }
-
- private Wrap readWrap(final Element wrapElement) {
- final String wrapId = wrapElement.getAttributeValue("id");
- if (myIdToWrap.containsKey(wrapId)) return myIdToWrap.get(wrapId);
-
- final String type = wrapElement.getAttributeValue("type");
- String parentId = wrapElement.getAttributeValue("parent");
- boolean wrapFirst = "true".equals(wrapElement.getAttributeValue("ignoreParents"));
-
- if (myIdToWrap.containsKey(parentId)) {
- final Wrap wrap = Wrap.createChildWrap(myIdToWrap.get(parentId),readWrapType(type), wrapFirst);
- if ("true".equals(wrapElement.getAttributeValue("ignoreParents"))) {
- wrap.ignoreParentWraps();
- }
- myIdToWrap.put(wrapId, wrap);
- return wrap;
- } else {
- final Wrap wrap = Wrap.createWrap(readWrapType(type), wrapFirst);
- if ("true".equals(wrapElement.getAttributeValue("ignoreParents"))) {
- wrap.ignoreParentWraps();
- }
- myIdToWrap.put(wrapId, wrap);
- return wrap;
- }
-
- }
-
- private WrapType readWrapType(final String type) {
- if ("ALWAYS".equals(type)) return WrapType.ALWAYS;
- if ("NORMAL".equals(type)) return WrapType.NORMAL;
- if ("CHOP".equals(type)) return WrapType.CHOP_DOWN_IF_LONG;
- return WrapType.NONE;
- }
-
- private Spacing readSpace(final Element element) {
- return Spacing.createSpacing(
- getInt(element.getAttributeValue("minspaces")),
- getInt(element.getAttributeValue("maxspaces")),
- getInt(element.getAttributeValue("minlinefeeds")),
- "true".equals(element.getAttributeValue("keepLineBreaks")), 0);
- }
-
- private Alignment readAlignment(final Element alignmentElement) {
- final String alignId = alignmentElement.getAttributeValue("id");
- if (myIdToAlignemt.containsKey(alignId)) return myIdToAlignemt.get(alignId);
-
- final Alignment alignment = Alignment.createAlignment();
- myIdToAlignemt.put(alignId, alignment);
- return alignment;
- }
-
- private Indent readIndent(final Element indentElement) {
- final String type = indentElement.getAttributeValue("type");
- if ("LABEL".equals(type)) return Indent.getLabelIndent();
- if ("NONE".equals(type)) return Indent.getNoneIndent();
- if ("CONTINUATION".equals(type)) return Indent.getContinuationIndent();
- if ("SPACE".equals(type)) {
- String spaces = indentElement.getAttributeValue("spaces");
- return Indent.getSpaceIndent(Integer.valueOf(spaces));
- }
- return Indent.getNormalIndent();
- }
-
- private int getInt(final String count) {
- try {
- return Integer.parseInt(count);
- }
- catch (Exception e) {
- return 0;
- }
- }
-}
diff --git a/platform/platform-tests/testSrc/com/intellij/formatting/TestBlock.java b/platform/platform-tests/testSrc/com/intellij/formatting/TestBlock.java
deleted file mode 100644
index d9fe410c3f2c..000000000000
--- a/platform/platform-tests/testSrc/com/intellij/formatting/TestBlock.java
+++ /dev/null
@@ -1,126 +0,0 @@
-package com.intellij.formatting;
-
-import com.intellij.openapi.util.TextRange;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-public class TestBlock implements Block{
- private TextRange myTextRange;
-
- private final List