Minor. Cleanup code

This commit is contained in:
Mikhael Bogdanov
2017-04-13 15:01:37 +02:00
parent 3df32ad425
commit a6c9cf7d3f
5 changed files with 27 additions and 39 deletions
@@ -86,7 +86,7 @@ public abstract class CodegenTestCase extends KtUsefulTestCase {
protected GeneratedClassLoader initializedClassLoader;
protected ConfigurationKind configurationKind = ConfigurationKind.JDK_ONLY;
public final String defaultJvmTarget = System.getProperty(DEFAULT_JVM_TARGET_FOR_TEST);
private final String defaultJvmTarget = System.getProperty(DEFAULT_JVM_TARGET_FOR_TEST);
protected final void createEnvironmentWithMockJdkAndIdeaAnnotations(
@NotNull ConfigurationKind configurationKind,
@@ -399,7 +399,8 @@ public abstract class CodegenTestCase extends KtUsefulTestCase {
protected ClassFileFactory generateClassesInFile() {
if (classFileFactory == null) {
try {
classFileFactory = generateFiles(myEnvironment, myFiles, getClassBuilderFactory());
classFileFactory =
GenerationUtils.compileFiles(myFiles.getPsiFiles(), myEnvironment, getClassBuilderFactory()).getFactory();
if (verifyWithDex() && DxChecker.RUN_DX_CHECKER) {
DxChecker.check(classFileFactory);
@@ -583,7 +584,7 @@ public abstract class CodegenTestCase extends KtUsefulTestCase {
}
@NotNull
protected List<String> extractJavacOptions(@NotNull List<TestFile> files) {
protected static List<String> extractJavacOptions(@NotNull List<TestFile> files) {
List<String> javacOptions = new ArrayList<>(0);
for (TestFile file : files) {
javacOptions.addAll(InTextDirectivesUtils.findListWithPrefixes(file.content, "// JAVAC_OPTIONS:"));
@@ -43,15 +43,6 @@ public class CodegenTestUtil {
return GenerationUtils.compileFiles(files.getPsiFiles(), environment).getFactory();
}
@NotNull
public static ClassFileFactory generateFiles(
@NotNull KotlinCoreEnvironment environment,
@NotNull CodegenTestFiles files,
@NotNull ClassBuilderFactory factory
) {
return GenerationUtils.compileFiles(files.getPsiFiles(), environment, factory).getFactory();
}
public static void assertThrows(@NotNull Method foo, @NotNull Class<? extends Throwable> exceptionClass,
@Nullable Object instance, @NotNull Object... args) throws IllegalAccessException {
boolean caught = false;
@@ -141,17 +141,16 @@ public abstract class AbstractWriteFlagsTest extends CodegenTestCase {
}
private static TestClassVisitor getClassVisitor(String visitorKind, String testedObjectName, boolean allowSynthetic) {
if (visitorKind.equals("class")) {
return new ClassFlagsVisitor();
}
else if (visitorKind.equals("function")) {
return new FunctionFlagsVisitor(testedObjectName, allowSynthetic);
}
else if (visitorKind.equals("property")) {
return new PropertyFlagsVisitor(testedObjectName);
}
else if (visitorKind.equals("innerClass")) {
return new InnerClassFlagsVisitor(testedObjectName);
switch (visitorKind) {
case "class":
return new ClassFlagsVisitor();
case "function":
return new FunctionFlagsVisitor(testedObjectName, allowSynthetic);
case "property":
return new PropertyFlagsVisitor(testedObjectName);
case "innerClass":
return new InnerClassFlagsVisitor(testedObjectName);
default:
}
throw new IllegalArgumentException("Value of TESTED_OBJECT_KIND is incorrect: " + visitorKind);
@@ -32,7 +32,7 @@ abstract class AbstractBlackBoxAgainstJavaCodegenTest : AbstractBlackBoxCodegenT
}
override fun updateConfiguration(configuration: CompilerConfiguration) {
configuration.addJvmClasspathRoots(listOf(javaOutputDir!!))
configuration.addJvmClasspathRoots(listOf(javaOutputDir))
}
override fun extractConfigurationKind(files: MutableList<TestFile>): ConfigurationKind {
@@ -134,10 +134,10 @@ public abstract class AbstractPositionManagerTest extends KotlinLightCodeInsight
private void performTest() {
Project project = getProject();
List<KtFile> files = new ArrayList<KtFile>(PluginJetFilesProvider.allFilesInProject(project));
List<KtFile> files = new ArrayList<>(PluginJetFilesProvider.allFilesInProject(project));
if (files.isEmpty()) return;
final List<Breakpoint> breakpoints = Lists.newArrayList();
List<Breakpoint> breakpoints = Lists.newArrayList();
for (KtFile file : files) {
breakpoints.addAll(extractBreakpointsInfo(file, file.getText()));
}
@@ -153,20 +153,17 @@ public abstract class AbstractPositionManagerTest extends KotlinLightCodeInsight
debugProcess = createDebugProcess(referencesByName);
final PositionManager positionManager = createPositionManager(debugProcess, files, state);
PositionManager positionManager = createPositionManager(debugProcess, files, state);
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
try {
for (Breakpoint breakpoint : breakpoints) {
assertBreakpointIsHandledCorrectly(breakpoint, positionManager);
}
}
catch (NoDataException e) {
throw ExceptionUtilsKt.rethrow(e);
ApplicationManager.getApplication().runReadAction(() -> {
try {
for (Breakpoint breakpoint : breakpoints) {
assertBreakpointIsHandledCorrectly(breakpoint, positionManager);
}
}
catch (NoDataException e) {
throw ExceptionUtilsKt.rethrow(e);
}
});
}
@@ -199,7 +196,7 @@ public abstract class AbstractPositionManagerTest extends KotlinLightCodeInsight
return new SmartMockReferenceTypeContext(outputFiles).getReferenceTypesByName();
}
private DebugProcessEvents createDebugProcess(final Map<String, ReferenceType> referencesByName) {
private DebugProcessEvents createDebugProcess(Map<String, ReferenceType> referencesByName) {
return new DebugProcessEvents(getProject()) {
private VirtualMachineProxyImpl virtualMachineProxy;
@@ -264,7 +261,7 @@ public abstract class AbstractPositionManagerTest extends KotlinLightCodeInsight
@Override
public List<ReferenceType> allClasses() {
return new ArrayList<ReferenceType>(referencesByName.values());
return new ArrayList<>(referencesByName.values());
}
@Override