use of org.jetbrains.kotlin.test.SettingsConfigurator in project kotlin by JetBrains.
the class AbstractKotlinFoldingTest method doTestWithSettings.
protected static void doTestWithSettings(@NotNull String fileText, @NotNull Function<String, Void> runnable) {
JavaCodeFoldingSettings settings = JavaCodeFoldingSettings.getInstance();
JavaCodeFoldingSettingsImpl restoreSettings = new JavaCodeFoldingSettingsImpl();
restoreSettings.loadState((JavaCodeFoldingSettingsImpl) settings);
try {
SettingsConfigurator configurator = new SettingsConfigurator(fileText, settings);
configurator.configureSettings();
runnable.apply(fileText);
} finally {
((JavaCodeFoldingSettingsImpl) JavaCodeFoldingSettings.getInstance()).loadState(restoreSettings);
}
}
use of org.jetbrains.kotlin.test.SettingsConfigurator in project kotlin by JetBrains.
the class AbstractTypingIndentationTestBase method doNewlineTest.
public void doNewlineTest(String afterFilePath, boolean inverted) throws Exception {
String testFileName = afterFilePath.substring(0, afterFilePath.indexOf("."));
String testFileExtension = afterFilePath.substring(afterFilePath.lastIndexOf("."));
String originFilePath = testFileName + testFileExtension;
String originalFileText = FileUtil.loadFile(new File(originFilePath), true);
try {
SettingsConfigurator configurator = FormatSettingsUtil.createConfigurator(originalFileText);
if (!inverted) {
configurator.configureSettings();
} else {
configurator.configureInvertedSettings();
}
doNewlineTest(originFilePath, afterFilePath);
} finally {
getSettings().clearCodeStyleSettings();
}
}
use of org.jetbrains.kotlin.test.SettingsConfigurator in project kotlin by JetBrains.
the class AbstractFormatterTest method doTest.
public void doTest(@NotNull String expectedFileNameWithExtension, boolean inverted) throws Exception {
String testFileName = expectedFileNameWithExtension.substring(0, expectedFileNameWithExtension.indexOf("."));
String testFileExtension = expectedFileNameWithExtension.substring(expectedFileNameWithExtension.lastIndexOf("."));
String originalFileText = FileUtil.loadFile(new File(testFileName + testFileExtension), true);
CodeStyleSettings codeStyleSettings = FormatSettingsUtil.getSettings();
Integer rightMargin = InTextDirectivesUtils.getPrefixedInt(originalFileText, "// RIGHT_MARGIN: ");
if (rightMargin != null) {
codeStyleSettings.setRightMargin(KotlinLanguage.INSTANCE, rightMargin);
}
SettingsConfigurator configurator = FormatSettingsUtil.createConfigurator(originalFileText, codeStyleSettings);
if (!inverted) {
configurator.configureSettings();
} else {
configurator.configureInvertedSettings();
}
doTextTest(originalFileText, new File(expectedFileNameWithExtension), testFileExtension);
codeStyleSettings.clearCodeStyleSettings();
}
Aggregations