org.jetbrains.kotlin.resolve.calls.smartcasts
Class DataFlowValueFactory

java.lang.Object
  extended by 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(JetExpression expression, JetType type, BindingContext bindingContext, DeclarationDescriptor containingDeclarationOrModule)
           
static DataFlowValue createDataFlowValue(JetExpression expression, JetType type, ResolutionContext resolutionContext)
           
static DataFlowValue createDataFlowValue(ReceiverValue receiverValue, BindingContext bindingContext, DeclarationDescriptor containingDeclarationOrModule)
           
static DataFlowValue createDataFlowValue(ReceiverValue receiverValue, ResolutionContext resolutionContext)
           
static DataFlowValue createDataFlowValue(ThisReceiver receiver)
           
static DataFlowValue createDataFlowValue(VariableDescriptor variableDescriptor, BindingContext bindingContext, ModuleDescriptor usageContainingModule)
           
static boolean isStableVariable(VariableDescriptor variableDescriptor, ModuleDescriptor usageModule)
          Determines whether a variable with a given descriptor is stable or not at the given usage place.
static DataFlowValue.Kind variableKind(VariableDescriptor variableDescriptor, ModuleDescriptor usageModule, BindingContext bindingContext)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createDataFlowValue

@NotNull
public static DataFlowValue createDataFlowValue(@NotNull
                                                        JetExpression expression,
                                                        @NotNull
                                                        JetType type,
                                                        @NotNull
                                                        ResolutionContext resolutionContext)

createDataFlowValue

@NotNull
public static DataFlowValue createDataFlowValue(@NotNull
                                                        JetExpression expression,
                                                        @NotNull
                                                        JetType type,
                                                        @NotNull
                                                        BindingContext bindingContext,
                                                        @NotNull
                                                        DeclarationDescriptor containingDeclarationOrModule)

createDataFlowValue

@NotNull
public static DataFlowValue createDataFlowValue(@NotNull
                                                        ThisReceiver 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)

createDataFlowValue

@NotNull
public static DataFlowValue createDataFlowValue(@NotNull
                                                        VariableDescriptor variableDescriptor,
                                                        @NotNull
                                                        BindingContext bindingContext,
                                                        @Nullable
                                                        ModuleDescriptor usageContainingModule)

variableKind

public static DataFlowValue.Kind variableKind(@NotNull
                                              VariableDescriptor variableDescriptor,
                                              @Nullable
                                              ModuleDescriptor usageModule,
                                              @NotNull
                                              BindingContext bindingContext)

isStableVariable

public static boolean isStableVariable(@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 variable
usageModule - a module with a considered usage place, or null if it's not known (not recommended)
Returns:
true if variable is stable, false otherwise