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());
}
}
}
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);
}
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);
}
}
}
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));
}
}
}
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;
}
Aggregations