Search in sources :

Example 6 with KtDeclaration

use of org.jetbrains.kotlin.psi.KtDeclaration 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)

Example 7 with KtDeclaration

use of org.jetbrains.kotlin.psi.KtDeclaration in project kotlin by JetBrains.

the class DuplicateJvmSignatureAnnotator method annotate.

@Override
public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
    if (!(element instanceof KtFile) && !(element instanceof KtDeclaration))
        return;
    if (!ProjectRootsUtil.isInProjectSource(element))
        return;
    PsiFile file = element.getContainingFile();
    if (!(file instanceof KtFile) || TargetPlatformDetector.getPlatform((KtFile) file) != JvmPlatform.INSTANCE)
        return;
    Diagnostics otherDiagnostics = ResolutionUtils.analyzeFully((KtElement) element).getDiagnostics();
    GlobalSearchScope moduleScope = GetModuleInfoKt.getModuleInfo(element).contentScope();
    Diagnostics diagnostics = DuplicateJvmSignatureUtilKt.getJvmSignatureDiagnostics(element, otherDiagnostics, moduleScope);
    if (diagnostics == null)
        return;
    new KotlinPsiChecker().annotateElement(element, holder, diagnostics);
}
Also used : KtDeclaration(org.jetbrains.kotlin.psi.KtDeclaration) KtElement(org.jetbrains.kotlin.psi.KtElement) Diagnostics(org.jetbrains.kotlin.resolve.diagnostics.Diagnostics) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) KtFile(org.jetbrains.kotlin.psi.KtFile) PsiFile(com.intellij.psi.PsiFile)

Aggregations

KtDeclaration (org.jetbrains.kotlin.psi.KtDeclaration)7 KtFile (org.jetbrains.kotlin.psi.KtFile)6 KtClass (org.jetbrains.kotlin.psi.KtClass)4 PsiFile (com.intellij.psi.PsiFile)3 ClassDescriptor (org.jetbrains.kotlin.descriptors.ClassDescriptor)2 KotlinClassStub (org.jetbrains.kotlin.psi.stubs.KotlinClassStub)2 AbstractTreeNode (com.intellij.ide.util.treeView.AbstractTreeNode)1 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)1 ArrayList (java.util.ArrayList)1 TestRunner (junit.textui.TestRunner)1 NotNull (org.jetbrains.annotations.NotNull)1 GenerationState (org.jetbrains.kotlin.codegen.state.GenerationState)1 DeclarationDescriptor (org.jetbrains.kotlin.descriptors.DeclarationDescriptor)1 FunctionDescriptor (org.jetbrains.kotlin.descriptors.FunctionDescriptor)1 KtClassOrObject (org.jetbrains.kotlin.psi.KtClassOrObject)1 KtElement (org.jetbrains.kotlin.psi.KtElement)1 KtTreeVisitorVoid (org.jetbrains.kotlin.psi.KtTreeVisitorVoid)1 Diagnostics (org.jetbrains.kotlin.resolve.diagnostics.Diagnostics)1 MemberScope (org.jetbrains.kotlin.resolve.scopes.MemberScope)1