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 void |
addSuperTypes(JetType type,
java.util.Set<JetType> set)
|
static Modality |
convertModality(Modality modality,
boolean makeNonAbstract)
|
static VariableDescriptor |
filterNonExtensionProperty(java.util.Collection<VariableDescriptor> variables)
|
static DeclarationDescriptor |
findTopLevelParent(DeclarationDescriptor declarationDescriptor)
|
static java.util.Set<ClassDescriptor> |
getAllSuperClasses(ClassDescriptor klass)
|
static ClassDescriptor |
getClassDescriptorForType(JetType type)
|
static ClassDescriptor |
getClassForCorrespondingJavaNamespace(NamespaceDescriptor correspondingNamespace)
|
static Name |
getClassObjectName(Name className)
|
static Name |
getClassObjectName(java.lang.String className)
|
static ConstructorDescriptor |
getConstructorOfDataClass(ClassDescriptor classDescriptor)
|
static ConstructorDescriptor |
getConstructorOfSingletonObject(ClassDescriptor classDescriptor)
|
static ClassDescriptor |
getContainingClass(JetScope scope)
|
static Visibility |
getDefaultConstructorVisibility(ClassDescriptor classDescriptor)
|
static ReceiverParameterDescriptor |
getExpectedThisObjectIfNeeded(DeclarationDescriptor containingDeclaration)
|
static FqNameUnsafe |
getFQName(DeclarationDescriptor descriptor)
|
static JetType |
getFunctionExpectedReturnType(FunctionDescriptor descriptor,
JetElement function)
|
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 java.util.List<DeclarationDescriptor> |
getPathWithoutRootNsAndModule(DeclarationDescriptor descriptor)
|
static PropertyDescriptor |
getPropertyDescriptor(JetParameter constructorParameter,
BindingContext bindingContext)
|
static PropertyDescriptor |
getPropertyDescriptor(JetProperty property,
BindingContext bindingContext)
|
static JetType |
getReceiverParameterType(ReceiverParameterDescriptor receiverParameterDescriptor)
|
static java.util.List<java.lang.String> |
getSortedValueArguments(AnnotationDescriptor descriptor,
DescriptorRenderer rendererForTypesIfNecessary)
|
static JetScope |
getStaticNestedClassesScope(ClassDescriptor descriptor)
|
static java.util.List<ClassDescriptor> |
getSuperclassDescriptors(ClassDescriptor classDescriptor)
|
static java.util.List<JetType> |
getValueParametersTypes(java.util.List<ValueParameterDescriptor> valueParameters)
|
static JetType |
getVarargParameterType(JetType elementType)
|
static JetType |
getVarargParameterType(JetType elementType,
Variance projectionKind)
|
static boolean |
inStaticContext(DeclarationDescriptor descriptor)
|
static boolean |
isAncestor(DeclarationDescriptor ancestor,
DeclarationDescriptor declarationDescriptor,
boolean strict)
|
static boolean |
isAnnotationClass(DeclarationDescriptor descriptor)
|
static boolean |
isAnonymous(ClassifierDescriptor descriptor)
|
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 |
isExternallyAccessible(PropertyDescriptor propertyDescriptor)
|
static boolean |
isFunctionLiteral(FunctionDescriptor descriptor)
|
static boolean |
isInSameModule(DeclarationDescriptor first,
DeclarationDescriptor second)
|
static boolean |
isInSameNamespace(DeclarationDescriptor first,
DeclarationDescriptor second)
|
static boolean |
isIteratorWithoutRemoveImpl(ClassDescriptor classDescriptor)
|
static boolean |
isKindOf(DeclarationDescriptor descriptor,
ClassKind classKind)
|
static boolean |
isKindOf(JetType jetType,
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 |
isNotAny(DeclarationDescriptor superClassDescriptor)
|
static boolean |
isRootNamespace(NamespaceDescriptor namespaceDescriptor)
|
static boolean |
isStaticNestedClass(DeclarationDescriptor descriptor)
|
static boolean |
isSubclass(ClassDescriptor subClass,
ClassDescriptor superClass)
|
static boolean |
isTopLevelDeclaration(DeclarationDescriptor descriptor)
|
static ReceiverValue |
safeGetValue(ReceiverParameterDescriptor receiverParameterDescriptor)
|
static
|
substituteBounds(D functionDescriptor)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DescriptorUtils
public DescriptorUtils()
substituteBounds
@NotNull
public static <D extends CallableDescriptor> D substituteBounds(@NotNull
D functionDescriptor)
convertModality
public static Modality convertModality(Modality modality,
boolean makeNonAbstract)
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)
isTopLevelDeclaration
public static boolean isTopLevelDeclaration(@NotNull
DeclarationDescriptor descriptor)
isInSameNamespace
public static boolean isInSameNamespace(@NotNull
DeclarationDescriptor first,
@NotNull
DeclarationDescriptor second)
isInSameModule
public static boolean isInSameModule(@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)
isAncestor
public static boolean isAncestor(@Nullable
DeclarationDescriptor ancestor,
@NotNull
DeclarationDescriptor declarationDescriptor,
boolean strict)
filterNonExtensionProperty
@Nullable
public static VariableDescriptor filterNonExtensionProperty(java.util.Collection<VariableDescriptor> variables)
getFunctionExpectedReturnType
@NotNull
public static JetType getFunctionExpectedReturnType(@NotNull
FunctionDescriptor descriptor,
@NotNull
JetElement function)
isSubclass
public static boolean isSubclass(@NotNull
ClassDescriptor subClass,
@NotNull
ClassDescriptor superClass)
addSuperTypes
public static void addSuperTypes(JetType type,
java.util.Set<JetType> set)
isRootNamespace
public static boolean isRootNamespace(@NotNull
NamespaceDescriptor namespaceDescriptor)
getPathWithoutRootNsAndModule
@NotNull
public static java.util.List<DeclarationDescriptor> getPathWithoutRootNsAndModule(@NotNull
DeclarationDescriptor descriptor)
isFunctionLiteral
public static boolean isFunctionLiteral(@NotNull
FunctionDescriptor descriptor)
isClassObject
public static boolean isClassObject(@NotNull
DeclarationDescriptor descriptor)
isAnonymous
public static boolean isAnonymous(@Nullable
ClassifierDescriptor descriptor)
isEnumEntry
public static boolean isEnumEntry(@NotNull
DeclarationDescriptor descriptor)
isEnumClass
public static boolean isEnumClass(@NotNull
DeclarationDescriptor descriptor)
isAnnotationClass
public static boolean isAnnotationClass(@Nullable
DeclarationDescriptor descriptor)
isClass
public static boolean isClass(@NotNull
DeclarationDescriptor descriptor)
isKindOf
public static boolean isKindOf(@NotNull
JetType jetType,
@NotNull
ClassKind classKind)
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)
isNotAny
public static boolean isNotAny(@NotNull
DeclarationDescriptor superClassDescriptor)
inStaticContext
public static boolean inStaticContext(@NotNull
DeclarationDescriptor descriptor)
isIteratorWithoutRemoveImpl
public static boolean isIteratorWithoutRemoveImpl(@NotNull
ClassDescriptor classDescriptor)
getClassObjectName
@NotNull
public static Name getClassObjectName(@NotNull
Name className)
getClassObjectName
@NotNull
public static Name getClassObjectName(@NotNull
java.lang.String className)
isEnumClassObject
public static boolean isEnumClassObject(@NotNull
DeclarationDescriptor descriptor)
getDefaultConstructorVisibility
@NotNull
public static Visibility getDefaultConstructorVisibility(@NotNull
ClassDescriptor classDescriptor)
getSortedValueArguments
@NotNull
public static java.util.List<java.lang.String> getSortedValueArguments(@NotNull
AnnotationDescriptor descriptor,
@Nullable
DescriptorRenderer rendererForTypesIfNecessary)
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)
safeGetValue
@NotNull
public static ReceiverValue safeGetValue(@Nullable
ReceiverParameterDescriptor receiverParameterDescriptor)
isExternallyAccessible
public static boolean isExternallyAccessible(PropertyDescriptor propertyDescriptor)
getVarargParameterType
@NotNull
public static JetType getVarargParameterType(@NotNull
JetType elementType)
getVarargParameterType
@NotNull
public static JetType getVarargParameterType(@NotNull
JetType elementType,
@NotNull
Variance projectionKind)
getValueParametersTypes
@NotNull
public static java.util.List<JetType> getValueParametersTypes(@NotNull
java.util.List<ValueParameterDescriptor> valueParameters)
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)
getClassForCorrespondingJavaNamespace
@Nullable
public static ClassDescriptor getClassForCorrespondingJavaNamespace(@NotNull
NamespaceDescriptor correspondingNamespace)
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)
getPropertyDescriptor
@NotNull
public static PropertyDescriptor getPropertyDescriptor(@NotNull
JetProperty property,
@NotNull
BindingContext bindingContext)
getPropertyDescriptor
@NotNull
public static PropertyDescriptor getPropertyDescriptor(@NotNull
JetParameter constructorParameter,
@NotNull
BindingContext bindingContext)