org.jetbrains.kotlin.resolve
Class DescriptorUtils
java.lang.Object
org.jetbrains.kotlin.resolve.DescriptorUtils
public class DescriptorUtils
- extends java.lang.Object
Method Summary |
static boolean |
areInSameModule(DeclarationDescriptor first,
DeclarationDescriptor second)
|
static boolean |
canHaveDeclaredConstructors(ClassDescriptor classDescriptor)
|
static boolean |
classCanHaveAbstractMembers(ClassDescriptor classDescriptor)
|
static boolean |
classCanHaveOpenMembers(ClassDescriptor classDescriptor)
|
static boolean |
containsReifiedTypeParameters(CallableDescriptor descriptor)
|
static boolean |
containsReifiedTypeParameterWithName(CallableDescriptor descriptor,
java.lang.String name)
|
static
|
getAllOverriddenDeclarations(D memberDescriptor)
|
static
|
getAllOverriddenDescriptors(D f)
|
static ClassDescriptor |
getClassDescriptorForType(KotlinType type)
|
static ClassDescriptor |
getClassDescriptorForTypeConstructor(TypeConstructor typeConstructor)
|
static ClassDescriptor |
getContainingClass(DeclarationDescriptor descriptor)
|
static ModuleDescriptor |
getContainingModule(DeclarationDescriptor descriptor)
|
static ModuleDescriptor |
getContainingModuleOrNull(DeclarationDescriptor descriptor)
|
static SourceFile |
getContainingSourceFile(DeclarationDescriptor descriptor)
|
static Visibility |
getDefaultConstructorVisibility(ClassDescriptor classDescriptor)
|
static ReceiverParameterDescriptor |
getDispatchReceiverParameterIfNeeded(DeclarationDescriptor containingDeclaration)
|
static FqNameUnsafe |
getFqName(DeclarationDescriptor descriptor)
|
static FqName |
getFqNameFromTopLevelClass(DeclarationDescriptor descriptor)
|
static FqName |
getFqNameSafe(DeclarationDescriptor descriptor)
|
static ClassDescriptor |
getInnerClassByName(ClassDescriptor classDescriptor,
java.lang.String innerClassName,
LookupLocation location)
|
static java.lang.String |
getJvmName(Annotated annotated)
|
static AnnotationDescriptor |
getJvmNameAnnotation(Annotations annotations)
|
static java.util.Set<FqName> |
getPackagesFqNames(ModuleDescriptor module)
|
static
|
getParentOfType(DeclarationDescriptor descriptor,
java.lang.Class<D> aClass)
|
static
|
getParentOfType(DeclarationDescriptor descriptor,
java.lang.Class<D> aClass,
boolean strict)
|
static KotlinType |
getReceiverParameterType(ReceiverParameterDescriptor receiverParameterDescriptor)
|
static KtScope |
getStaticNestedClassesScope(ClassDescriptor descriptor)
|
static java.util.Set<FqName> |
getSubPackagesFqNames(PackageViewDescriptor packageView)
|
static ClassDescriptor |
getSuperClassDescriptor(ClassDescriptor classDescriptor)
|
static java.util.List<ClassDescriptor> |
getSuperclassDescriptors(ClassDescriptor classDescriptor)
|
static KotlinType |
getSuperClassType(ClassDescriptor classDescriptor)
|
static AnnotationDescriptor |
getSynchronizedAnnotation(Annotated annotated)
|
static AnnotationDescriptor |
getVolatileAnnotation(Annotated annotated)
|
static boolean |
hasDefaultConstructor(ClassDescriptor classDescriptor)
|
static boolean |
isAncestor(DeclarationDescriptor ancestor,
DeclarationDescriptor declarationDescriptor,
boolean strict)
|
static boolean |
isAnnotationClass(DeclarationDescriptor descriptor)
|
static boolean |
isAnonymousObject(DeclarationDescriptor descriptor)
|
static boolean |
isClass(DeclarationDescriptor descriptor)
|
static boolean |
isCompanionObject(DeclarationDescriptor descriptor)
|
static boolean |
isDirectSubclass(ClassDescriptor subClass,
ClassDescriptor superClass)
|
static boolean |
isEnumClass(DeclarationDescriptor descriptor)
|
static boolean |
isEnumEntry(DeclarationDescriptor descriptor)
|
static boolean |
isExtension(CallableDescriptor descriptor)
|
static boolean |
isFunctionExpression(DeclarationDescriptor descriptor)
|
static boolean |
isFunctionLiteral(DeclarationDescriptor descriptor)
|
static boolean |
isInterface(DeclarationDescriptor descriptor)
|
static boolean |
isInterfaceCompanionObject(DeclarationDescriptor descriptor)
|
static boolean |
isLocal(DeclarationDescriptor descriptor)
Descriptor may be local itself or have a local ancestor |
static boolean |
isLocalFunction(DeclarationDescriptor descriptor)
|
static boolean |
isNonCompanionObject(DeclarationDescriptor descriptor)
|
static boolean |
isObject(DeclarationDescriptor descriptor)
|
static boolean |
isOverride(CallableMemberDescriptor descriptor)
|
static boolean |
isSingleton(DeclarationDescriptor classifier)
|
static boolean |
isSingletonOrAnonymousObject(ClassDescriptor classDescriptor)
|
static boolean |
isStaticDeclaration(CallableDescriptor descriptor)
|
static boolean |
isStaticNestedClass(DeclarationDescriptor descriptor)
|
static boolean |
isSubclass(ClassDescriptor subClass,
ClassDescriptor superClass)
|
static boolean |
isTopLevelDeclaration(DeclarationDescriptor descriptor)
|
static boolean |
isTopLevelOrInnerClass(ClassDescriptor descriptor)
|
static boolean |
shouldRecordInitializerForProperty(VariableDescriptor variable,
KotlinType type)
|
static
|
unwrapFakeOverride(D descriptor)
Given a fake override, finds any declaration of it in the overridden descriptors. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ENUM_VALUES
public static final Name ENUM_VALUES
ENUM_VALUE_OF
public static final Name ENUM_VALUE_OF
JVM_NAME
public static final FqName JVM_NAME
PLATFORM_NAME
public static final FqName PLATFORM_NAME
VOLATILE
public static final FqName VOLATILE
SYNCHRONIZED
public static final FqName SYNCHRONIZED
getDispatchReceiverParameterIfNeeded
@Nullable
public static ReceiverParameterDescriptor getDispatchReceiverParameterIfNeeded(@NotNull
DeclarationDescriptor containingDeclaration)
isLocal
public static boolean isLocal(@NotNull
DeclarationDescriptor descriptor)
- Descriptor may be local itself or have a local ancestor
getFqName
@NotNull
public static FqNameUnsafe getFqName(@NotNull
DeclarationDescriptor descriptor)
getFqNameSafe
@NotNull
public static FqName getFqNameSafe(@NotNull
DeclarationDescriptor descriptor)
getFqNameFromTopLevelClass
@NotNull
public static FqName getFqNameFromTopLevelClass(@NotNull
DeclarationDescriptor descriptor)
isTopLevelDeclaration
public static boolean isTopLevelDeclaration(@NotNull
DeclarationDescriptor descriptor)
isExtension
public static boolean isExtension(@NotNull
CallableDescriptor descriptor)
isOverride
public static boolean isOverride(@NotNull
CallableMemberDescriptor descriptor)
isStaticDeclaration
public static boolean isStaticDeclaration(@NotNull
CallableDescriptor descriptor)
- Returns:
- true iff this is a top-level declaration or a class member with no expected "this" object (e.g. static members in Java,
values() and valueOf() methods of enum classes, etc.)
areInSameModule
public static boolean areInSameModule(@NotNull
DeclarationDescriptor first,
@NotNull
DeclarationDescriptor second)
getParentOfType
@Nullable
public static <D extends DeclarationDescriptor> D getParentOfType(@Nullable
DeclarationDescriptor descriptor,
@NotNull
java.lang.Class<D> aClass)
getParentOfType
@Nullable
public static <D extends DeclarationDescriptor> D getParentOfType(@Nullable
DeclarationDescriptor descriptor,
@NotNull
java.lang.Class<D> aClass,
boolean strict)
getContainingModule
@NotNull
public static ModuleDescriptor getContainingModule(@NotNull
DeclarationDescriptor descriptor)
getContainingModuleOrNull
@Nullable
public static ModuleDescriptor getContainingModuleOrNull(@NotNull
DeclarationDescriptor descriptor)
getContainingClass
@Nullable
public static ClassDescriptor getContainingClass(@NotNull
DeclarationDescriptor descriptor)
isAncestor
public static boolean isAncestor(@Nullable
DeclarationDescriptor ancestor,
@NotNull
DeclarationDescriptor declarationDescriptor,
boolean strict)
isDirectSubclass
public static boolean isDirectSubclass(@NotNull
ClassDescriptor subClass,
@NotNull
ClassDescriptor superClass)
isSubclass
public static boolean isSubclass(@NotNull
ClassDescriptor subClass,
@NotNull
ClassDescriptor superClass)
isFunctionLiteral
public static boolean isFunctionLiteral(@Nullable
DeclarationDescriptor descriptor)
isLocalFunction
public static boolean isLocalFunction(@Nullable
DeclarationDescriptor descriptor)
isFunctionExpression
public static boolean isFunctionExpression(@Nullable
DeclarationDescriptor descriptor)
isCompanionObject
public static boolean isCompanionObject(@Nullable
DeclarationDescriptor descriptor)
isAnonymousObject
public static boolean isAnonymousObject(@NotNull
DeclarationDescriptor descriptor)
isNonCompanionObject
public static boolean isNonCompanionObject(@NotNull
DeclarationDescriptor descriptor)
isInterfaceCompanionObject
public static boolean isInterfaceCompanionObject(@NotNull
DeclarationDescriptor descriptor)
isObject
public static boolean isObject(@NotNull
DeclarationDescriptor descriptor)
isEnumEntry
public static boolean isEnumEntry(@NotNull
DeclarationDescriptor descriptor)
isSingleton
public static boolean isSingleton(@Nullable
DeclarationDescriptor classifier)
isEnumClass
public static boolean isEnumClass(@Nullable
DeclarationDescriptor descriptor)
isAnnotationClass
public static boolean isAnnotationClass(@Nullable
DeclarationDescriptor descriptor)
isInterface
public static boolean isInterface(@Nullable
DeclarationDescriptor descriptor)
isClass
public static boolean isClass(@Nullable
DeclarationDescriptor descriptor)
getSuperclassDescriptors
@NotNull
public static java.util.List<ClassDescriptor> getSuperclassDescriptors(@NotNull
ClassDescriptor classDescriptor)
getSuperClassType
@NotNull
public static KotlinType getSuperClassType(@NotNull
ClassDescriptor classDescriptor)
getSuperClassDescriptor
@Nullable
public static ClassDescriptor getSuperClassDescriptor(@NotNull
ClassDescriptor classDescriptor)
getClassDescriptorForType
@NotNull
public static ClassDescriptor getClassDescriptorForType(@NotNull
KotlinType type)
getClassDescriptorForTypeConstructor
@NotNull
public static ClassDescriptor getClassDescriptorForTypeConstructor(@NotNull
TypeConstructor typeConstructor)
getDefaultConstructorVisibility
@NotNull
public static Visibility getDefaultConstructorVisibility(@NotNull
ClassDescriptor classDescriptor)
getInnerClassByName
@Nullable
public static ClassDescriptor getInnerClassByName(@NotNull
ClassDescriptor classDescriptor,
@NotNull
java.lang.String innerClassName,
@NotNull
LookupLocation location)
getReceiverParameterType
@Nullable
public static KotlinType getReceiverParameterType(@Nullable
ReceiverParameterDescriptor receiverParameterDescriptor)
isStaticNestedClass
public static boolean isStaticNestedClass(@NotNull
DeclarationDescriptor descriptor)
- Returns:
- true if descriptor is a class inside another class and does not have access to the outer class
getStaticNestedClassesScope
@NotNull
public static KtScope getStaticNestedClassesScope(@NotNull
ClassDescriptor descriptor)
isTopLevelOrInnerClass
public static boolean isTopLevelOrInnerClass(@NotNull
ClassDescriptor descriptor)
- Returns:
- true iff
descriptor
's first non-class container is a package
unwrapFakeOverride
@NotNull
public static <D extends CallableMemberDescriptor> D unwrapFakeOverride(@NotNull
D descriptor)
- Given a fake override, finds any declaration of it in the overridden descriptors. Keep in mind that there may be many declarations
of the fake override in the supertypes, this method finds just the only one.
TODO: probably all call-sites of this method are wrong, they should handle all super-declarations
shouldRecordInitializerForProperty
public static boolean shouldRecordInitializerForProperty(@NotNull
VariableDescriptor variable,
@NotNull
KotlinType type)
classCanHaveAbstractMembers
public static boolean classCanHaveAbstractMembers(@NotNull
ClassDescriptor classDescriptor)
classCanHaveOpenMembers
public static boolean classCanHaveOpenMembers(@NotNull
ClassDescriptor classDescriptor)
getAllOverriddenDescriptors
@NotNull
public static <D extends CallableDescriptor> java.util.Set<D> getAllOverriddenDescriptors(@NotNull
D f)
getAllOverriddenDeclarations
@NotNull
public static <D extends CallableMemberDescriptor> java.util.Set<D> getAllOverriddenDeclarations(@NotNull
D memberDescriptor)
containsReifiedTypeParameterWithName
public static boolean containsReifiedTypeParameterWithName(@NotNull
CallableDescriptor descriptor,
@NotNull
java.lang.String name)
containsReifiedTypeParameters
public static boolean containsReifiedTypeParameters(@NotNull
CallableDescriptor descriptor)
isSingletonOrAnonymousObject
public static boolean isSingletonOrAnonymousObject(@NotNull
ClassDescriptor classDescriptor)
canHaveDeclaredConstructors
public static boolean canHaveDeclaredConstructors(@NotNull
ClassDescriptor classDescriptor)
hasDefaultConstructor
public static boolean hasDefaultConstructor(@NotNull
ClassDescriptor classDescriptor)
getPackagesFqNames
public static java.util.Set<FqName> getPackagesFqNames(ModuleDescriptor module)
getSubPackagesFqNames
public static java.util.Set<FqName> getSubPackagesFqNames(PackageViewDescriptor packageView)
getJvmName
@Nullable
public static java.lang.String getJvmName(@NotNull
Annotated annotated)
getJvmNameAnnotation
@Nullable
public static AnnotationDescriptor getJvmNameAnnotation(@NotNull
Annotations annotations)
getVolatileAnnotation
@Nullable
public static AnnotationDescriptor getVolatileAnnotation(@NotNull
Annotated annotated)
getSynchronizedAnnotation
@Nullable
public static AnnotationDescriptor getSynchronizedAnnotation(@NotNull
Annotated annotated)
getContainingSourceFile
@NotNull
public static SourceFile getContainingSourceFile(@NotNull
DeclarationDescriptor descriptor)