Refactoring: extracted 'BindingContext.getDataFlowInfo'

This commit is contained in:
Svetlana Isakova
2014-08-23 12:23:29 +04:00
parent 0b9c62ab54
commit 3767187027
10 changed files with 26 additions and 23 deletions
@@ -24,6 +24,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage;
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
import org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage;
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
@@ -145,10 +146,7 @@ public class BindingContextUtils {
@Nullable
public static JetTypeInfo getRecordedTypeInfo(@NotNull JetExpression expression, @NotNull BindingContext context) {
if (!context.get(BindingContext.PROCESSED, expression)) return null;
DataFlowInfo dataFlowInfo = context.get(BindingContext.EXPRESSION_DATA_FLOW_INFO, expression);
if (dataFlowInfo == null) {
dataFlowInfo = DataFlowInfo.EMPTY;
}
DataFlowInfo dataFlowInfo = BindingContextUtilPackage.getDataFlowInfo(context, expression);
JetType type = context.get(BindingContext.EXPRESSION_TYPE, expression);
return JetTypeInfo.create(type, dataFlowInfo);
}
@@ -54,3 +54,6 @@ public fun <C : ResolutionContext<C>> ResolutionContext<C>.recordScopeAndDataFlo
trace.record(BindingContext.EXPRESSION_DATA_FLOW_INFO, expression, dataFlowInfo)
}
}
public fun BindingContext.getDataFlowInfo(expression: JetExpression?): DataFlowInfo =
expression?.let { this[BindingContext.EXPRESSION_DATA_FLOW_INFO, it] } ?: DataFlowInfo.EMPTY