use of org.jetbrains.kotlin.name.Name in project kotlin by JetBrains.
the class KtNamedDeclarationUtil method getFQName.
@Nullable
static /*package private*/
FqName getFQName(@NotNull KtNamedDeclaration namedDeclaration) {
Name name = namedDeclaration.getNameAsName();
if (name == null) {
return null;
}
FqName parentFqName = getParentFqName(namedDeclaration);
if (parentFqName == null) {
return null;
}
return parentFqName.child(name);
}
use of org.jetbrains.kotlin.name.Name in project kotlin by JetBrains.
the class AbstractAnnotationDescriptorResolveTest method getFunctionDescriptor.
@NotNull
private static FunctionDescriptor getFunctionDescriptor(@NotNull ClassDescriptor classDescriptor, @NotNull String name) {
Name functionName = Name.identifier(name);
MemberScope memberScope = classDescriptor.getMemberScope(Collections.<TypeProjection>emptyList());
Collection<SimpleFunctionDescriptor> functions = memberScope.getContributedFunctions(functionName, NoLookupLocation.FROM_TEST);
assert functions.size() == 1 : "Failed to find function " + functionName + " in class" + "." + classDescriptor.getName();
return functions.iterator().next();
}
use of org.jetbrains.kotlin.name.Name in project kotlin by JetBrains.
the class AbstractAnnotationDescriptorResolveTest method getInnerClassDescriptor.
@NotNull
private static ClassDescriptor getInnerClassDescriptor(@NotNull ClassDescriptor classDescriptor, @NotNull String name) {
Name propertyName = Name.identifier(name);
MemberScope memberScope = classDescriptor.getMemberScope(Collections.<TypeProjection>emptyList());
ClassifierDescriptor innerClass = memberScope.getContributedClassifier(propertyName, NoLookupLocation.FROM_TEST);
assert innerClass instanceof ClassDescriptor : "Failed to find inner class " + propertyName + " in class " + classDescriptor.getName();
return (ClassDescriptor) innerClass;
}
use of org.jetbrains.kotlin.name.Name in project kotlin by JetBrains.
the class AbstractAnnotationDescriptorResolveTest method getFunctionDescriptor.
@NotNull
protected static FunctionDescriptor getFunctionDescriptor(@NotNull PackageFragmentDescriptor packageView, @NotNull String name) {
Name functionName = Name.identifier(name);
MemberScope memberScope = packageView.getMemberScope();
Collection<SimpleFunctionDescriptor> functions = memberScope.getContributedFunctions(functionName, NoLookupLocation.FROM_TEST);
assert functions.size() == 1 : "Failed to find function " + functionName + " in class" + "." + packageView.getName();
return functions.iterator().next();
}
use of org.jetbrains.kotlin.name.Name in project kotlin by JetBrains.
the class AbstractAnnotationDescriptorResolveTest method getPropertyDescriptor.
@Nullable
protected static PropertyDescriptor getPropertyDescriptor(@NotNull PackageFragmentDescriptor packageView, @NotNull String name, boolean failOnMissing) {
Name propertyName = Name.identifier(name);
MemberScope memberScope = packageView.getMemberScope();
Collection<PropertyDescriptor> properties = memberScope.getContributedVariables(propertyName, NoLookupLocation.FROM_TEST);
if (properties.isEmpty()) {
for (DeclarationDescriptor descriptor : DescriptorUtils.getAllDescriptors(memberScope)) {
if (descriptor instanceof ClassDescriptor) {
Collection<PropertyDescriptor> classProperties = ((ClassDescriptor) descriptor).getMemberScope(Collections.<TypeProjection>emptyList()).getContributedVariables(propertyName, NoLookupLocation.FROM_TEST);
if (!classProperties.isEmpty()) {
properties = classProperties;
break;
}
}
}
}
if (failOnMissing) {
assert properties.size() == 1 : "Failed to find property " + propertyName + " in class " + packageView.getName();
} else if (properties.size() != 1) {
return null;
}
return properties.iterator().next();
}
Aggregations