use of org.jetbrains.kotlin.asJava.classes.KtLightClass in project kotlin by JetBrains.
the class KotlinLightClassCoherenceTest method doTest.
@NotNull
protected PsiClass doTest(String qualifiedName) {
KtLightClass psiClass = (KtLightClass) finder.findClass(qualifiedName, GlobalSearchScope.allScope(getProject()));
assertNotNull("Class not found: " + qualifiedName, psiClass);
Asserter asserter = new Asserter();
asserter.assertModifiersCoherent(psiClass);
asserter.assertPropertyCoherent(psiClass, "isInterface");
asserter.assertPropertyCoherent(psiClass, "isAnnotationType");
asserter.assertPropertyCoherent(psiClass, "isEnum");
asserter.assertPropertyCoherent(psiClass, "hasTypeParameters");
asserter.assertPropertyCoherent(psiClass, "isDeprecated");
asserter.reportFailures();
return psiClass;
}
use of org.jetbrains.kotlin.asJava.classes.KtLightClass in project kotlin by JetBrains.
the class LightClassAnnotationsTest method doTest.
private void doTest(@NotNull String fqName) {
PsiClass psiClass = finder.findClass(fqName, GlobalSearchScope.allScope(getProject()));
if (!(psiClass instanceof KtLightClass)) {
throw new IllegalStateException("Not a light class: " + psiClass + " (" + fqName + ")");
}
PsiModifierList modifierList = psiClass.getModifierList();
assert modifierList != null : "No modifier list for " + psiClass.getText();
StringBuilder sb = new StringBuilder();
for (PsiAnnotation annotation : modifierList.getAnnotations()) {
sb.append(annotation.getText()).append("\n");
}
KotlinTestUtils.assertEqualsToFile(new File(testDir, getTestName(false) + ".annotations.txt"), sb.toString());
}
use of org.jetbrains.kotlin.asJava.classes.KtLightClass in project kotlin by JetBrains.
the class KotlinJavaFacadeTest method doTestWrapClass.
private void doTestWrapClass() {
myFixture.configureByFile(fileName());
int offset = myFixture.getEditor().getCaretModel().getOffset();
PsiElement elementAt = myFixture.getFile().findElementAt(offset);
assertNotNull("Caret should be set for tested file", elementAt);
KtClass ktClass = PsiTreeUtil.getParentOfType(elementAt, KtClass.class);
assertNotNull("Caret should be placed to class definition", ktClass);
// Should not fail!
KtLightClass lightClass = toLightClass(ktClass);
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();
}
Aggregations