using guice to wire TopDownAnalyzer beans
attempt 2
This commit is contained in:
+2
-4
@@ -28,7 +28,6 @@ import com.intellij.psi.util.CachedValuesManager;
|
||||
import com.intellij.psi.util.PsiModificationTracker;
|
||||
import com.intellij.util.Function;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.JetSemanticServices;
|
||||
import org.jetbrains.jet.lang.StandardConfiguration;
|
||||
import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils;
|
||||
@@ -141,15 +140,14 @@ public class AnalyzerFacadeForJVM {
|
||||
public static BindingContext analyzeFilesWithJavaIntegration(Project project, Collection<JetFile> files, Predicate<PsiFile> filesToAnalyzeCompletely,
|
||||
JetControlFlowDataTraceFactory flowDataTraceFactory) {
|
||||
BindingTraceContext bindingTraceContext = new BindingTraceContext();
|
||||
JetSemanticServices semanticServices = JetSemanticServices.createSemanticServices(project);
|
||||
return AnalyzingUtils.analyzeFilesWithGivenTrace(
|
||||
project,
|
||||
JavaBridgeConfiguration.createJavaBridgeConfiguration(project, bindingTraceContext, StandardConfiguration.createStandardConfiguration(project)),
|
||||
files,
|
||||
filesToAnalyzeCompletely,
|
||||
flowDataTraceFactory,
|
||||
bindingTraceContext,
|
||||
semanticServices);
|
||||
bindingTraceContext
|
||||
);
|
||||
}
|
||||
|
||||
public static BindingContext shallowAnalyzeFiles(Collection<JetFile> files) {
|
||||
|
||||
+1
-2
@@ -19,7 +19,6 @@ package org.jetbrains.jet.lang.resolve.java;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.Configuration;
|
||||
import org.jetbrains.jet.lang.JetSemanticServices;
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetImportDirective;
|
||||
@@ -48,7 +47,7 @@ public class JavaBridgeConfiguration implements Configuration {
|
||||
|
||||
private JavaBridgeConfiguration(Project project, BindingTrace trace, Configuration delegateConfiguration) {
|
||||
this.project = project;
|
||||
this.javaSemanticServices = new JavaSemanticServices(project, JetSemanticServices.createSemanticServices(project), trace);
|
||||
this.javaSemanticServices = new JavaSemanticServices(project, trace);
|
||||
this.delegateConfiguration = delegateConfiguration;
|
||||
}
|
||||
|
||||
|
||||
+5
-4
@@ -40,6 +40,7 @@ import org.jetbrains.jet.lang.resolve.java.alt.AltClassFinder;
|
||||
import org.jetbrains.jet.lang.resolve.java.kt.JetClassAnnotation;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.plugin.JetFileType;
|
||||
import org.jetbrains.jet.rt.signature.JetSignatureAdapter;
|
||||
import org.jetbrains.jet.rt.signature.JetSignatureExceptionsAdapter;
|
||||
@@ -542,7 +543,7 @@ public class JavaDescriptorResolver {
|
||||
|
||||
@Override
|
||||
public JetSignatureVisitor visitClassBound() {
|
||||
return new JetTypeJetSignatureReader(semanticServices, semanticServices.getJetSemanticServices().getStandardLibrary(), typeVariableResolver) {
|
||||
return new JetTypeJetSignatureReader(semanticServices, JetStandardLibrary.getInstance(), typeVariableResolver) {
|
||||
@Override
|
||||
protected void done(@NotNull JetType jetType) {
|
||||
if (isJavaLangObject(jetType)) {
|
||||
@@ -555,7 +556,7 @@ public class JavaDescriptorResolver {
|
||||
|
||||
@Override
|
||||
public JetSignatureVisitor visitInterfaceBound() {
|
||||
return new JetTypeJetSignatureReader(semanticServices, semanticServices.getJetSemanticServices().getStandardLibrary(), typeVariableResolver) {
|
||||
return new JetTypeJetSignatureReader(semanticServices, JetStandardLibrary.getInstance(), typeVariableResolver) {
|
||||
@Override
|
||||
protected void done(@NotNull JetType jetType) {
|
||||
upperBounds.add(jetType);
|
||||
@@ -739,7 +740,7 @@ public class JavaDescriptorResolver {
|
||||
|
||||
@Override
|
||||
public JetSignatureVisitor visitSuperclass() {
|
||||
return new JetTypeJetSignatureReader(semanticServices, semanticServices.getJetSemanticServices().getStandardLibrary(), typeVariableResolver) {
|
||||
return new JetTypeJetSignatureReader(semanticServices, JetStandardLibrary.getInstance(), typeVariableResolver) {
|
||||
@Override
|
||||
protected void done(@NotNull JetType jetType) {
|
||||
if (!jetType.equals(JetStandardClasses.getAnyType())) {
|
||||
@@ -971,7 +972,7 @@ public class JavaDescriptorResolver {
|
||||
|
||||
JetType varargElementType;
|
||||
if (psiType instanceof PsiEllipsisType) {
|
||||
varargElementType = semanticServices.getJetSemanticServices().getStandardLibrary().getArrayElementType(outType);
|
||||
varargElementType = JetStandardLibrary.getInstance().getArrayElementType(outType);
|
||||
} else {
|
||||
varargElementType = null;
|
||||
}
|
||||
|
||||
+4
-10
@@ -19,11 +19,11 @@ package org.jetbrains.jet.lang.resolve.java;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.JetSemanticServices;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
@@ -32,13 +32,11 @@ public class JavaSemanticServices {
|
||||
private final JavaTypeTransformer typeTransformer;
|
||||
private final JavaDescriptorResolver descriptorResolver;
|
||||
private final BindingTrace trace;
|
||||
private final JetSemanticServices jetSemanticServices;
|
||||
|
||||
public JavaSemanticServices(Project project, JetSemanticServices jetSemanticServices, BindingTrace trace) {
|
||||
public JavaSemanticServices(Project project, BindingTrace trace) {
|
||||
this.trace = trace;
|
||||
this.descriptorResolver = new JavaDescriptorResolver(project, this);
|
||||
this.typeTransformer = new JavaTypeTransformer(this, jetSemanticServices.getStandardLibrary(), descriptorResolver);
|
||||
this.jetSemanticServices = jetSemanticServices;
|
||||
this.typeTransformer = new JavaTypeTransformer(this, JetStandardLibrary.getInstance(), descriptorResolver);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -56,14 +54,10 @@ public class JavaSemanticServices {
|
||||
return trace;
|
||||
}
|
||||
|
||||
public JetSemanticServices getJetSemanticServices() {
|
||||
return jetSemanticServices;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ClassDescriptor getKotlinClassDescriptor(String qualifiedName) {
|
||||
if (qualifiedName.startsWith("jet.")) {
|
||||
ClassDescriptor r = (ClassDescriptor) jetSemanticServices.getStandardLibrary().getLibraryScope().getClassifier(qualifiedName.substring("jet.".length()));
|
||||
ClassDescriptor r = (ClassDescriptor) JetStandardLibrary.getInstance().getLibraryScope().getClassifier(qualifiedName.substring("jet.".length()));
|
||||
if (r == null) {
|
||||
// TODO: better error
|
||||
//throw new IllegalStateException();
|
||||
|
||||
Reference in New Issue
Block a user