use of org.jetbrains.kotlin.resolve.lazy.data.KtClassOrObjectInfo in project kotlin by JetBrains.
the class ResolveSession method getTopLevelClassifierDescriptors.
@Override
@NotNull
@ReadOnly
public Collection<ClassifierDescriptor> getTopLevelClassifierDescriptors(@NotNull FqName fqName, @NotNull final LookupLocation location) {
if (fqName.isRoot())
return Collections.emptyList();
PackageMemberDeclarationProvider provider = declarationProviderFactory.getPackageMemberDeclarationProvider(fqName.parent());
if (provider == null)
return Collections.emptyList();
Collection<ClassifierDescriptor> result = new SmartList<ClassifierDescriptor>();
result.addAll(ContainerUtil.mapNotNull(provider.getClassOrObjectDeclarations(fqName.shortName()), new Function<KtClassLikeInfo, ClassifierDescriptor>() {
@Override
public ClassDescriptor fun(KtClassLikeInfo classLikeInfo) {
if (classLikeInfo instanceof KtClassOrObjectInfo) {
//noinspection RedundantCast
return getClassDescriptor(((KtClassOrObjectInfo) classLikeInfo).getCorrespondingClassOrObject(), location);
} else if (classLikeInfo instanceof KtScriptInfo) {
return getScriptDescriptor(((KtScriptInfo) classLikeInfo).getScript());
} else {
throw new IllegalStateException("Unexpected " + classLikeInfo + " of type " + classLikeInfo.getClass().getName());
}
}
}));
result.addAll(ContainerUtil.map(provider.getTypeAliasDeclarations(fqName.shortName()), new Function<KtTypeAlias, ClassifierDescriptor>() {
@Override
public ClassifierDescriptor fun(KtTypeAlias alias) {
return (ClassifierDescriptor) lazyDeclarationResolver.resolveToDescriptor(alias);
}
}));
return result;
}
use of org.jetbrains.kotlin.resolve.lazy.data.KtClassOrObjectInfo in project kotlin by JetBrains.
the class LazyClassDescriptor method computeCompanionObjectDescriptor.
@Nullable
private ClassDescriptorWithResolutionScopes computeCompanionObjectDescriptor(@Nullable KtObjectDeclaration companionObject) {
if (companionObject == null)
return createSyntheticCompanionObjectDescriptor();
KtClassLikeInfo companionObjectInfo = getCompanionObjectInfo(companionObject);
if (!(companionObjectInfo instanceof KtClassOrObjectInfo)) {
return null;
}
Name name = ((KtClassOrObjectInfo) companionObjectInfo).getName();
assert name != null;
getUnsubstitutedMemberScope().getContributedClassifier(name, NoLookupLocation.WHEN_GET_COMPANION_OBJECT);
ClassDescriptor companionObjectDescriptor = c.getTrace().get(BindingContext.CLASS, companionObject);
if (companionObjectDescriptor instanceof ClassDescriptorWithResolutionScopes) {
assert DescriptorUtils.isCompanionObject(companionObjectDescriptor) : "Not a companion object: " + companionObjectDescriptor;
return (ClassDescriptorWithResolutionScopes) companionObjectDescriptor;
} else {
return null;
}
}
Aggregations