Search in sources :

Example 41 with FqName

use of org.jetbrains.kotlin.name.FqName in project kotlin by JetBrains.

the class IdeStubIndexService method indexFile.

@Override
public void indexFile(KotlinFileStub stub, IndexSink sink) {
    FqName packageFqName = stub.getPackageFqName();
    sink.occurrence(KotlinExactPackagesIndex.getInstance().getKey(), packageFqName.asString());
    if (stub.isScript())
        return;
    FqName facadeFqName = ((KotlinFileStubForIde) stub).getFacadeFqName();
    if (facadeFqName != null) {
        sink.occurrence(KotlinFileFacadeFqNameIndex.INSTANCE.getKey(), facadeFqName.asString());
        sink.occurrence(KotlinFileFacadeShortNameIndex.INSTANCE.getKey(), facadeFqName.shortName().asString());
        sink.occurrence(KotlinFileFacadeClassByPackageIndex.INSTANCE.getKey(), packageFqName.asString());
    }
    FqName partFqName = ((KotlinFileStubForIde) stub).getPartFqName();
    if (partFqName != null) {
        sink.occurrence(KotlinFilePartClassIndex.INSTANCE.getKey(), partFqName.asString());
    }
    List<StringRef> partNames = ((KotlinFileStubForIde) stub).getFacadePartSimpleNames();
    if (partNames != null) {
        for (StringRef partName : partNames) {
            String partSimpleName = StringRef.toString(partName);
            if (partSimpleName == null) {
                continue;
            }
            FqName multifileClassPartFqName = packageFqName.child(Name.identifier(partSimpleName));
            sink.occurrence(KotlinMultifileClassPartIndex.INSTANCE.getKey(), multifileClassPartFqName.asString());
        }
    }
}
Also used : FqName(org.jetbrains.kotlin.name.FqName) StringRef(com.intellij.util.io.StringRef)

Example 42 with FqName

use of org.jetbrains.kotlin.name.FqName in project kotlin by JetBrains.

the class IdeStubIndexService method indexClass.

@Override
public void indexClass(KotlinClassStub stub, IndexSink sink) {
    String name = stub.getName();
    if (name != null) {
        sink.occurrence(KotlinClassShortNameIndex.getInstance().getKey(), name);
    }
    FqName fqName = stub.getFqName();
    if (fqName != null) {
        sink.occurrence(KotlinFullClassNameIndex.getInstance().getKey(), fqName.asString());
        if (stub.isTopLevel()) {
            sink.occurrence(KotlinTopLevelClassByPackageIndex.getInstance().getKey(), fqName.parent().asString());
        }
    }
    if (stub.isInterface()) {
        sink.occurrence(KotlinClassShortNameIndex.getInstance().getKey(), JvmAbi.DEFAULT_IMPLS_CLASS_NAME);
    }
    indexSuperNames(stub, sink);
}
Also used : FqName(org.jetbrains.kotlin.name.FqName)

Example 43 with FqName

use of org.jetbrains.kotlin.name.FqName in project kotlin by JetBrains.

the class IdeStubIndexService method indexFunction.

@Override
public void indexFunction(KotlinFunctionStub stub, IndexSink sink) {
    String name = stub.getName();
    if (name != null) {
        sink.occurrence(KotlinFunctionShortNameIndex.getInstance().getKey(), name);
        if (TypeIndexUtilKt.isProbablyNothing(stub.getPsi().getTypeReference())) {
            sink.occurrence(KotlinProbablyNothingFunctionShortNameIndex.getInstance().getKey(), name);
        }
    }
    if (stub.isTopLevel()) {
        // can have special fq name in case of syntactically incorrect function with no name
        FqName fqName = stub.getFqName();
        if (fqName != null) {
            sink.occurrence(KotlinTopLevelFunctionFqnNameIndex.getInstance().getKey(), fqName.asString());
            sink.occurrence(KotlinTopLevelFunctionByPackageIndex.getInstance().getKey(), fqName.parent().asString());
            IndexUtilsKt.indexTopLevelExtension(stub, sink);
        }
    }
}
Also used : FqName(org.jetbrains.kotlin.name.FqName)

Example 44 with FqName

use of org.jetbrains.kotlin.name.FqName in project kotlin by JetBrains.

the class LazyDeclarationResolver method getMemberScopeDeclaredIn.

@NotNull
/*package*/
MemberScope getMemberScopeDeclaredIn(@NotNull KtDeclaration declaration, @NotNull LookupLocation location) {
    KtDeclaration parentDeclaration = KtStubbedPsiUtil.getContainingDeclaration(declaration);
    boolean isTopLevel = parentDeclaration == null;
    if (isTopLevel) {
        // for top level declarations we search directly in package because of possible conflicts with imports
        KtFile ktFile = (KtFile) declaration.getContainingFile();
        FqName fqName = ktFile.getPackageFqName();
        LazyPackageDescriptor packageDescriptor = topLevelDescriptorProvider.getPackageFragment(fqName);
        if (packageDescriptor == null) {
            if (topLevelDescriptorProvider instanceof LazyClassContext) {
                ((LazyClassContext) topLevelDescriptorProvider).getDeclarationProviderFactory().diagnoseMissingPackageFragment(ktFile);
            } else {
                throw new IllegalStateException("Cannot find package fragment for file " + ktFile.getName() + " with package " + fqName);
            }
        }
        return packageDescriptor.getMemberScope();
    } else {
        if (parentDeclaration instanceof KtClassOrObject) {
            return getClassDescriptor((KtClassOrObject) parentDeclaration, location).getUnsubstitutedMemberScope();
        } else if (parentDeclaration instanceof KtScript) {
            return getScriptDescriptor((KtScript) parentDeclaration, location).getUnsubstitutedMemberScope();
        } else {
            throw new IllegalStateException("Don't call this method for local declarations: " + declaration + "\n" + PsiUtilsKt.getElementTextWithContext(declaration));
        }
    }
}
Also used : FqName(org.jetbrains.kotlin.name.FqName) LazyPackageDescriptor(org.jetbrains.kotlin.resolve.lazy.descriptors.LazyPackageDescriptor) NotNull(org.jetbrains.annotations.NotNull)

Example 45 with FqName

use of org.jetbrains.kotlin.name.FqName in project kotlin by JetBrains.

the class FileBasedDeclarationProviderFactory method computeFilesByPackage.

@NotNull
private static Index computeFilesByPackage(@NotNull Collection<KtFile> files) {
    Index index = new Index();
    for (KtFile file : files) {
        FqName packageFqName = file.getPackageFqName();
        addMeAndParentPackages(index, packageFqName);
        index.filesByPackage.put(packageFqName, file);
    }
    return index;
}
Also used : FqName(org.jetbrains.kotlin.name.FqName) KtFile(org.jetbrains.kotlin.psi.KtFile) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

FqName (org.jetbrains.kotlin.name.FqName)74 NotNull (org.jetbrains.annotations.NotNull)25 Nullable (org.jetbrains.annotations.Nullable)15 KtFile (org.jetbrains.kotlin.psi.KtFile)10 StringRef (com.intellij.util.io.StringRef)6 File (java.io.File)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)4 ModuleDescriptor (org.jetbrains.kotlin.descriptors.ModuleDescriptor)4 Name (org.jetbrains.kotlin.name.Name)4 PsiClass (com.intellij.psi.PsiClass)3 ClassId (org.jetbrains.kotlin.name.ClassId)3 Disposable (com.intellij.openapi.Disposable)2 ConfigurationException (com.intellij.openapi.options.ConfigurationException)2 SmartList (com.intellij.util.SmartList)2 Function1 (kotlin.jvm.functions.Function1)2 KotlinCoreEnvironment (org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment)2 CompilerConfiguration (org.jetbrains.kotlin.config.CompilerConfiguration)2 JavaClassDescriptor (org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor)2 KtClassOrObject (org.jetbrains.kotlin.psi.KtClassOrObject)2