Search in sources :

Example 1 with KotlinClassStub

use of org.jetbrains.kotlin.psi.stubs.KotlinClassStub in project kotlin by JetBrains.

the class KotlinStubsTest method testSuperclassNames.

public void testSuperclassNames() {
    PsiFile psiFile = myFixture.configureByText("foo.kt", "import java.util.ArrayList as alist\nclass C(): alist() { }");
    List<KtDeclaration> declarations = ((KtFile) psiFile).getDeclarations();
    KtClass ktClass = (KtClass) declarations.get(0);
    KotlinClassStub stub = KtStubElementTypes.CLASS.createStub(ktClass, null);
    List<String> names = stub.getSuperNames();
    assertSameElements(names, "ArrayList", "alist");
}
Also used : KtDeclaration(org.jetbrains.kotlin.psi.KtDeclaration) KtClass(org.jetbrains.kotlin.psi.KtClass) KotlinClassStub(org.jetbrains.kotlin.psi.stubs.KotlinClassStub) PsiFile(com.intellij.psi.PsiFile) KtFile(org.jetbrains.kotlin.psi.KtFile)

Example 2 with KotlinClassStub

use of org.jetbrains.kotlin.psi.stubs.KotlinClassStub in project kotlin by JetBrains.

the class KotlinStubsTest method testClassIsTrait.

public void testClassIsTrait() {
    PsiFile psiFile = myFixture.configureByText("foo.kt", "interface Test { }");
    List<KtDeclaration> declarations = ((KtFile) psiFile).getDeclarations();
    KtClass ktClass = (KtClass) declarations.get(0);
    KotlinClassStub stub = KtStubElementTypes.CLASS.createStub(ktClass, null);
    assertEquals(true, stub.isInterface());
}
Also used : KtDeclaration(org.jetbrains.kotlin.psi.KtDeclaration) KtClass(org.jetbrains.kotlin.psi.KtClass) KotlinClassStub(org.jetbrains.kotlin.psi.stubs.KotlinClassStub) PsiFile(com.intellij.psi.PsiFile) KtFile(org.jetbrains.kotlin.psi.KtFile)

Aggregations

PsiFile (com.intellij.psi.PsiFile)2 KtClass (org.jetbrains.kotlin.psi.KtClass)2 KtDeclaration (org.jetbrains.kotlin.psi.KtDeclaration)2 KtFile (org.jetbrains.kotlin.psi.KtFile)2 KotlinClassStub (org.jetbrains.kotlin.psi.stubs.KotlinClassStub)2