Move refactorings, fix annotations and fix cls-delegate tests

This commit is contained in:
Igor Yakovlev
2019-04-24 18:05:37 +03:00
parent 8e103b6559
commit b485819a30
14 changed files with 449 additions and 388 deletions
@@ -34,7 +34,6 @@ import org.jetbrains.kotlin.asJava.classes.*
import org.jetbrains.kotlin.asJava.finder.JavaElementFinder
import org.jetbrains.kotlin.codegen.ClassBuilderMode
import org.jetbrains.kotlin.codegen.JvmCodegenUtil
import org.jetbrains.kotlin.codegen.state.IncompatibleClassTracker
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper
import org.jetbrains.kotlin.config.JvmTarget
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
@@ -72,7 +71,7 @@ class IDELightClassGenerationSupport(private val project: Project) : LightClassG
}
val module = ModuleUtilCore.findModuleForPsiElement(element) ?: return null
return KtUltraLightClass(element, object : UltraLightSupport {
return KtUltraLightClass(element, object : KtUltraLightSupport {
override fun isTooComplexForUltraLightGeneration(element: KtClassOrObject): Boolean {
val facet = KotlinFacet.get(module)
val pluginClasspath = facet?.configuration?.settings?.compilerArguments?.pluginClasspaths
@@ -12,6 +12,7 @@ import com.intellij.testFramework.LightProjectDescriptor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.asJava.LightClassUtil;
import org.jetbrains.kotlin.asJava.classes.KtLightClass;
import org.jetbrains.kotlin.asJava.classes.KtUltraLightClass;
import org.jetbrains.kotlin.asJava.elements.KtLightMethod;
import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase;
import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor;
@@ -294,9 +295,11 @@ public class KotlinJavaFacadeTest extends KotlinLightCodeInsightFixtureTestCase
assertNotNull(String.format("Failed to wrap jetClass '%s' to class", ktClass.getText()), lightClass);
// This invokes codegen with ClassBuilderMode = LIGHT_CLASSES
// No exception/error should happen here
lightClass.getClsDelegate();
if (!(lightClass instanceof KtUltraLightClass)){
// This invokes codegen with ClassBuilderMode = LIGHT_CLASSES
// No exception/error should happen here
lightClass.getClsDelegate();
}
}
@NotNull
@@ -283,8 +283,8 @@ class CommonIntentionActionsTest : LightPlatformCodeInsightFixtureTestCase() {
)
TestCase.assertEquals(
"KtLightMethodImpl -> org.jetbrains.annotations.NotNull," +
" KtLightFieldForDeclaration -> pkg.myannotation.JavaAnnotation, org.jetbrains.annotations.NotNull",
"KtUltraLightMethodForSourceDeclaration -> org.jetbrains.annotations.NotNull," +
" KtUltraLightField -> pkg.myannotation.JavaAnnotation, org.jetbrains.annotations.NotNull",
annotationsString(myFixture.findElementByText("bar", KtModifierListOwner::class.java))
)
}
@@ -335,14 +335,14 @@ class CommonIntentionActionsTest : LightPlatformCodeInsightFixtureTestCase() {
)
TestCase.assertEquals(
"KtLightMethodImpl -> org.jetbrains.annotations.NotNull," +
" KtLightFieldForDeclaration -> pkg.myannotation.JavaAnnotation, org.jetbrains.annotations.NotNull",
"KtUltraLightMethodForSourceDeclaration -> org.jetbrains.annotations.NotNull," +
" KtUltraLightField -> pkg.myannotation.JavaAnnotation, org.jetbrains.annotations.NotNull",
annotationsString(myFixture.findElementByText("bar", KtModifierListOwner::class.java))
)
}
private fun annotationsString(findElementByText: KtModifierListOwner) = findElementByText.toLightElements()
.joinToString { elem -> "${elem.javaClass.simpleName} -> ${(elem as PsiModifierListOwner).annotations.joinToString { it.qualifiedName!! }}" }
.joinToString { elem -> "${elem.javaClass.simpleName} -> ${(elem as PsiModifierListOwner).annotations.mapNotNull { it.qualifiedName }.joinToString()}" }
fun testDontMakePublicPublic() {
myFixture.configureByText(