org.jetbrains.kotlin.resolve.calls.smartcasts
Class DataFlowValueFactory
java.lang.Object
org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
public class DataFlowValueFactory
- extends java.lang.Object
This class is intended to create data flow values for different kind of expressions.
Then data flow values serve as keys to obtain data flow information for these expressions.
Method Summary |
static DataFlowValue |
createDataFlowValue(KtExpression expression,
KotlinType type,
BindingContext bindingContext,
DeclarationDescriptor containingDeclarationOrModule)
|
static DataFlowValue |
createDataFlowValue(KtExpression expression,
KotlinType type,
ResolutionContext resolutionContext)
|
static DataFlowValue |
createDataFlowValue(ReceiverValue receiverValue,
BindingContext bindingContext,
DeclarationDescriptor containingDeclarationOrModule)
|
static DataFlowValue |
createDataFlowValue(ReceiverValue receiverValue,
ResolutionContext resolutionContext)
|
static DataFlowValue |
createDataFlowValueForProperty(KtProperty property,
VariableDescriptor variableDescriptor,
BindingContext bindingContext,
ModuleDescriptor usageContainingModule)
|
static DataFlowValue |
createDataFlowValueForStableReceiver(ReceiverValue receiver)
|
static boolean |
isStableValue(VariableDescriptor variableDescriptor,
ModuleDescriptor usageModule)
Determines whether a variable with a given descriptor is stable or not at the given usage place. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
createDataFlowValue
@NotNull
public static DataFlowValue createDataFlowValue(@NotNull
KtExpression expression,
@NotNull
KotlinType type,
@NotNull
ResolutionContext resolutionContext)
createDataFlowValue
@NotNull
public static DataFlowValue createDataFlowValue(@NotNull
KtExpression expression,
@NotNull
KotlinType type,
@NotNull
BindingContext bindingContext,
@NotNull
DeclarationDescriptor containingDeclarationOrModule)
createDataFlowValueForStableReceiver
@NotNull
public static DataFlowValue createDataFlowValueForStableReceiver(@NotNull
ReceiverValue receiver)
createDataFlowValue
@NotNull
public static DataFlowValue createDataFlowValue(@NotNull
ReceiverValue receiverValue,
@NotNull
ResolutionContext resolutionContext)
createDataFlowValue
@NotNull
public static DataFlowValue createDataFlowValue(@NotNull
ReceiverValue receiverValue,
@NotNull
BindingContext bindingContext,
@NotNull
DeclarationDescriptor containingDeclarationOrModule)
createDataFlowValueForProperty
@NotNull
public static DataFlowValue createDataFlowValueForProperty(@NotNull
KtProperty property,
@NotNull
VariableDescriptor variableDescriptor,
@NotNull
BindingContext bindingContext,
@Nullable
ModuleDescriptor usageContainingModule)
isStableValue
public static boolean isStableValue(@NotNull
VariableDescriptor variableDescriptor,
@Nullable
ModuleDescriptor usageModule)
- Determines whether a variable with a given descriptor is stable or not at the given usage place.
Stable means that the variable value cannot change. The simple (non-property) variable is considered stable if it's immutable (val).
If the variable is a property, it's considered stable if it's immutable (val) AND it's final (not open) AND
the default getter is in use (otherwise nobody can guarantee that a getter is consistent) AND
(it's private OR internal OR used at the same module where it's defined).
The last check corresponds to a risk of changing property definition in another module, e.g. from "val" to "var".
- Parameters:
variableDescriptor
- descriptor of a considered variableusageModule
- a module with a considered usage place, or null if it's not known (not recommended)
- Returns:
- true if variable is stable, false otherwise