org.jetbrains.jet.lang.resolve
Class DescriptorUtils
java.lang.Object
org.jetbrains.jet.lang.resolve.DescriptorUtils
public class DescriptorUtils
- extends java.lang.Object
Method Summary |
static boolean |
areInSameModule(DeclarationDescriptor first,
DeclarationDescriptor second)
|
static DeclarationDescriptor |
findTopLevelParent(DeclarationDescriptor declarationDescriptor)
|
static java.util.Set<ClassDescriptor> |
getAllSuperClasses(ClassDescriptor klass)
|
static ClassDescriptor |
getClassDescriptorForType(JetType type)
|
static ClassDescriptor |
getClassDescriptorForTypeConstructor(TypeConstructor typeConstructor)
|
static ConstructorDescriptor |
getConstructorOfDataClass(ClassDescriptor classDescriptor)
|
static ConstructorDescriptor |
getConstructorOfSingletonObject(ClassDescriptor classDescriptor)
|
static ClassDescriptor |
getContainingClass(JetScope scope)
|
static ModuleDescriptor |
getContainingModule(DeclarationDescriptor descriptor)
|
static Visibility |
getDefaultConstructorVisibility(ClassDescriptor classDescriptor)
|
static ReceiverParameterDescriptor |
getExpectedThisObjectIfNeeded(DeclarationDescriptor containingDeclaration)
|
static FqNameUnsafe |
getFqName(DeclarationDescriptor descriptor)
|
static FqName |
getFqNameSafe(DeclarationDescriptor descriptor)
|
static ClassDescriptor |
getInnerClassByName(ClassDescriptor classDescriptor,
java.lang.String innerClassName)
|
static
|
getParentOfType(DeclarationDescriptor descriptor,
java.lang.Class<D> aClass)
|
static
|
getParentOfType(DeclarationDescriptor descriptor,
java.lang.Class<D> aClass,
boolean strict)
|
static JetType |
getReceiverParameterType(ReceiverParameterDescriptor receiverParameterDescriptor)
|
static JetScope |
getStaticNestedClassesScope(ClassDescriptor descriptor)
|
static java.util.List<ClassDescriptor> |
getSuperclassDescriptors(ClassDescriptor classDescriptor)
|
static Visibility |
getSyntheticClassObjectVisibility()
|
static java.util.List<JetType> |
getValueParametersTypes(java.util.List<ValueParameterDescriptor> valueParameters)
|
static JetType |
getVarargParameterType(JetType elementType)
|
static boolean |
isAncestor(DeclarationDescriptor ancestor,
DeclarationDescriptor declarationDescriptor,
boolean strict)
|
static boolean |
isAnnotationClass(DeclarationDescriptor descriptor)
|
static boolean |
isAnonymousObject(DeclarationDescriptor descriptor)
|
static boolean |
isAny(DeclarationDescriptor superClassDescriptor)
|
static boolean |
isClass(DeclarationDescriptor descriptor)
|
static boolean |
isClassObject(DeclarationDescriptor descriptor)
|
static boolean |
isConstructorOfStaticNestedClass(CallableDescriptor descriptor)
|
static boolean |
isEnumClass(DeclarationDescriptor descriptor)
|
static boolean |
isEnumClassObject(DeclarationDescriptor descriptor)
|
static boolean |
isEnumEntry(DeclarationDescriptor descriptor)
|
static boolean |
isEnumValueOfMethod(FunctionDescriptor functionDescriptor)
|
static boolean |
isEnumValuesMethod(FunctionDescriptor functionDescriptor)
|
static boolean |
isFunctionLiteral(FunctionDescriptor descriptor)
|
static boolean |
isInsideOuterClassOrItsSubclass(DeclarationDescriptor nested,
ClassDescriptor outer)
|
static boolean |
isKindOf(DeclarationDescriptor descriptor,
ClassKind classKind)
|
static boolean |
isLocal(DeclarationDescriptor containerOfTheCurrentLocality,
DeclarationDescriptor candidate)
The primary case for local extensions is the following:
I had a locally declared extension function or a local variable of function type called foo
And I called it on my x
Now, someone added function foo() to the class of x
My code should not change
thus
local extension prevail over members (and members prevail over all non-local extensions) |
static boolean |
isObject(DeclarationDescriptor descriptor)
|
static boolean |
isPropertyCompileTimeConstant(VariableDescriptor descriptor)
|
static boolean |
isSingleton(DeclarationDescriptor classifier)
|
static boolean |
isStaticNestedClass(DeclarationDescriptor descriptor)
|
static boolean |
isSubclass(ClassDescriptor subClass,
ClassDescriptor superClass)
|
static boolean |
isSyntheticClassObject(DeclarationDescriptor descriptor)
|
static boolean |
isTopLevelDeclaration(DeclarationDescriptor descriptor)
|
static boolean |
isTopLevelOrInnerClass(ClassDescriptor descriptor)
|
static boolean |
isTrait(DeclarationDescriptor descriptor)
|
static boolean |
shouldRecordInitializerForProperty(VariableDescriptor variable,
JetType type)
|
static
|
substituteBounds(D functionDescriptor)
|
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 |
substituteBounds
@NotNull
public static <D extends CallableDescriptor> D substituteBounds(@NotNull
D functionDescriptor)
getExpectedThisObjectIfNeeded
@Nullable
public static ReceiverParameterDescriptor getExpectedThisObjectIfNeeded(@NotNull
DeclarationDescriptor containingDeclaration)
isLocal
public static boolean isLocal(DeclarationDescriptor containerOfTheCurrentLocality,
DeclarationDescriptor candidate)
- The primary case for local extensions is the following:
I had a locally declared extension function or a local variable of function type called foo
And I called it on my x
Now, someone added function foo() to the class of x
My code should not change
thus
local extension prevail over members (and members prevail over all non-local extensions)
getFqName
@NotNull
public static FqNameUnsafe getFqName(@NotNull
DeclarationDescriptor descriptor)
getFqNameSafe
@NotNull
public static FqName getFqNameSafe(@NotNull
DeclarationDescriptor descriptor)
isTopLevelDeclaration
public static boolean isTopLevelDeclaration(@NotNull
DeclarationDescriptor descriptor)
areInSameModule
public static boolean areInSameModule(@NotNull
DeclarationDescriptor first,
@NotNull
DeclarationDescriptor second)
findTopLevelParent
@Nullable
public static DeclarationDescriptor findTopLevelParent(@NotNull
DeclarationDescriptor declarationDescriptor)
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)
isAncestor
public static boolean isAncestor(@Nullable
DeclarationDescriptor ancestor,
@NotNull
DeclarationDescriptor declarationDescriptor,
boolean strict)
isSubclass
public static boolean isSubclass(@NotNull
ClassDescriptor subClass,
@NotNull
ClassDescriptor superClass)
isFunctionLiteral
public static boolean isFunctionLiteral(@NotNull
FunctionDescriptor descriptor)
isClassObject
public static boolean isClassObject(@NotNull
DeclarationDescriptor descriptor)
isAnonymousObject
public static boolean isAnonymousObject(@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(@NotNull
DeclarationDescriptor descriptor)
isAnnotationClass
public static boolean isAnnotationClass(@Nullable
DeclarationDescriptor descriptor)
isTrait
public static boolean isTrait(@Nullable
DeclarationDescriptor descriptor)
isClass
public static boolean isClass(@Nullable
DeclarationDescriptor descriptor)
isKindOf
public static boolean isKindOf(@Nullable
DeclarationDescriptor descriptor,
@NotNull
ClassKind classKind)
getSuperclassDescriptors
@NotNull
public static java.util.List<ClassDescriptor> getSuperclassDescriptors(@NotNull
ClassDescriptor classDescriptor)
getClassDescriptorForType
@NotNull
public static ClassDescriptor getClassDescriptorForType(@NotNull
JetType type)
getClassDescriptorForTypeConstructor
@NotNull
public static ClassDescriptor getClassDescriptorForTypeConstructor(@NotNull
TypeConstructor typeConstructor)
isAny
public static boolean isAny(@NotNull
DeclarationDescriptor superClassDescriptor)
isEnumClassObject
public static boolean isEnumClassObject(@NotNull
DeclarationDescriptor descriptor)
isSyntheticClassObject
public static boolean isSyntheticClassObject(@NotNull
DeclarationDescriptor descriptor)
getDefaultConstructorVisibility
@NotNull
public static Visibility getDefaultConstructorVisibility(@NotNull
ClassDescriptor classDescriptor)
getSyntheticClassObjectVisibility
@NotNull
public static Visibility getSyntheticClassObjectVisibility()
getInnerClassByName
@Nullable
public static ClassDescriptor getInnerClassByName(@NotNull
ClassDescriptor classDescriptor,
@NotNull
java.lang.String innerClassName)
getConstructorOfDataClass
@NotNull
public static ConstructorDescriptor getConstructorOfDataClass(ClassDescriptor classDescriptor)
getConstructorOfSingletonObject
@NotNull
public static ConstructorDescriptor getConstructorOfSingletonObject(ClassDescriptor classDescriptor)
getReceiverParameterType
@Nullable
public static JetType getReceiverParameterType(@Nullable
ReceiverParameterDescriptor receiverParameterDescriptor)
getVarargParameterType
@NotNull
public static JetType getVarargParameterType(@NotNull
JetType elementType)
getValueParametersTypes
@NotNull
public static java.util.List<JetType> getValueParametersTypes(@NotNull
java.util.List<ValueParameterDescriptor> valueParameters)
isInsideOuterClassOrItsSubclass
public static boolean isInsideOuterClassOrItsSubclass(@Nullable
DeclarationDescriptor nested,
@NotNull
ClassDescriptor outer)
isConstructorOfStaticNestedClass
public static boolean isConstructorOfStaticNestedClass(@Nullable
CallableDescriptor descriptor)
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
getContainingClass
@Nullable
public static ClassDescriptor getContainingClass(@NotNull
JetScope scope)
getStaticNestedClassesScope
@NotNull
public static JetScope getStaticNestedClassesScope(@NotNull
ClassDescriptor descriptor)
isEnumValueOfMethod
public static boolean isEnumValueOfMethod(@NotNull
FunctionDescriptor functionDescriptor)
isEnumValuesMethod
public static boolean isEnumValuesMethod(@NotNull
FunctionDescriptor functionDescriptor)
getAllSuperClasses
@NotNull
public static java.util.Set<ClassDescriptor> getAllSuperClasses(@NotNull
ClassDescriptor klass)
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
isPropertyCompileTimeConstant
public static boolean isPropertyCompileTimeConstant(@NotNull
VariableDescriptor descriptor)
shouldRecordInitializerForProperty
public static boolean shouldRecordInitializerForProperty(@NotNull
VariableDescriptor variable,
@NotNull
JetType type)