Outer DataFlowInfo is passed to TopDownAnalyzer
This commit is contained in:
@@ -22,6 +22,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.MutableClassDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
|
||||
@@ -37,6 +38,7 @@ public interface BodiesResolveContext {
|
||||
Function<JetDeclaration, JetScope> getDeclaringScopes();
|
||||
Map<JetScript, ScriptDescriptor> getScripts();
|
||||
Map<JetScript, WritableScope> getScriptScopes();
|
||||
DataFlowInfo getOuterDataFlowInfo();
|
||||
|
||||
void setTopDownAnalysisParameters(TopDownAnalysisParameters parameters);
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.MutableClassDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
|
||||
@@ -43,6 +44,7 @@ public class CachedBodiesResolveContext implements BodiesResolveContext {
|
||||
private final Function<JetDeclaration, JetScope> declaringScopes;
|
||||
private final Map<JetScript, ScriptDescriptor> scripts;
|
||||
private final Map<JetScript, WritableScope> scriptScopes;
|
||||
private final DataFlowInfo outerDataFlowInfo;
|
||||
|
||||
private @NotNull TopDownAnalysisParameters topDownAnalysisParameters;
|
||||
|
||||
@@ -55,6 +57,7 @@ public class CachedBodiesResolveContext implements BodiesResolveContext {
|
||||
declaringScopes = context.getDeclaringScopes();
|
||||
scripts = Collections.unmodifiableMap(context.getScripts());
|
||||
scriptScopes = Collections.unmodifiableMap(context.getScriptScopes());
|
||||
outerDataFlowInfo = context.getOuterDataFlowInfo();
|
||||
|
||||
topDownAnalysisParameters = context.getTopDownAnalysisParameters();
|
||||
}
|
||||
@@ -99,6 +102,11 @@ public class CachedBodiesResolveContext implements BodiesResolveContext {
|
||||
return scriptScopes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataFlowInfo getOuterDataFlowInfo() {
|
||||
return outerDataFlowInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTopDownAnalysisParameters(@NotNull TopDownAnalysisParameters parameters) {
|
||||
topDownAnalysisParameters = parameters;
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.jetbrains.jet.lang.descriptors.impl.MutableClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.MutableClassDescriptorLite;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.NamespaceDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
|
||||
@@ -38,6 +39,8 @@ import java.util.Map;
|
||||
|
||||
public class TopDownAnalysisContext implements BodiesResolveContext {
|
||||
|
||||
private DataFlowInfo outerDataFlowInfo = DataFlowInfo.EMPTY;
|
||||
|
||||
private final Map<JetClass, MutableClassDescriptor> classes = Maps.newLinkedHashMap();
|
||||
private final Map<JetObjectDeclaration, MutableClassDescriptor> objects = Maps.newLinkedHashMap();
|
||||
protected final Map<JetFile, NamespaceDescriptorImpl> namespaceDescriptors = Maps.newHashMap();
|
||||
@@ -179,4 +182,13 @@ public class TopDownAnalysisContext implements BodiesResolveContext {
|
||||
public void setClassesTopologicalOrder(@NotNull List<MutableClassDescriptorLite> classesTopologicalOrder) {
|
||||
this.classesTopologicalOrder = classesTopologicalOrder;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public DataFlowInfo getOuterDataFlowInfo() {
|
||||
return outerDataFlowInfo;
|
||||
}
|
||||
|
||||
public void setOuterDataFlowInfo(@NotNull DataFlowInfo outerDataFlowInfo) {
|
||||
this.outerDataFlowInfo = outerDataFlowInfo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl;
|
||||
import org.jetbrains.jet.lang.types.expressions.ExpressionTypingContext;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@@ -181,9 +182,7 @@ public class TopDownAnalyzer {
|
||||
}
|
||||
|
||||
public static void processClassOrObject(
|
||||
@NotNull Project project,
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull JetScope outerScope,
|
||||
@NotNull ExpressionTypingContext context,
|
||||
@NotNull final DeclarationDescriptor containingDeclaration,
|
||||
@NotNull JetClassOrObject object
|
||||
) {
|
||||
@@ -197,9 +196,11 @@ public class TopDownAnalyzer {
|
||||
false, true, Collections.<AnalyzerScriptParameter>emptyList());
|
||||
|
||||
InjectorForTopDownAnalyzerBasic injector = new InjectorForTopDownAnalyzerBasic(
|
||||
project, topDownAnalysisParameters, new ObservableBindingTrace(trace), moduleDescriptor);
|
||||
object.getProject(), topDownAnalysisParameters, new ObservableBindingTrace(context.trace), moduleDescriptor);
|
||||
|
||||
injector.getTopDownAnalyzer().doProcess(outerScope, new NamespaceLikeBuilder() {
|
||||
injector.getTopDownAnalysisContext().setOuterDataFlowInfo(context.dataFlowInfo);
|
||||
|
||||
injector.getTopDownAnalyzer().doProcess(context.scope, new NamespaceLikeBuilder() {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
|
||||
+3
-2
@@ -81,8 +81,9 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
|
||||
};
|
||||
ObservableBindingTrace traceAdapter = new ObservableBindingTrace(temporaryTrace);
|
||||
traceAdapter.addHandler(CLASS, handler);
|
||||
TopDownAnalyzer.processClassOrObject(context.expressionTypingServices.getProject(), traceAdapter, context.scope,
|
||||
context.scope.getContainingDeclaration(), expression.getObjectDeclaration());
|
||||
TopDownAnalyzer.processClassOrObject(context.replaceBindingTrace(traceAdapter),
|
||||
context.scope.getContainingDeclaration(),
|
||||
expression.getObjectDeclaration());
|
||||
|
||||
DelegatingBindingTrace cloneDelta = new DelegatingBindingTrace(
|
||||
new BindingTraceContext().getBindingContext(), "cached delta trace for object literal expression resolve", expression);
|
||||
|
||||
+2
-4
@@ -84,8 +84,7 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
|
||||
|
||||
@Override
|
||||
public JetTypeInfo visitObjectDeclaration(JetObjectDeclaration declaration, ExpressionTypingContext context) {
|
||||
TopDownAnalyzer.processClassOrObject(context.expressionTypingServices.getProject(), context.trace, scope,
|
||||
scope.getContainingDeclaration(), declaration);
|
||||
TopDownAnalyzer.processClassOrObject(context.replaceScope(scope), scope.getContainingDeclaration(), declaration);
|
||||
ClassDescriptor classDescriptor = context.trace.getBindingContext().get(BindingContext.CLASS, declaration);
|
||||
if (classDescriptor != null) {
|
||||
VariableDescriptor variableDescriptor = context.expressionTypingServices.getDescriptorResolver()
|
||||
@@ -169,8 +168,7 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
|
||||
|
||||
@Override
|
||||
public JetTypeInfo visitClass(JetClass klass, ExpressionTypingContext context) {
|
||||
TopDownAnalyzer.processClassOrObject(context.expressionTypingServices.getProject(), context.trace, scope,
|
||||
scope.getContainingDeclaration(), klass);
|
||||
TopDownAnalyzer.processClassOrObject(context.replaceScope(scope), scope.getContainingDeclaration(), klass);
|
||||
ClassDescriptor classDescriptor = context.trace.getBindingContext().get(BindingContext.CLASS, klass);
|
||||
if (classDescriptor != null) {
|
||||
scope.addClassifierDescriptor(classDescriptor);
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.jetbrains.jet.lang.descriptors.annotations.Annotated;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.MutableClassDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.*;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.lazy.KotlinCodeAnalyzer;
|
||||
import org.jetbrains.jet.lang.resolve.lazy.LazyDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.lazy.ResolveSession;
|
||||
@@ -438,6 +439,11 @@ public class ResolveElementCache {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataFlowInfo getOuterDataFlowInfo() {
|
||||
return DataFlowInfo.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTopDownAnalysisParameters(TopDownAnalysisParameters parameters) {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user