PlatformToKotlinClassMap injected into expression analyzers
This commit is contained in:
@@ -18,6 +18,7 @@ package org.jetbrains.jet.di;
|
||||
|
||||
import org.jetbrains.jet.lang.resolve.BodyResolver;
|
||||
import org.jetbrains.jet.lang.resolve.calls.NeedSyntheticCallResolverExtension;
|
||||
import org.jetbrains.jet.lang.PlatformToKotlinClassMap;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.jet.lang.resolve.TopDownAnalysisParameters;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
@@ -44,6 +45,7 @@ public class InjectorForBodyResolve {
|
||||
|
||||
private final BodyResolver bodyResolver;
|
||||
private final NeedSyntheticCallResolverExtension needSyntheticCallResolverExtension;
|
||||
private final PlatformToKotlinClassMap platformToKotlinClassMap;
|
||||
private final Project project;
|
||||
private final TopDownAnalysisParameters topDownAnalysisParameters;
|
||||
private final BindingTrace bindingTrace;
|
||||
@@ -72,6 +74,7 @@ public class InjectorForBodyResolve {
|
||||
) {
|
||||
this.bodyResolver = new BodyResolver();
|
||||
this.needSyntheticCallResolverExtension = new NeedSyntheticCallResolverExtension();
|
||||
this.platformToKotlinClassMap = moduleDescriptor.getPlatformToKotlinClassMap();
|
||||
this.project = project;
|
||||
this.topDownAnalysisParameters = topDownAnalysisParameters;
|
||||
this.bindingTrace = bindingTrace;
|
||||
@@ -117,6 +120,7 @@ public class InjectorForBodyResolve {
|
||||
expressionTypingServices.setCallExpressionResolver(callExpressionResolver);
|
||||
expressionTypingServices.setCallResolver(callResolver);
|
||||
expressionTypingServices.setDescriptorResolver(descriptorResolver);
|
||||
expressionTypingServices.setPlatformToKotlinClassMap(platformToKotlinClassMap);
|
||||
expressionTypingServices.setProject(project);
|
||||
expressionTypingServices.setTypeResolver(typeResolver);
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.jetbrains.jet.lang.resolve.AnnotationResolver;
|
||||
import org.jetbrains.jet.lang.resolve.QualifiedExpressionResolver;
|
||||
import org.jetbrains.jet.lang.psi.JetImportsFactory;
|
||||
import org.jetbrains.jet.lang.resolve.calls.NeedSyntheticCallResolverExtension;
|
||||
import org.jetbrains.jet.lang.PlatformToKotlinClassMap;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallExpressionResolver;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallResolver;
|
||||
import org.jetbrains.jet.lang.resolve.calls.ArgumentTypeResolver;
|
||||
@@ -48,6 +49,7 @@ public class InjectorForLazyResolve {
|
||||
private final QualifiedExpressionResolver qualifiedExpressionResolver;
|
||||
private final JetImportsFactory jetImportsFactory;
|
||||
private final NeedSyntheticCallResolverExtension needSyntheticCallResolverExtension;
|
||||
private final PlatformToKotlinClassMap platformToKotlinClassMap;
|
||||
private final CallExpressionResolver callExpressionResolver;
|
||||
private final CallResolver callResolver;
|
||||
private final ArgumentTypeResolver argumentTypeResolver;
|
||||
@@ -69,6 +71,7 @@ public class InjectorForLazyResolve {
|
||||
this.qualifiedExpressionResolver = new QualifiedExpressionResolver();
|
||||
this.jetImportsFactory = new JetImportsFactory();
|
||||
this.needSyntheticCallResolverExtension = new NeedSyntheticCallResolverExtension();
|
||||
this.platformToKotlinClassMap = moduleDescriptor.getPlatformToKotlinClassMap();
|
||||
this.callExpressionResolver = new CallExpressionResolver();
|
||||
this.callResolver = new CallResolver();
|
||||
this.argumentTypeResolver = new ArgumentTypeResolver();
|
||||
@@ -81,6 +84,7 @@ public class InjectorForLazyResolve {
|
||||
this.expressionTypingServices.setCallExpressionResolver(callExpressionResolver);
|
||||
this.expressionTypingServices.setCallResolver(callResolver);
|
||||
this.expressionTypingServices.setDescriptorResolver(descriptorResolver);
|
||||
this.expressionTypingServices.setPlatformToKotlinClassMap(platformToKotlinClassMap);
|
||||
this.expressionTypingServices.setProject(project);
|
||||
this.expressionTypingServices.setTypeResolver(typeResolver);
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.jetbrains.jet.di;
|
||||
|
||||
import org.jetbrains.jet.lang.types.expressions.ExpressionTypingServices;
|
||||
import org.jetbrains.jet.lang.resolve.calls.NeedSyntheticCallResolverExtension;
|
||||
import org.jetbrains.jet.lang.PlatformToKotlinClassMap;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallExpressionResolver;
|
||||
@@ -36,6 +37,7 @@ public class InjectorForMacros {
|
||||
|
||||
private final ExpressionTypingServices expressionTypingServices;
|
||||
private final NeedSyntheticCallResolverExtension needSyntheticCallResolverExtension;
|
||||
private final PlatformToKotlinClassMap platformToKotlinClassMap;
|
||||
private final Project project;
|
||||
private final ModuleDescriptor moduleDescriptor;
|
||||
private final CallExpressionResolver callExpressionResolver;
|
||||
@@ -53,6 +55,7 @@ public class InjectorForMacros {
|
||||
) {
|
||||
this.expressionTypingServices = new ExpressionTypingServices();
|
||||
this.needSyntheticCallResolverExtension = new NeedSyntheticCallResolverExtension();
|
||||
this.platformToKotlinClassMap = moduleDescriptor.getPlatformToKotlinClassMap();
|
||||
this.project = project;
|
||||
this.moduleDescriptor = moduleDescriptor;
|
||||
this.callExpressionResolver = new CallExpressionResolver();
|
||||
@@ -67,6 +70,7 @@ public class InjectorForMacros {
|
||||
this.expressionTypingServices.setCallExpressionResolver(callExpressionResolver);
|
||||
this.expressionTypingServices.setCallResolver(callResolver);
|
||||
this.expressionTypingServices.setDescriptorResolver(descriptorResolver);
|
||||
this.expressionTypingServices.setPlatformToKotlinClassMap(platformToKotlinClassMap);
|
||||
this.expressionTypingServices.setProject(project);
|
||||
this.expressionTypingServices.setTypeResolver(typeResolver);
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.types.DependencyClassByQualifiedNameResolverDummyImpl;
|
||||
import org.jetbrains.jet.lang.resolve.NamespaceFactoryImpl;
|
||||
import org.jetbrains.jet.lang.PlatformToKotlinClassMap;
|
||||
import org.jetbrains.jet.lang.resolve.DeclarationResolver;
|
||||
import org.jetbrains.jet.lang.resolve.AnnotationResolver;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallResolver;
|
||||
@@ -64,6 +65,7 @@ public class InjectorForTopDownAnalyzerBasic {
|
||||
private final ModuleDescriptorImpl moduleDescriptor;
|
||||
private final DependencyClassByQualifiedNameResolverDummyImpl dependencyClassByQualifiedNameResolverDummy;
|
||||
private final NamespaceFactoryImpl namespaceFactory;
|
||||
private final PlatformToKotlinClassMap platformToKotlinClassMap;
|
||||
private final DeclarationResolver declarationResolver;
|
||||
private final AnnotationResolver annotationResolver;
|
||||
private final CallResolver callResolver;
|
||||
@@ -85,7 +87,8 @@ public class InjectorForTopDownAnalyzerBasic {
|
||||
@NotNull Project project,
|
||||
@NotNull TopDownAnalysisParameters topDownAnalysisParameters,
|
||||
@NotNull BindingTrace bindingTrace,
|
||||
@NotNull ModuleDescriptorImpl moduleDescriptor
|
||||
@NotNull ModuleDescriptorImpl moduleDescriptor,
|
||||
@NotNull PlatformToKotlinClassMap platformToKotlinClassMap
|
||||
) {
|
||||
this.topDownAnalyzer = new TopDownAnalyzer();
|
||||
this.topDownAnalysisContext = new TopDownAnalysisContext();
|
||||
@@ -100,6 +103,7 @@ public class InjectorForTopDownAnalyzerBasic {
|
||||
this.moduleDescriptor = moduleDescriptor;
|
||||
this.dependencyClassByQualifiedNameResolverDummy = new DependencyClassByQualifiedNameResolverDummyImpl();
|
||||
this.namespaceFactory = new NamespaceFactoryImpl();
|
||||
this.platformToKotlinClassMap = platformToKotlinClassMap;
|
||||
this.declarationResolver = new DeclarationResolver();
|
||||
this.annotationResolver = new AnnotationResolver();
|
||||
this.callResolver = new CallResolver();
|
||||
@@ -175,6 +179,7 @@ public class InjectorForTopDownAnalyzerBasic {
|
||||
expressionTypingServices.setCallExpressionResolver(callExpressionResolver);
|
||||
expressionTypingServices.setCallResolver(callResolver);
|
||||
expressionTypingServices.setDescriptorResolver(descriptorResolver);
|
||||
expressionTypingServices.setPlatformToKotlinClassMap(platformToKotlinClassMap);
|
||||
expressionTypingServices.setProject(project);
|
||||
expressionTypingServices.setTypeResolver(typeResolver);
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ public class TopDownAnalyzer {
|
||||
Predicates.<PsiFile>alwaysFalse(), true, false, Collections.<AnalyzerScriptParameter>emptyList());
|
||||
InjectorForTopDownAnalyzerBasic injector = new InjectorForTopDownAnalyzerBasic(
|
||||
project, topDownAnalysisParameters, new ObservableBindingTrace(trace),
|
||||
KotlinBuiltIns.getInstance().getBuiltInsModule());
|
||||
KotlinBuiltIns.getInstance().getBuiltInsModule(), PlatformToKotlinClassMap.EMPTY);
|
||||
|
||||
injector.getTopDownAnalyzer().doProcessStandardLibraryNamespace(outerScope, standardLibraryNamespace, files);
|
||||
}
|
||||
@@ -196,7 +196,8 @@ public class TopDownAnalyzer {
|
||||
false, true, Collections.<AnalyzerScriptParameter>emptyList());
|
||||
|
||||
InjectorForTopDownAnalyzerBasic injector = new InjectorForTopDownAnalyzerBasic(
|
||||
object.getProject(), topDownAnalysisParameters, new ObservableBindingTrace(context.trace), moduleDescriptor);
|
||||
object.getProject(), topDownAnalysisParameters, new ObservableBindingTrace(context.trace),
|
||||
moduleDescriptor, context.expressionTypingServices.getPlatformToKotlinClassMap());
|
||||
|
||||
injector.getTopDownAnalysisContext().setOuterDataFlowInfo(context.dataFlowInfo);
|
||||
|
||||
|
||||
+6
-1
@@ -23,6 +23,7 @@ import com.intellij.psi.tree.IElementType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.JetNodeTypes;
|
||||
import org.jetbrains.jet.lang.PlatformToKotlinClassMap;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.FunctionDescriptorUtil;
|
||||
@@ -75,8 +76,12 @@ import static org.jetbrains.jet.lang.types.expressions.ExpressionTypingUtils.*;
|
||||
|
||||
@SuppressWarnings("SuspiciousMethodCalls")
|
||||
public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
protected BasicExpressionTypingVisitor(@NotNull ExpressionTypingInternals facade) {
|
||||
|
||||
private final PlatformToKotlinClassMap platformToKotlinClassMap;
|
||||
|
||||
protected BasicExpressionTypingVisitor(@NotNull ExpressionTypingInternals facade, @NotNull PlatformToKotlinClassMap platformToKotlinClassMap) {
|
||||
super(facade);
|
||||
this.platformToKotlinClassMap = platformToKotlinClassMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+18
-6
@@ -21,6 +21,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.PlatformToKotlinClassMap;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ScriptDescriptor;
|
||||
@@ -54,8 +55,8 @@ import static org.jetbrains.jet.lang.types.expressions.CoercionStrategy.COERCION
|
||||
|
||||
public class ExpressionTypingServices {
|
||||
|
||||
private final ExpressionTypingFacade expressionTypingFacade = ExpressionTypingVisitorDispatcher.create();
|
||||
|
||||
@NotNull
|
||||
private ExpressionTypingFacade expressionTypingFacade;
|
||||
@NotNull
|
||||
private Project project;
|
||||
@NotNull
|
||||
@@ -66,8 +67,8 @@ public class ExpressionTypingServices {
|
||||
private DescriptorResolver descriptorResolver;
|
||||
@NotNull
|
||||
private TypeResolver typeResolver;
|
||||
|
||||
|
||||
@NotNull
|
||||
private PlatformToKotlinClassMap platformToKotlinClassMap;
|
||||
|
||||
@NotNull
|
||||
public Project getProject() {
|
||||
@@ -119,6 +120,17 @@ public class ExpressionTypingServices {
|
||||
this.typeResolver = typeResolver;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setPlatformToKotlinClassMap(@NotNull PlatformToKotlinClassMap platformToKotlinClassMap) {
|
||||
this.platformToKotlinClassMap = platformToKotlinClassMap;
|
||||
this.expressionTypingFacade = ExpressionTypingVisitorDispatcher.create(platformToKotlinClassMap);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PlatformToKotlinClassMap getPlatformToKotlinClassMap() {
|
||||
return platformToKotlinClassMap;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetType safeGetType(@NotNull JetScope scope, @NotNull JetExpression expression, @NotNull JetType expectedType, @NotNull DataFlowInfo dataFlowInfo, @NotNull BindingTrace trace) {
|
||||
JetType type = getType(scope, expression, expectedType, dataFlowInfo, trace);
|
||||
@@ -247,7 +259,7 @@ public class ExpressionTypingServices {
|
||||
return JetTypeInfo.create(KotlinBuiltIns.getInstance().getUnitType(), context.dataFlowInfo);
|
||||
}
|
||||
|
||||
ExpressionTypingInternals blockLevelVisitor = ExpressionTypingVisitorDispatcher.createForBlock(scope);
|
||||
ExpressionTypingInternals blockLevelVisitor = ExpressionTypingVisitorDispatcher.createForBlock(platformToKotlinClassMap, scope);
|
||||
ExpressionTypingContext newContext = createContext(context, trace, scope, context.dataFlowInfo, NO_EXPECTED_TYPE);
|
||||
|
||||
JetTypeInfo result = JetTypeInfo.create(null, context.dataFlowInfo);
|
||||
@@ -271,7 +283,7 @@ public class ExpressionTypingServices {
|
||||
if (newDataFlowInfo != context.dataFlowInfo) {
|
||||
newContext = newContext.replaceDataFlowInfo(newDataFlowInfo);
|
||||
}
|
||||
blockLevelVisitor = ExpressionTypingVisitorDispatcher.createForBlock(scope);
|
||||
blockLevelVisitor = ExpressionTypingVisitorDispatcher.createForBlock(platformToKotlinClassMap, scope);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
+10
-6
@@ -18,6 +18,7 @@ package org.jetbrains.jet.lang.types.expressions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.PlatformToKotlinClassMap;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
@@ -38,13 +39,16 @@ public class ExpressionTypingVisitorDispatcher extends JetVisitor<JetTypeInfo, E
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ExpressionTypingFacade create() {
|
||||
return new ExpressionTypingVisitorDispatcher(null);
|
||||
public static ExpressionTypingFacade create(@NotNull PlatformToKotlinClassMap platformToKotlinClassMap) {
|
||||
return new ExpressionTypingVisitorDispatcher(platformToKotlinClassMap, null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ExpressionTypingInternals createForBlock(WritableScope writableScope) {
|
||||
return new ExpressionTypingVisitorDispatcher(writableScope);
|
||||
public static ExpressionTypingInternals createForBlock(
|
||||
@NotNull PlatformToKotlinClassMap platformToKotlinClassMap,
|
||||
@NotNull WritableScope writableScope
|
||||
) {
|
||||
return new ExpressionTypingVisitorDispatcher(platformToKotlinClassMap, writableScope);
|
||||
}
|
||||
|
||||
private final BasicExpressionTypingVisitor basic;
|
||||
@@ -53,8 +57,8 @@ public class ExpressionTypingVisitorDispatcher extends JetVisitor<JetTypeInfo, E
|
||||
private final ControlStructureTypingVisitor controlStructures = new ControlStructureTypingVisitor(this);
|
||||
private final PatternMatchingTypingVisitor patterns = new PatternMatchingTypingVisitor(this);
|
||||
|
||||
private ExpressionTypingVisitorDispatcher(WritableScope writableScope) {
|
||||
this.basic = new BasicExpressionTypingVisitor(this);
|
||||
private ExpressionTypingVisitorDispatcher(PlatformToKotlinClassMap platformToKotlinClassMap, WritableScope writableScope) {
|
||||
this.basic = new BasicExpressionTypingVisitor(this, platformToKotlinClassMap);
|
||||
if (writableScope != null) {
|
||||
this.statements = new ExpressionTypingVisitorForStatements(this, writableScope, basic, controlStructures, patterns);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user