Remove "javax.annotation.Nullable" usage and clean up file

This commit is contained in:
Nikolay Krasko
2017-09-25 20:37:45 +03:00
parent 412fb62bbb
commit 31f5c105f3
@@ -16,7 +16,6 @@
package org.jetbrains.kotlin.idea.folding; package org.jetbrains.kotlin.idea.folding;
import com.google.common.base.Function;
import com.intellij.codeInsight.folding.JavaCodeFoldingSettings; import com.intellij.codeInsight.folding.JavaCodeFoldingSettings;
import com.intellij.codeInsight.folding.impl.JavaCodeFoldingSettingsImpl; import com.intellij.codeInsight.folding.impl.JavaCodeFoldingSettingsImpl;
import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.io.FileUtil;
@@ -31,10 +30,10 @@ import org.jetbrains.kotlin.idea.test.KotlinLightProjectDescriptor;
import org.jetbrains.kotlin.test.SettingsConfigurator; import org.jetbrains.kotlin.test.SettingsConfigurator;
import org.junit.Assert; import org.junit.Assert;
import javax.annotation.Nullable;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.util.function.Consumer;
public abstract class AbstractKotlinFoldingTest extends KotlinLightCodeInsightFixtureTestCaseBase { public abstract class AbstractKotlinFoldingTest extends KotlinLightCodeInsightFixtureTestCaseBase {
protected void doTest(@NotNull String path) { protected void doTest(@NotNull String path) {
@@ -47,14 +46,7 @@ public abstract class AbstractKotlinFoldingTest extends KotlinLightCodeInsightFi
String directText = fileText.replaceAll("~true~", "true").replaceAll("~false~", "false"); String directText = fileText.replaceAll("~true~", "true").replaceAll("~false~", "false");
directText += "\n\n// Generated from: " + path; directText += "\n\n// Generated from: " + path;
Function<String, Void> doExpandSettingsTestFunction = new Function<String, Void>() { Consumer<String> doExpandSettingsTestFunction = this::doExpandSettingsTest;
@Nullable
@Override
public Void apply(@Nullable String fileText) {
doExpandSettingsTest(fileText);
return null;
}
};
doTestWithSettings(directText, doExpandSettingsTestFunction); doTestWithSettings(directText, doExpandSettingsTestFunction);
@@ -68,7 +60,7 @@ public abstract class AbstractKotlinFoldingTest extends KotlinLightCodeInsightFi
doTestWithSettings(invertedText, doExpandSettingsTestFunction); doTestWithSettings(invertedText, doExpandSettingsTestFunction);
} }
protected static void doTestWithSettings(@NotNull String fileText, @NotNull Function<String, Void> runnable) { protected static void doTestWithSettings(@NotNull String fileText, @NotNull Consumer<String> runnable) {
JavaCodeFoldingSettings settings = JavaCodeFoldingSettings.getInstance(); JavaCodeFoldingSettings settings = JavaCodeFoldingSettings.getInstance();
JavaCodeFoldingSettingsImpl restoreSettings = new JavaCodeFoldingSettingsImpl(); JavaCodeFoldingSettingsImpl restoreSettings = new JavaCodeFoldingSettingsImpl();
restoreSettings.loadState((JavaCodeFoldingSettingsImpl) settings); restoreSettings.loadState((JavaCodeFoldingSettingsImpl) settings);
@@ -77,7 +69,7 @@ public abstract class AbstractKotlinFoldingTest extends KotlinLightCodeInsightFi
SettingsConfigurator configurator = new SettingsConfigurator(fileText, settings); SettingsConfigurator configurator = new SettingsConfigurator(fileText, settings);
configurator.configureSettings(); configurator.configureSettings();
runnable.apply(fileText); runnable.accept(fileText);
} }
finally { finally {
((JavaCodeFoldingSettingsImpl) JavaCodeFoldingSettings.getInstance()).loadState(restoreSettings); ((JavaCodeFoldingSettingsImpl) JavaCodeFoldingSettings.getInstance()).loadState(restoreSettings);
@@ -87,7 +79,7 @@ public abstract class AbstractKotlinFoldingTest extends KotlinLightCodeInsightFi
private void doExpandSettingsTest(String fileText) { private void doExpandSettingsTest(String fileText) {
try { try {
VirtualFile tempFile = PlatformTestCase.createTempFile("kt", null, fileText, Charset.defaultCharset()); VirtualFile tempFile = PlatformTestCase.createTempFile("kt", null, fileText, Charset.defaultCharset());
assertFoldingRegionsForFile(tempFile.getPath(), true); assertFoldingRegionsForFile(tempFile.getPath());
} }
catch (IOException e) { catch (IOException e) {
throw new IllegalStateException(e); throw new IllegalStateException(e);
@@ -96,7 +88,7 @@ public abstract class AbstractKotlinFoldingTest extends KotlinLightCodeInsightFi
// Rewritten version of CodeInsightTestFixtureImpl.testFoldingRegions(verificationFileName, true). // Rewritten version of CodeInsightTestFixtureImpl.testFoldingRegions(verificationFileName, true).
// Configure test with custom file name to force creating different editors for normal and inverted tests. // Configure test with custom file name to force creating different editors for normal and inverted tests.
private void assertFoldingRegionsForFile(String verificationFileName, boolean doCheckCollapseStatus) { private void assertFoldingRegionsForFile(String verificationFileName) {
String START_FOLD = "<fold\\stext=\'[^\']*\'(\\sexpand=\'[^\']*\')*>"; String START_FOLD = "<fold\\stext=\'[^\']*\'(\\sexpand=\'[^\']*\')*>";
String END_FOLD = "</fold>"; String END_FOLD = "</fold>";
@@ -115,7 +107,7 @@ public abstract class AbstractKotlinFoldingTest extends KotlinLightCodeInsightFi
String cleanContent = expectedContent.replaceAll(START_FOLD, "").replaceAll(END_FOLD, ""); String cleanContent = expectedContent.replaceAll(START_FOLD, "").replaceAll(END_FOLD, "");
myFixture.configureByText(file.getName(), cleanContent); myFixture.configureByText(file.getName(), cleanContent);
String actual = ((CodeInsightTestFixtureImpl)myFixture).getFoldingDescription(doCheckCollapseStatus); String actual = ((CodeInsightTestFixtureImpl)myFixture).getFoldingDescription(true);
Assert.assertEquals(expectedContent, actual); Assert.assertEquals(expectedContent, actual);
} }