LTDA: Initialize project components with resolve session after injector construction is finished
This commit is contained in:
+63
-56
@@ -18,6 +18,7 @@ package org.jetbrains.jet.cli.jvm.compiler;
|
|||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.collect.Collections2;
|
import com.google.common.collect.Collections2;
|
||||||
|
import com.intellij.openapi.application.ApplicationManager;
|
||||||
import com.intellij.openapi.components.ServiceManager;
|
import com.intellij.openapi.components.ServiceManager;
|
||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
import com.intellij.psi.PsiClass;
|
import com.intellij.psi.PsiClass;
|
||||||
@@ -29,25 +30,21 @@ import com.intellij.util.SmartList;
|
|||||||
import com.intellij.util.containers.ContainerUtil;
|
import com.intellij.util.containers.ContainerUtil;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.annotations.TestOnly;
|
|
||||||
import org.jetbrains.jet.asJava.KotlinLightClassForExplicitDeclaration;
|
import org.jetbrains.jet.asJava.KotlinLightClassForExplicitDeclaration;
|
||||||
import org.jetbrains.jet.asJava.LightClassConstructionContext;
|
import org.jetbrains.jet.asJava.LightClassConstructionContext;
|
||||||
import org.jetbrains.jet.asJava.LightClassGenerationSupport;
|
import org.jetbrains.jet.asJava.LightClassGenerationSupport;
|
||||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.PackageViewDescriptor;
|
import org.jetbrains.jet.lang.descriptors.PackageViewDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.impl.ModuleDescriptorImpl;
|
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
import org.jetbrains.jet.lang.resolve.*;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
|
||||||
import org.jetbrains.jet.lang.resolve.BindingTraceContext;
|
|
||||||
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils;
|
|
||||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||||
import org.jetbrains.jet.lang.resolve.java.TopDownAnalyzerFacadeForJVM;
|
import org.jetbrains.jet.lang.resolve.lazy.KotlinCodeAnalyzer;
|
||||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.DescriptorKindFilter;
|
import org.jetbrains.jet.lang.resolve.scopes.DescriptorKindFilter;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
import org.jetbrains.jet.util.slicedmap.ReadOnlySlice;
|
||||||
import org.jetbrains.jet.util.slicedmap.WritableSlice;
|
import org.jetbrains.jet.util.slicedmap.WritableSlice;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -66,60 +63,40 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* To mitigate this, CliLightClassGenerationSupport hold a trace that is shared between the analyzer and JetLightClasses
|
* To mitigate this, CliLightClassGenerationSupport hold a trace that is shared between the analyzer and JetLightClasses
|
||||||
*/
|
*/
|
||||||
public class CliLightClassGenerationSupport extends LightClassGenerationSupport {
|
public class CliLightClassGenerationSupport extends LightClassGenerationSupport implements CodeAnalyzerInitializer {
|
||||||
|
|
||||||
public static CliLightClassGenerationSupport getInstanceForCli(@NotNull Project project) {
|
public static CliLightClassGenerationSupport getInstanceForCli(@NotNull Project project) {
|
||||||
return ServiceManager.getService(project, CliLightClassGenerationSupport.class);
|
return ServiceManager.getService(project, CliLightClassGenerationSupport.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private BindingTrace trace;
|
private BindingContext bindingContext = null;
|
||||||
private ModuleDescriptorImpl module;
|
private ModuleDescriptor module = null;
|
||||||
|
|
||||||
public CliLightClassGenerationSupport() {
|
public CliLightClassGenerationSupport() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@Override
|
||||||
public BindingTrace getTrace() {
|
public void initialize(@NotNull BindingTrace trace, @NotNull ModuleDescriptor module, @Nullable KotlinCodeAnalyzer analyzer) {
|
||||||
if (trace == null) {
|
this.bindingContext = trace.getBindingContext();
|
||||||
trace = new BindingTraceContextWithoutScopeRecording();
|
|
||||||
}
|
|
||||||
return trace;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public ModuleDescriptorImpl newModule() {
|
|
||||||
assert this.module == null : "module already configured: " + module;
|
|
||||||
module = TopDownAnalyzerFacadeForJVM.createJavaModule("<shared-module-for-cli-light-classes>");
|
|
||||||
module.addDependencyOnModule(module);
|
|
||||||
module.addDependencyOnModule(KotlinBuiltIns.getInstance().getBuiltInsModule());
|
|
||||||
module.seal();
|
|
||||||
return module;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private ModuleDescriptorImpl getModule() {
|
|
||||||
if (module == null) {
|
|
||||||
return newModule();
|
|
||||||
}
|
|
||||||
return module;
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestOnly
|
|
||||||
@Nullable
|
|
||||||
public ModuleDescriptorImpl getLightClassModule() {
|
|
||||||
return module;
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestOnly
|
|
||||||
public void setModule(@NotNull ModuleDescriptorImpl module) {
|
|
||||||
assert this.module == null : "module already configured: " + module;
|
|
||||||
this.module = module;
|
this.module = module;
|
||||||
|
|
||||||
|
if (trace instanceof CliBindingTrace) {
|
||||||
|
((CliBindingTrace) trace).setKotlinCodeAnalyzer(analyzer);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
assert ApplicationManager.getApplication().isUnitTestMode();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestOnly
|
@NotNull
|
||||||
public void newBindingTrace() {
|
private BindingContext getBindingContext() {
|
||||||
trace = null;
|
assert bindingContext != null : "Call initialize() first";
|
||||||
module = null;
|
return bindingContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private ModuleDescriptor getModule() {
|
||||||
|
assert module != null : "Call initialize() first";
|
||||||
|
return module;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -136,13 +113,13 @@ public class CliLightClassGenerationSupport extends LightClassGenerationSupport
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private LightClassConstructionContext getContext() {
|
private LightClassConstructionContext getContext() {
|
||||||
return new LightClassConstructionContext(getTrace().getBindingContext(), getModule());
|
return new LightClassConstructionContext(bindingContext, getModule());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Collection<JetClassOrObject> findClassOrObjectDeclarations(@NotNull FqName fqName, @NotNull GlobalSearchScope searchScope) {
|
public Collection<JetClassOrObject> findClassOrObjectDeclarations(@NotNull FqName fqName, @NotNull GlobalSearchScope searchScope) {
|
||||||
ClassDescriptor classDescriptor = getTrace().get(BindingContext.FQNAME_TO_CLASS_DESCRIPTOR, fqName.toUnsafe());
|
ClassDescriptor classDescriptor = getBindingContext().get(BindingContext.FQNAME_TO_CLASS_DESCRIPTOR, fqName.toUnsafe());
|
||||||
if (classDescriptor != null) {
|
if (classDescriptor != null) {
|
||||||
PsiElement element = DescriptorToSourceUtils.classDescriptorToDeclaration(classDescriptor);
|
PsiElement element = DescriptorToSourceUtils.classDescriptorToDeclaration(classDescriptor);
|
||||||
if (element != null && PsiSearchScopeUtil.isInScope(searchScope, element)) {
|
if (element != null && PsiSearchScopeUtil.isInScope(searchScope, element)) {
|
||||||
@@ -174,7 +151,7 @@ public class CliLightClassGenerationSupport extends LightClassGenerationSupport
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Collection<JetFile> findFilesForPackage(@NotNull FqName fqName, @NotNull final GlobalSearchScope searchScope) {
|
public Collection<JetFile> findFilesForPackage(@NotNull FqName fqName, @NotNull final GlobalSearchScope searchScope) {
|
||||||
Collection<JetFile> files = getTrace().get(BindingContext.PACKAGE_TO_FILES, fqName);
|
Collection<JetFile> files = getBindingContext().get(BindingContext.PACKAGE_TO_FILES, fqName);
|
||||||
if (files != null) {
|
if (files != null) {
|
||||||
return Collections2.filter(files, new Predicate<JetFile>() {
|
return Collections2.filter(files, new Predicate<JetFile>() {
|
||||||
@Override
|
@Override
|
||||||
@@ -240,7 +217,13 @@ public class CliLightClassGenerationSupport extends LightClassGenerationSupport
|
|||||||
return KotlinLightClassForExplicitDeclaration.create(classOrObject.getManager(), classOrObject);
|
return KotlinLightClassForExplicitDeclaration.create(classOrObject.getManager(), classOrObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class BindingTraceContextWithoutScopeRecording extends BindingTraceContext {
|
public static BindingTrace createTrace() {
|
||||||
|
return new CliBindingTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class CliBindingTrace extends BindingTraceContext {
|
||||||
|
private KotlinCodeAnalyzer kotlinCodeAnalyzer;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <K, V> void record(WritableSlice<K, V> slice, K key, V value) {
|
public <K, V> void record(WritableSlice<K, V> slice, K key, V value) {
|
||||||
if (slice == BindingContext.RESOLUTION_SCOPE || slice == BindingContext.TYPE_RESOLUTION_SCOPE) {
|
if (slice == BindingContext.RESOLUTION_SCOPE || slice == BindingContext.TYPE_RESOLUTION_SCOPE) {
|
||||||
@@ -252,7 +235,31 @@ public class CliLightClassGenerationSupport extends LightClassGenerationSupport
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Filtering trace for the CLI compiler: does not save scopes";
|
return CliBindingTrace.class.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKotlinCodeAnalyzer(KotlinCodeAnalyzer kotlinCodeAnalyzer) {
|
||||||
|
this.kotlinCodeAnalyzer = kotlinCodeAnalyzer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <K, V> V get(ReadOnlySlice<K, V> slice, K key) {
|
||||||
|
V value = super.get(slice, key);
|
||||||
|
|
||||||
|
if (value == null) {
|
||||||
|
if (BindingContext.FUNCTION == slice || BindingContext.VARIABLE == slice) {
|
||||||
|
if (key instanceof JetDeclaration) {
|
||||||
|
JetDeclaration jetDeclaration = (JetDeclaration) key;
|
||||||
|
if (!JetPsiUtil.isLocal(jetDeclaration)) {
|
||||||
|
kotlinCodeAnalyzer.resolveToDescriptor(jetDeclaration);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.get(slice, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ import org.jetbrains.jet.config.CompilerConfiguration;
|
|||||||
import org.jetbrains.jet.lang.parsing.JetParserDefinition;
|
import org.jetbrains.jet.lang.parsing.JetParserDefinition;
|
||||||
import org.jetbrains.jet.lang.parsing.JetScriptDefinitionProvider;
|
import org.jetbrains.jet.lang.parsing.JetScriptDefinitionProvider;
|
||||||
import org.jetbrains.jet.lang.psi.JetFile;
|
import org.jetbrains.jet.lang.psi.JetFile;
|
||||||
|
import org.jetbrains.jet.lang.resolve.CodeAnalyzerInitializer;
|
||||||
import org.jetbrains.jet.lang.resolve.DiagnosticsWithSuppression;
|
import org.jetbrains.jet.lang.resolve.DiagnosticsWithSuppression;
|
||||||
import org.jetbrains.jet.lang.resolve.kotlin.KotlinBinaryClassCache;
|
import org.jetbrains.jet.lang.resolve.kotlin.KotlinBinaryClassCache;
|
||||||
import org.jetbrains.jet.lang.resolve.kotlin.VirtualFileFinderFactory;
|
import org.jetbrains.jet.lang.resolve.kotlin.VirtualFileFinderFactory;
|
||||||
@@ -236,6 +237,7 @@ public class JetCoreEnvironment {
|
|||||||
CliLightClassGenerationSupport cliLightClassGenerationSupport = new CliLightClassGenerationSupport();
|
CliLightClassGenerationSupport cliLightClassGenerationSupport = new CliLightClassGenerationSupport();
|
||||||
project.registerService(LightClassGenerationSupport.class, cliLightClassGenerationSupport);
|
project.registerService(LightClassGenerationSupport.class, cliLightClassGenerationSupport);
|
||||||
project.registerService(CliLightClassGenerationSupport.class, cliLightClassGenerationSupport);
|
project.registerService(CliLightClassGenerationSupport.class, cliLightClassGenerationSupport);
|
||||||
|
project.registerService(CodeAnalyzerInitializer.class, cliLightClassGenerationSupport);
|
||||||
Extensions.getArea(project)
|
Extensions.getArea(project)
|
||||||
.getExtensionPoint(PsiElementFinder.EP_NAME)
|
.getExtensionPoint(PsiElementFinder.EP_NAME)
|
||||||
.registerExtension(new JavaElementFinder(project, cliLightClassGenerationSupport));
|
.registerExtension(new JavaElementFinder(project, cliLightClassGenerationSupport));
|
||||||
|
|||||||
+7
-6
@@ -282,23 +282,24 @@ public class KotlinToJVMBytecodeCompiler {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private static AnalysisResult analyze(@NotNull final JetCoreEnvironment environment) {
|
private static AnalysisResult analyze(@NotNull final JetCoreEnvironment environment) {
|
||||||
AnalyzerWithCompilerReport analyzerWithCompilerReport = new AnalyzerWithCompilerReport(
|
MessageCollector collector = environment.getConfiguration().get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY);
|
||||||
environment.getConfiguration().get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY));
|
assert collector != null;
|
||||||
|
|
||||||
|
AnalyzerWithCompilerReport analyzerWithCompilerReport = new AnalyzerWithCompilerReport(collector);
|
||||||
analyzerWithCompilerReport.analyzeAndReport(
|
analyzerWithCompilerReport.analyzeAndReport(
|
||||||
environment.getSourceFiles(), new Function0<AnalysisResult>() {
|
environment.getSourceFiles(), new Function0<AnalysisResult>() {
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public AnalysisResult invoke() {
|
public AnalysisResult invoke() {
|
||||||
CliLightClassGenerationSupport support = CliLightClassGenerationSupport.getInstanceForCli(environment.getProject());
|
BindingTrace sharedTrace = CliLightClassGenerationSupport.createTrace();
|
||||||
BindingTrace sharedTrace = support.getTrace();
|
ModuleDescriptorImpl analyzeModule = TopDownAnalyzerFacadeForJVM.createAnalyzeModule();
|
||||||
ModuleDescriptorImpl sharedModule = support.newModule();
|
|
||||||
|
|
||||||
return TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(
|
return TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(
|
||||||
environment.getProject(),
|
environment.getProject(),
|
||||||
environment.getSourceFiles(),
|
environment.getSourceFiles(),
|
||||||
sharedTrace,
|
sharedTrace,
|
||||||
Predicates.<PsiFile>alwaysTrue(),
|
Predicates.<PsiFile>alwaysTrue(),
|
||||||
sharedModule,
|
analyzeModule,
|
||||||
environment.getConfiguration().get(JVMConfigurationKeys.MODULE_IDS),
|
environment.getConfiguration().get(JVMConfigurationKeys.MODULE_IDS),
|
||||||
environment.getConfiguration().get(JVMConfigurationKeys.INCREMENTAL_CACHE_PROVIDER)
|
environment.getConfiguration().get(JVMConfigurationKeys.INCREMENTAL_CACHE_PROVIDER)
|
||||||
);
|
);
|
||||||
|
|||||||
+10
@@ -33,6 +33,7 @@ import org.jetbrains.jet.lang.resolve.java.structure.impl.JavaPropertyInitialize
|
|||||||
import org.jetbrains.jet.lang.resolve.java.sam.SamConversionResolverImpl;
|
import org.jetbrains.jet.lang.resolve.java.sam.SamConversionResolverImpl;
|
||||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaSourceElementFactoryImpl;
|
import org.jetbrains.jet.lang.resolve.java.resolver.JavaSourceElementFactoryImpl;
|
||||||
import org.jetbrains.jet.lang.resolve.java.lazy.SingleModuleClassResolver;
|
import org.jetbrains.jet.lang.resolve.java.lazy.SingleModuleClassResolver;
|
||||||
|
import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolverPostConstruct;
|
||||||
import org.jetbrains.jet.lang.resolve.kotlin.VirtualFileFinder;
|
import org.jetbrains.jet.lang.resolve.kotlin.VirtualFileFinder;
|
||||||
import org.jetbrains.jet.lang.resolve.java.lazy.LazyJavaPackageFragmentProvider;
|
import org.jetbrains.jet.lang.resolve.java.lazy.LazyJavaPackageFragmentProvider;
|
||||||
import org.jetbrains.jet.lang.resolve.java.lazy.GlobalJavaResolverContext;
|
import org.jetbrains.jet.lang.resolve.java.lazy.GlobalJavaResolverContext;
|
||||||
@@ -64,6 +65,7 @@ public class InjectorForJavaDescriptorResolver {
|
|||||||
private final SamConversionResolverImpl samConversionResolver;
|
private final SamConversionResolverImpl samConversionResolver;
|
||||||
private final JavaSourceElementFactoryImpl javaSourceElementFactory;
|
private final JavaSourceElementFactoryImpl javaSourceElementFactory;
|
||||||
private final SingleModuleClassResolver singleModuleClassResolver;
|
private final SingleModuleClassResolver singleModuleClassResolver;
|
||||||
|
private final JavaDescriptorResolverPostConstruct javaDescriptorResolverPostConstruct;
|
||||||
private final VirtualFileFinder virtualFileFinder;
|
private final VirtualFileFinder virtualFileFinder;
|
||||||
private final LazyJavaPackageFragmentProvider lazyJavaPackageFragmentProvider;
|
private final LazyJavaPackageFragmentProvider lazyJavaPackageFragmentProvider;
|
||||||
private final GlobalJavaResolverContext globalJavaResolverContext;
|
private final GlobalJavaResolverContext globalJavaResolverContext;
|
||||||
@@ -97,10 +99,12 @@ public class InjectorForJavaDescriptorResolver {
|
|||||||
this.lazyJavaPackageFragmentProvider = new LazyJavaPackageFragmentProvider(globalJavaResolverContext, getModule());
|
this.lazyJavaPackageFragmentProvider = new LazyJavaPackageFragmentProvider(globalJavaResolverContext, getModule());
|
||||||
this.javaDescriptorResolver = new JavaDescriptorResolver(lazyJavaPackageFragmentProvider, getModule());
|
this.javaDescriptorResolver = new JavaDescriptorResolver(lazyJavaPackageFragmentProvider, getModule());
|
||||||
this.globalSearchScope = com.intellij.psi.search.GlobalSearchScope.allScope(project);
|
this.globalSearchScope = com.intellij.psi.search.GlobalSearchScope.allScope(project);
|
||||||
|
this.javaDescriptorResolverPostConstruct = new JavaDescriptorResolverPostConstruct();
|
||||||
this.javaClassDataFinder = new JavaClassDataFinder(virtualFileFinder, deserializedDescriptorResolver);
|
this.javaClassDataFinder = new JavaClassDataFinder(virtualFileFinder, deserializedDescriptorResolver);
|
||||||
this.binaryClassAnnotationAndConstantLoader = new BinaryClassAnnotationAndConstantLoaderImpl(getModule(), lockBasedStorageManager, virtualFileFinder, traceBasedErrorReporter);
|
this.binaryClassAnnotationAndConstantLoader = new BinaryClassAnnotationAndConstantLoaderImpl(getModule(), lockBasedStorageManager, virtualFileFinder, traceBasedErrorReporter);
|
||||||
this.deserializationComponentsForJava = new DeserializationComponentsForJava(lockBasedStorageManager, getModule(), javaClassDataFinder, binaryClassAnnotationAndConstantLoader, lazyJavaPackageFragmentProvider);
|
this.deserializationComponentsForJava = new DeserializationComponentsForJava(lockBasedStorageManager, getModule(), javaClassDataFinder, binaryClassAnnotationAndConstantLoader, lazyJavaPackageFragmentProvider);
|
||||||
|
|
||||||
|
this.javaClassFinder.setComponentPostConstruct(javaDescriptorResolverPostConstruct);
|
||||||
this.javaClassFinder.setProject(project);
|
this.javaClassFinder.setProject(project);
|
||||||
this.javaClassFinder.setScope(globalSearchScope);
|
this.javaClassFinder.setScope(globalSearchScope);
|
||||||
|
|
||||||
@@ -117,10 +121,16 @@ public class InjectorForJavaDescriptorResolver {
|
|||||||
|
|
||||||
singleModuleClassResolver.setResolver(javaDescriptorResolver);
|
singleModuleClassResolver.setResolver(javaDescriptorResolver);
|
||||||
|
|
||||||
|
javaDescriptorResolverPostConstruct.setModule(module);
|
||||||
|
javaDescriptorResolverPostConstruct.setProject(project);
|
||||||
|
javaDescriptorResolverPostConstruct.setTrace(bindingTrace);
|
||||||
|
|
||||||
deserializedDescriptorResolver.setComponents(deserializationComponentsForJava);
|
deserializedDescriptorResolver.setComponents(deserializationComponentsForJava);
|
||||||
|
|
||||||
javaClassFinder.initialize();
|
javaClassFinder.initialize();
|
||||||
|
|
||||||
|
javaDescriptorResolverPostConstruct.postCreate();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PreDestroy
|
@PreDestroy
|
||||||
|
|||||||
+1
@@ -37,6 +37,7 @@ public class InjectorForJavaDescriptorResolverUtil {
|
|||||||
module.addDependencyOnModule(KotlinBuiltIns.getInstance().getBuiltInsModule());
|
module.addDependencyOnModule(KotlinBuiltIns.getInstance().getBuiltInsModule());
|
||||||
}
|
}
|
||||||
module.seal();
|
module.seal();
|
||||||
|
|
||||||
return injector;
|
return injector;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import org.jetbrains.jet.lang.resolve.java.sam.SamConversionResolverImpl;
|
|||||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaSourceElementFactoryImpl;
|
import org.jetbrains.jet.lang.resolve.java.resolver.JavaSourceElementFactoryImpl;
|
||||||
import org.jetbrains.jet.lang.resolve.java.JavaFlexibleTypeCapabilitiesProvider;
|
import org.jetbrains.jet.lang.resolve.java.JavaFlexibleTypeCapabilitiesProvider;
|
||||||
import org.jetbrains.jet.context.LazyResolveToken;
|
import org.jetbrains.jet.context.LazyResolveToken;
|
||||||
|
import org.jetbrains.jet.lang.resolve.java.JavaLazyAnalyzerPostConstruct;
|
||||||
import org.jetbrains.jet.lang.resolve.AdditionalCheckerProvider;
|
import org.jetbrains.jet.lang.resolve.AdditionalCheckerProvider;
|
||||||
import org.jetbrains.jet.lang.resolve.AnnotationResolver;
|
import org.jetbrains.jet.lang.resolve.AnnotationResolver;
|
||||||
import org.jetbrains.jet.lang.resolve.calls.CallResolver;
|
import org.jetbrains.jet.lang.resolve.calls.CallResolver;
|
||||||
@@ -98,6 +99,7 @@ public class InjectorForLazyResolveWithJava {
|
|||||||
private final JavaSourceElementFactoryImpl javaSourceElementFactory;
|
private final JavaSourceElementFactoryImpl javaSourceElementFactory;
|
||||||
private final JavaFlexibleTypeCapabilitiesProvider javaFlexibleTypeCapabilitiesProvider;
|
private final JavaFlexibleTypeCapabilitiesProvider javaFlexibleTypeCapabilitiesProvider;
|
||||||
private final LazyResolveToken lazyResolveToken;
|
private final LazyResolveToken lazyResolveToken;
|
||||||
|
private final JavaLazyAnalyzerPostConstruct javaLazyAnalyzerPostConstruct;
|
||||||
private final AdditionalCheckerProvider additionalCheckerProvider;
|
private final AdditionalCheckerProvider additionalCheckerProvider;
|
||||||
private final AnnotationResolver annotationResolver;
|
private final AnnotationResolver annotationResolver;
|
||||||
private final CallResolver callResolver;
|
private final CallResolver callResolver;
|
||||||
@@ -163,6 +165,7 @@ public class InjectorForLazyResolveWithJava {
|
|||||||
this.javaDescriptorResolver = new JavaDescriptorResolver(lazyJavaPackageFragmentProvider, module);
|
this.javaDescriptorResolver = new JavaDescriptorResolver(lazyJavaPackageFragmentProvider, module);
|
||||||
this.javaFlexibleTypeCapabilitiesProvider = new JavaFlexibleTypeCapabilitiesProvider();
|
this.javaFlexibleTypeCapabilitiesProvider = new JavaFlexibleTypeCapabilitiesProvider();
|
||||||
this.lazyResolveToken = new LazyResolveToken();
|
this.lazyResolveToken = new LazyResolveToken();
|
||||||
|
this.javaLazyAnalyzerPostConstruct = new JavaLazyAnalyzerPostConstruct();
|
||||||
this.additionalCheckerProvider = org.jetbrains.jet.lang.resolve.kotlin.JavaDeclarationCheckerProvider.INSTANCE$;
|
this.additionalCheckerProvider = org.jetbrains.jet.lang.resolve.kotlin.JavaDeclarationCheckerProvider.INSTANCE$;
|
||||||
this.annotationResolver = new AnnotationResolver();
|
this.annotationResolver = new AnnotationResolver();
|
||||||
this.callResolver = new CallResolver();
|
this.callResolver = new CallResolver();
|
||||||
@@ -198,6 +201,7 @@ public class InjectorForLazyResolveWithJava {
|
|||||||
this.resolveSession.setScriptBodyResolver(scriptBodyResolver);
|
this.resolveSession.setScriptBodyResolver(scriptBodyResolver);
|
||||||
this.resolveSession.setTypeResolver(typeResolver);
|
this.resolveSession.setTypeResolver(typeResolver);
|
||||||
|
|
||||||
|
javaClassFinder.setComponentPostConstruct(javaLazyAnalyzerPostConstruct);
|
||||||
javaClassFinder.setProject(project);
|
javaClassFinder.setProject(project);
|
||||||
javaClassFinder.setScope(moduleContentScope);
|
javaClassFinder.setScope(moduleContentScope);
|
||||||
|
|
||||||
@@ -212,6 +216,10 @@ public class InjectorForLazyResolveWithJava {
|
|||||||
psiBasedMethodSignatureChecker.setExternalAnnotationResolver(psiBasedExternalAnnotationResolver);
|
psiBasedMethodSignatureChecker.setExternalAnnotationResolver(psiBasedExternalAnnotationResolver);
|
||||||
psiBasedMethodSignatureChecker.setExternalSignatureResolver(traceBasedExternalSignatureResolver);
|
psiBasedMethodSignatureChecker.setExternalSignatureResolver(traceBasedExternalSignatureResolver);
|
||||||
|
|
||||||
|
javaLazyAnalyzerPostConstruct.setCodeAnalyzer(resolveSession);
|
||||||
|
javaLazyAnalyzerPostConstruct.setProject(project);
|
||||||
|
javaLazyAnalyzerPostConstruct.setTrace(bindingTrace);
|
||||||
|
|
||||||
annotationResolver.setCallResolver(callResolver);
|
annotationResolver.setCallResolver(callResolver);
|
||||||
annotationResolver.setStorageManager(storageManager);
|
annotationResolver.setStorageManager(storageManager);
|
||||||
annotationResolver.setTypeResolver(typeResolver);
|
annotationResolver.setTypeResolver(typeResolver);
|
||||||
@@ -270,6 +278,8 @@ public class InjectorForLazyResolveWithJava {
|
|||||||
|
|
||||||
javaClassFinder.initialize();
|
javaClassFinder.initialize();
|
||||||
|
|
||||||
|
javaLazyAnalyzerPostConstruct.postCreate();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PreDestroy
|
@PreDestroy
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import org.jetbrains.jet.lang.resolve.java.structure.impl.JavaPropertyInitialize
|
|||||||
import org.jetbrains.jet.lang.resolve.java.sam.SamConversionResolverImpl;
|
import org.jetbrains.jet.lang.resolve.java.sam.SamConversionResolverImpl;
|
||||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaSourceElementFactoryImpl;
|
import org.jetbrains.jet.lang.resolve.java.resolver.JavaSourceElementFactoryImpl;
|
||||||
import org.jetbrains.jet.lang.resolve.java.lazy.SingleModuleClassResolver;
|
import org.jetbrains.jet.lang.resolve.java.lazy.SingleModuleClassResolver;
|
||||||
|
import org.jetbrains.jet.lang.resolve.java.JavaLazyAnalyzerPostConstruct;
|
||||||
import org.jetbrains.jet.lang.resolve.java.JavaFlexibleTypeCapabilitiesProvider;
|
import org.jetbrains.jet.lang.resolve.java.JavaFlexibleTypeCapabilitiesProvider;
|
||||||
import org.jetbrains.jet.lang.resolve.AdditionalCheckerProvider;
|
import org.jetbrains.jet.lang.resolve.AdditionalCheckerProvider;
|
||||||
import org.jetbrains.jet.lang.resolve.BodyResolver;
|
import org.jetbrains.jet.lang.resolve.BodyResolver;
|
||||||
@@ -108,6 +109,7 @@ public class InjectorForTopDownAnalyzerForJvm {
|
|||||||
private final SamConversionResolverImpl samConversionResolver;
|
private final SamConversionResolverImpl samConversionResolver;
|
||||||
private final JavaSourceElementFactoryImpl javaSourceElementFactory;
|
private final JavaSourceElementFactoryImpl javaSourceElementFactory;
|
||||||
private final SingleModuleClassResolver singleModuleClassResolver;
|
private final SingleModuleClassResolver singleModuleClassResolver;
|
||||||
|
private final JavaLazyAnalyzerPostConstruct javaLazyAnalyzerPostConstruct;
|
||||||
private final JavaFlexibleTypeCapabilitiesProvider javaFlexibleTypeCapabilitiesProvider;
|
private final JavaFlexibleTypeCapabilitiesProvider javaFlexibleTypeCapabilitiesProvider;
|
||||||
private final AdditionalCheckerProvider additionalCheckerProvider;
|
private final AdditionalCheckerProvider additionalCheckerProvider;
|
||||||
private final BodyResolver bodyResolver;
|
private final BodyResolver bodyResolver;
|
||||||
@@ -184,6 +186,7 @@ public class InjectorForTopDownAnalyzerForJvm {
|
|||||||
this.javaClassDataFinder = new JavaClassDataFinder(virtualFileFinder, deserializedDescriptorResolver);
|
this.javaClassDataFinder = new JavaClassDataFinder(virtualFileFinder, deserializedDescriptorResolver);
|
||||||
this.binaryClassAnnotationAndConstantLoader = new BinaryClassAnnotationAndConstantLoaderImpl(module, storageManager, virtualFileFinder, traceBasedErrorReporter);
|
this.binaryClassAnnotationAndConstantLoader = new BinaryClassAnnotationAndConstantLoaderImpl(module, storageManager, virtualFileFinder, traceBasedErrorReporter);
|
||||||
this.deserializationComponentsForJava = new DeserializationComponentsForJava(storageManager, module, javaClassDataFinder, binaryClassAnnotationAndConstantLoader, lazyJavaPackageFragmentProvider);
|
this.deserializationComponentsForJava = new DeserializationComponentsForJava(storageManager, module, javaClassDataFinder, binaryClassAnnotationAndConstantLoader, lazyJavaPackageFragmentProvider);
|
||||||
|
this.javaLazyAnalyzerPostConstruct = new JavaLazyAnalyzerPostConstruct();
|
||||||
this.javaFlexibleTypeCapabilitiesProvider = new JavaFlexibleTypeCapabilitiesProvider();
|
this.javaFlexibleTypeCapabilitiesProvider = new JavaFlexibleTypeCapabilitiesProvider();
|
||||||
this.additionalCheckerProvider = org.jetbrains.jet.lang.resolve.kotlin.JavaDeclarationCheckerProvider.INSTANCE$;
|
this.additionalCheckerProvider = org.jetbrains.jet.lang.resolve.kotlin.JavaDeclarationCheckerProvider.INSTANCE$;
|
||||||
this.bodyResolver = new BodyResolver();
|
this.bodyResolver = new BodyResolver();
|
||||||
@@ -235,6 +238,7 @@ public class InjectorForTopDownAnalyzerForJvm {
|
|||||||
this.resolveSession.setScriptBodyResolver(scriptBodyResolver);
|
this.resolveSession.setScriptBodyResolver(scriptBodyResolver);
|
||||||
this.resolveSession.setTypeResolver(typeResolver);
|
this.resolveSession.setTypeResolver(typeResolver);
|
||||||
|
|
||||||
|
javaClassFinder.setComponentPostConstruct(javaLazyAnalyzerPostConstruct);
|
||||||
javaClassFinder.setProject(project);
|
javaClassFinder.setProject(project);
|
||||||
javaClassFinder.setScope(moduleContentScope);
|
javaClassFinder.setScope(moduleContentScope);
|
||||||
|
|
||||||
@@ -251,6 +255,10 @@ public class InjectorForTopDownAnalyzerForJvm {
|
|||||||
|
|
||||||
singleModuleClassResolver.setResolver(javaDescriptorResolver);
|
singleModuleClassResolver.setResolver(javaDescriptorResolver);
|
||||||
|
|
||||||
|
javaLazyAnalyzerPostConstruct.setCodeAnalyzer(resolveSession);
|
||||||
|
javaLazyAnalyzerPostConstruct.setProject(project);
|
||||||
|
javaLazyAnalyzerPostConstruct.setTrace(bindingTrace);
|
||||||
|
|
||||||
bodyResolver.setAnnotationResolver(annotationResolver);
|
bodyResolver.setAnnotationResolver(annotationResolver);
|
||||||
bodyResolver.setCallResolver(callResolver);
|
bodyResolver.setCallResolver(callResolver);
|
||||||
bodyResolver.setControlFlowAnalyzer(controlFlowAnalyzer);
|
bodyResolver.setControlFlowAnalyzer(controlFlowAnalyzer);
|
||||||
@@ -341,6 +349,8 @@ public class InjectorForTopDownAnalyzerForJvm {
|
|||||||
|
|
||||||
javaClassFinder.initialize();
|
javaClassFinder.initialize();
|
||||||
|
|
||||||
|
javaLazyAnalyzerPostConstruct.postCreate();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PreDestroy
|
@PreDestroy
|
||||||
|
|||||||
+5
@@ -53,6 +53,11 @@ public class JavaClassFinderImpl implements JavaClassFinder {
|
|||||||
this.baseScope = scope;
|
this.baseScope = scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public void setComponentPostConstruct(@NotNull JavaClassFinderPostConstruct finderPostConstruct) {
|
||||||
|
// Only activate post create
|
||||||
|
}
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
javaSearchScope = new DelegatingGlobalSearchScope(baseScope) {
|
javaSearchScope = new DelegatingGlobalSearchScope(baseScope) {
|
||||||
|
|||||||
+60
@@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2014 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.jet.lang.resolve.java
|
||||||
|
|
||||||
|
import com.intellij.openapi.project.Project
|
||||||
|
import org.jetbrains.jet.lang.resolve.lazy.KotlinCodeAnalyzer
|
||||||
|
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor
|
||||||
|
import javax.inject.Inject
|
||||||
|
import javax.annotation.PostConstruct
|
||||||
|
import org.jetbrains.jet.lang.resolve.BindingTrace
|
||||||
|
import org.jetbrains.jet.lang.resolve.CodeAnalyzerInitializer
|
||||||
|
|
||||||
|
public open class JavaClassFinderPostConstruct {
|
||||||
|
PostConstruct public open fun postCreate() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class JavaLazyAnalyzerPostConstruct : JavaClassFinderPostConstruct() {
|
||||||
|
public var project: Project? = null
|
||||||
|
[Inject] set
|
||||||
|
|
||||||
|
public var trace: BindingTrace? = null
|
||||||
|
[Inject] set
|
||||||
|
|
||||||
|
public var codeAnalyzer: KotlinCodeAnalyzer? = null
|
||||||
|
[Inject] set
|
||||||
|
|
||||||
|
[PostConstruct] override fun postCreate() {
|
||||||
|
CodeAnalyzerInitializer.getInstance(project!!).initialize(trace!!, codeAnalyzer!!.getModuleDescriptor(), codeAnalyzer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class JavaDescriptorResolverPostConstruct : JavaClassFinderPostConstruct() {
|
||||||
|
public var project: Project? = null
|
||||||
|
[Inject] set
|
||||||
|
|
||||||
|
public var trace: BindingTrace? = null
|
||||||
|
[Inject] set
|
||||||
|
|
||||||
|
public var module: ModuleDescriptor? = null
|
||||||
|
[Inject] set
|
||||||
|
|
||||||
|
[PostConstruct] override fun postCreate() {
|
||||||
|
CodeAnalyzerInitializer.getInstance(project!!).initialize(trace!!, module!!, null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
+16
-9
@@ -40,6 +40,7 @@ import org.jetbrains.jet.lang.resolve.kotlin.incremental.cache.IncrementalCache;
|
|||||||
import org.jetbrains.jet.lang.resolve.kotlin.incremental.cache.IncrementalCacheProvider;
|
import org.jetbrains.jet.lang.resolve.kotlin.incremental.cache.IncrementalCacheProvider;
|
||||||
import org.jetbrains.jet.lang.resolve.lazy.declarations.FileBasedDeclarationProviderFactory;
|
import org.jetbrains.jet.lang.resolve.lazy.declarations.FileBasedDeclarationProviderFactory;
|
||||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||||
|
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||||
import org.jetbrains.jet.storage.LockBasedStorageManager;
|
import org.jetbrains.jet.storage.LockBasedStorageManager;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -68,11 +69,7 @@ public enum TopDownAnalyzerFacadeForJVM {
|
|||||||
@NotNull TopDownAnalysisParameters topDownAnalysisParameters,
|
@NotNull TopDownAnalysisParameters topDownAnalysisParameters,
|
||||||
@NotNull ModuleDescriptorImpl module
|
@NotNull ModuleDescriptorImpl module
|
||||||
) {
|
) {
|
||||||
GlobalContext globalContext = new GlobalContextImpl(
|
return analyzeFilesWithJavaIntegration(project, files, trace, topDownAnalysisParameters, module, null, null);
|
||||||
(LockBasedStorageManager) topDownAnalysisParameters.getStorageManager(),
|
|
||||||
topDownAnalysisParameters.getExceptionTracker());
|
|
||||||
|
|
||||||
return analyzeFilesWithJavaIntegration(project, files, trace, topDownAnalysisParameters, module, globalContext, null, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -112,7 +109,7 @@ public enum TopDownAnalyzerFacadeForJVM {
|
|||||||
|
|
||||||
return analyzeFilesWithJavaIntegration(
|
return analyzeFilesWithJavaIntegration(
|
||||||
project, files, trace, topDownAnalysisParameters, module,
|
project, files, trace, topDownAnalysisParameters, module,
|
||||||
globalContext, moduleIds, incrementalCacheProvider);
|
moduleIds, incrementalCacheProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -122,7 +119,6 @@ public enum TopDownAnalyzerFacadeForJVM {
|
|||||||
BindingTrace trace,
|
BindingTrace trace,
|
||||||
TopDownAnalysisParameters topDownAnalysisParameters,
|
TopDownAnalysisParameters topDownAnalysisParameters,
|
||||||
ModuleDescriptorImpl module,
|
ModuleDescriptorImpl module,
|
||||||
GlobalContext globalContext,
|
|
||||||
@Nullable List<String> moduleIds,
|
@Nullable List<String> moduleIds,
|
||||||
@Nullable IncrementalCacheProvider incrementalCacheProvider
|
@Nullable IncrementalCacheProvider incrementalCacheProvider
|
||||||
) {
|
) {
|
||||||
@@ -131,7 +127,7 @@ public enum TopDownAnalyzerFacadeForJVM {
|
|||||||
|
|
||||||
InjectorForTopDownAnalyzerForJvm injector = new InjectorForTopDownAnalyzerForJvm(
|
InjectorForTopDownAnalyzerForJvm injector = new InjectorForTopDownAnalyzerForJvm(
|
||||||
project,
|
project,
|
||||||
globalContext,
|
topDownAnalysisParameters,
|
||||||
trace,
|
trace,
|
||||||
module,
|
module,
|
||||||
GlobalSearchScope.allScope(project),
|
GlobalSearchScope.allScope(project),
|
||||||
@@ -166,6 +162,17 @@ public enum TopDownAnalyzerFacadeForJVM {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static ModuleDescriptorImpl createJavaModule(@NotNull String name) {
|
public static ModuleDescriptorImpl createJavaModule(@NotNull String name) {
|
||||||
return new ModuleDescriptorImpl(Name.special(name), DEFAULT_IMPORTS, JavaToKotlinClassMap.getInstance());
|
return new ModuleDescriptorImpl(Name.special(name),
|
||||||
|
DEFAULT_IMPORTS,
|
||||||
|
JavaToKotlinClassMap.getInstance());
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static ModuleDescriptorImpl createAnalyzeModule() {
|
||||||
|
ModuleDescriptorImpl module = createJavaModule("<shared-module>");
|
||||||
|
module.addDependencyOnModule(module);
|
||||||
|
module.addDependencyOnModule(KotlinBuiltIns.getInstance().getBuiltInsModule());
|
||||||
|
module.seal();
|
||||||
|
return module;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2014 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.jet.lang.resolve
|
||||||
|
|
||||||
|
import org.jetbrains.jet.lang.resolve.lazy.KotlinCodeAnalyzer
|
||||||
|
import kotlin.platform.platformStatic
|
||||||
|
import com.intellij.openapi.project.Project
|
||||||
|
import com.intellij.openapi.components.ServiceManager
|
||||||
|
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor
|
||||||
|
import javax.annotation.PostConstruct
|
||||||
|
|
||||||
|
public trait CodeAnalyzerInitializer {
|
||||||
|
public fun initialize(trace: BindingTrace, module: ModuleDescriptor, codeAnalyzer: KotlinCodeAnalyzer?)
|
||||||
|
|
||||||
|
class object {
|
||||||
|
public fun getInstance(project: Project): CodeAnalyzerInitializer =
|
||||||
|
ServiceManager.getService<CodeAnalyzerInitializer>(project, javaClass<CodeAnalyzerInitializer>())!!
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DummyCodeAnalyzerInitializer: CodeAnalyzerInitializer {
|
||||||
|
public override fun initialize(trace: BindingTrace, module: ModuleDescriptor, codeAnalyzer: KotlinCodeAnalyzer?) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,8 +24,6 @@ import com.intellij.psi.util.PsiTreeUtil;
|
|||||||
import kotlin.KotlinPackage;
|
import kotlin.KotlinPackage;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.context.GlobalContextImpl;
|
|
||||||
import org.jetbrains.jet.di.InjectorForLazyResolve;
|
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.*;
|
||||||
import org.jetbrains.jet.lang.descriptors.impl.CompositePackageFragmentProvider;
|
import org.jetbrains.jet.lang.descriptors.impl.CompositePackageFragmentProvider;
|
||||||
import org.jetbrains.jet.lang.descriptors.impl.ModuleDescriptorImpl;
|
import org.jetbrains.jet.lang.descriptors.impl.ModuleDescriptorImpl;
|
||||||
@@ -33,11 +31,8 @@ import org.jetbrains.jet.lang.psi.*;
|
|||||||
import org.jetbrains.jet.lang.resolve.calls.CallsPackage;
|
import org.jetbrains.jet.lang.resolve.calls.CallsPackage;
|
||||||
import org.jetbrains.jet.lang.resolve.lazy.KotlinCodeAnalyzer;
|
import org.jetbrains.jet.lang.resolve.lazy.KotlinCodeAnalyzer;
|
||||||
import org.jetbrains.jet.lang.resolve.lazy.LazyImportScope;
|
import org.jetbrains.jet.lang.resolve.lazy.LazyImportScope;
|
||||||
import org.jetbrains.jet.lang.resolve.lazy.ResolveSession;
|
|
||||||
import org.jetbrains.jet.lang.resolve.lazy.declarations.FileBasedDeclarationProviderFactory;
|
|
||||||
import org.jetbrains.jet.lang.resolve.lazy.descriptors.LazyClassDescriptor;
|
import org.jetbrains.jet.lang.resolve.lazy.descriptors.LazyClassDescriptor;
|
||||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||||
import org.jetbrains.jet.storage.LockBasedStorageManager;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|||||||
@@ -416,11 +416,6 @@ public class JetTestUtils {
|
|||||||
return configuration;
|
return configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void newTrace(@NotNull JetCoreEnvironment environment) {
|
|
||||||
// let the next analysis use another trace
|
|
||||||
CliLightClassGenerationSupport.getInstanceForCli(environment.getProject()).newBindingTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void resolveAllKotlinFiles(JetCoreEnvironment environment) throws IOException {
|
public static void resolveAllKotlinFiles(JetCoreEnvironment environment) throws IOException {
|
||||||
List<String> paths = environment.getConfiguration().get(CommonConfigurationKeys.SOURCE_ROOTS_KEY);
|
List<String> paths = environment.getConfiguration().get(CommonConfigurationKeys.SOURCE_ROOTS_KEY);
|
||||||
if (paths == null) return;
|
if (paths == null) return;
|
||||||
|
|||||||
@@ -32,8 +32,6 @@ import org.jetbrains.jet.cli.jvm.compiler.CliLightClassGenerationSupport;
|
|||||||
import org.jetbrains.jet.context.GlobalContext;
|
import org.jetbrains.jet.context.GlobalContext;
|
||||||
import org.jetbrains.jet.context.SimpleGlobalContext;
|
import org.jetbrains.jet.context.SimpleGlobalContext;
|
||||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.PackageFragmentDescriptor;
|
|
||||||
import org.jetbrains.jet.lang.descriptors.PackageFragmentProvider;
|
|
||||||
import org.jetbrains.jet.lang.descriptors.PackageViewDescriptor;
|
import org.jetbrains.jet.lang.descriptors.PackageViewDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.impl.ModuleDescriptorImpl;
|
import org.jetbrains.jet.lang.descriptors.impl.ModuleDescriptorImpl;
|
||||||
import org.jetbrains.jet.lang.diagnostics.*;
|
import org.jetbrains.jet.lang.diagnostics.*;
|
||||||
@@ -86,9 +84,6 @@ public abstract class AbstractJetDiagnosticsTest extends BaseDiagnosticsTest {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
CliLightClassGenerationSupport support = CliLightClassGenerationSupport.getInstanceForCli(getProject());
|
|
||||||
BindingTrace supportTrace = support.getTrace();
|
|
||||||
|
|
||||||
List<JetFile> allJetFiles = new ArrayList<JetFile>();
|
List<JetFile> allJetFiles = new ArrayList<JetFile>();
|
||||||
Map<TestModule, ModuleDescriptorImpl> modules = createModules(groupedByModule);
|
Map<TestModule, ModuleDescriptorImpl> modules = createModules(groupedByModule);
|
||||||
Map<TestModule, BindingContext> moduleBindings = new HashMap<TestModule, BindingContext>();
|
Map<TestModule, BindingContext> moduleBindings = new HashMap<TestModule, BindingContext>();
|
||||||
@@ -103,19 +98,9 @@ public abstract class AbstractJetDiagnosticsTest extends BaseDiagnosticsTest {
|
|||||||
allJetFiles.addAll(jetFiles);
|
allJetFiles.addAll(jetFiles);
|
||||||
|
|
||||||
ModuleDescriptorImpl module = modules.get(testModule);
|
ModuleDescriptorImpl module = modules.get(testModule);
|
||||||
BindingTrace moduleTrace = groupedByModule.size() > 1
|
BindingTrace moduleTrace = CliLightClassGenerationSupport.createTrace();
|
||||||
? new DelegatingBindingTrace(supportTrace.getBindingContext(), "Trace for module " + module)
|
|
||||||
: supportTrace;
|
|
||||||
moduleBindings.put(testModule, moduleTrace.getBindingContext());
|
|
||||||
|
|
||||||
if (module == null) {
|
moduleBindings.put(testModule, moduleTrace.getBindingContext());
|
||||||
module = support.newModule();
|
|
||||||
modules.put(entry.getKey(), module);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
module.addDependencyOnModule(KotlinBuiltIns.getInstance().getBuiltInsModule());
|
|
||||||
module.seal();
|
|
||||||
}
|
|
||||||
|
|
||||||
ExceptionTracker tracker = new ExceptionTracker();
|
ExceptionTracker tracker = new ExceptionTracker();
|
||||||
GlobalContext context = new SimpleGlobalContext(
|
GlobalContext context = new SimpleGlobalContext(
|
||||||
@@ -149,7 +134,7 @@ public abstract class AbstractJetDiagnosticsTest extends BaseDiagnosticsTest {
|
|||||||
Throwable exceptionFromDescriptorValidation = null;
|
Throwable exceptionFromDescriptorValidation = null;
|
||||||
try {
|
try {
|
||||||
File expectedFile = new File(FileUtil.getNameWithoutExtension(testDataFile.getAbsolutePath()) + ".txt");
|
File expectedFile = new File(FileUtil.getNameWithoutExtension(testDataFile.getAbsolutePath()) + ".txt");
|
||||||
validateAndCompareDescriptorWithFile(expectedFile, testFiles, support, modules);
|
validateAndCompareDescriptorWithFile(expectedFile, testFiles, modules);
|
||||||
}
|
}
|
||||||
catch (Throwable e) {
|
catch (Throwable e) {
|
||||||
exceptionFromDescriptorValidation = e;
|
exceptionFromDescriptorValidation = e;
|
||||||
@@ -167,8 +152,6 @@ public abstract class AbstractJetDiagnosticsTest extends BaseDiagnosticsTest {
|
|||||||
|
|
||||||
assertTrue("Diagnostics mismatch. See the output above", ok);
|
assertTrue("Diagnostics mismatch. See the output above", ok);
|
||||||
|
|
||||||
checkAllResolvedCallsAreCompleted(allJetFiles, supportTrace.getBindingContext());
|
|
||||||
|
|
||||||
// now we throw a previously found error, if any
|
// now we throw a previously found error, if any
|
||||||
if (exceptionFromDescriptorValidation != null) {
|
if (exceptionFromDescriptorValidation != null) {
|
||||||
throw UtilsPackage.rethrow(exceptionFromDescriptorValidation);
|
throw UtilsPackage.rethrow(exceptionFromDescriptorValidation);
|
||||||
@@ -246,28 +229,8 @@ public abstract class AbstractJetDiagnosticsTest extends BaseDiagnosticsTest {
|
|||||||
private void validateAndCompareDescriptorWithFile(
|
private void validateAndCompareDescriptorWithFile(
|
||||||
File expectedFile,
|
File expectedFile,
|
||||||
List<TestFile> testFiles,
|
List<TestFile> testFiles,
|
||||||
CliLightClassGenerationSupport support,
|
|
||||||
Map<TestModule, ModuleDescriptorImpl> modules
|
Map<TestModule, ModuleDescriptorImpl> modules
|
||||||
) {
|
) {
|
||||||
ModuleDescriptorImpl lightClassModule = support.getLightClassModule();
|
|
||||||
if (lightClassModule == null) {
|
|
||||||
ModuleDescriptorImpl cliModule = support.newModule();
|
|
||||||
cliModule.initialize(new PackageFragmentProvider() {
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public List<PackageFragmentDescriptor> getPackageFragments(@NotNull FqName fqName) {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public Collection<FqName> getSubPackagesOf(
|
|
||||||
@NotNull FqName fqName, @NotNull Function1<? super Name, ? extends Boolean> nameFilter) {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
RecursiveDescriptorComparator comparator = new RecursiveDescriptorComparator(createdAffectedPackagesConfiguration(testFiles));
|
RecursiveDescriptorComparator comparator = new RecursiveDescriptorComparator(createdAffectedPackagesConfiguration(testFiles));
|
||||||
|
|
||||||
boolean isMultiModuleTest = modules.size() != 1;
|
boolean isMultiModuleTest = modules.size() != 1;
|
||||||
@@ -275,13 +238,13 @@ public abstract class AbstractJetDiagnosticsTest extends BaseDiagnosticsTest {
|
|||||||
|
|
||||||
for (TestModule module : KotlinPackage.sort(modules.keySet())) {
|
for (TestModule module : KotlinPackage.sort(modules.keySet())) {
|
||||||
ModuleDescriptorImpl moduleDescriptor = modules.get(module);
|
ModuleDescriptorImpl moduleDescriptor = modules.get(module);
|
||||||
|
DeclarationDescriptor aPackage = moduleDescriptor.getPackage(FqName.ROOT);
|
||||||
|
assertNotNull(aPackage);
|
||||||
|
|
||||||
if (isMultiModuleTest) {
|
if (isMultiModuleTest) {
|
||||||
rootPackageText.append(String.format("// -- Module: %s --\n", moduleDescriptor.getName()));
|
rootPackageText.append(String.format("// -- Module: %s --\n", moduleDescriptor.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
DeclarationDescriptor aPackage = moduleDescriptor.getPackage(FqName.ROOT);
|
|
||||||
assertNotNull(aPackage);
|
|
||||||
|
|
||||||
String actualSerialized = comparator.serializeRecursively(aPackage);
|
String actualSerialized = comparator.serializeRecursively(aPackage);
|
||||||
rootPackageText.append(actualSerialized);
|
rootPackageText.append(actualSerialized);
|
||||||
|
|
||||||
@@ -319,8 +282,11 @@ public abstract class AbstractJetDiagnosticsTest extends BaseDiagnosticsTest {
|
|||||||
Map<TestModule, ModuleDescriptorImpl> modules = new HashMap<TestModule, ModuleDescriptorImpl>();
|
Map<TestModule, ModuleDescriptorImpl> modules = new HashMap<TestModule, ModuleDescriptorImpl>();
|
||||||
|
|
||||||
for (TestModule testModule : groupedByModule.keySet()) {
|
for (TestModule testModule : groupedByModule.keySet()) {
|
||||||
if (testModule == null) continue;
|
ModuleDescriptorImpl module =
|
||||||
ModuleDescriptorImpl module = createModule(testModule);
|
testModule == null ?
|
||||||
|
TopDownAnalyzerFacadeForJVM.createAnalyzeModule() :
|
||||||
|
createModule(testModule);
|
||||||
|
|
||||||
modules.put(testModule, module);
|
modules.put(testModule, module);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -332,7 +298,11 @@ public abstract class AbstractJetDiagnosticsTest extends BaseDiagnosticsTest {
|
|||||||
for (TestModule dependency : testModule.getDependencies()) {
|
for (TestModule dependency : testModule.getDependencies()) {
|
||||||
module.addDependencyOnModule(modules.get(dependency));
|
module.addDependencyOnModule(modules.get(dependency));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.addDependencyOnModule(KotlinBuiltIns.getInstance().getBuiltInsModule());
|
||||||
|
module.seal();
|
||||||
}
|
}
|
||||||
|
|
||||||
return modules;
|
return modules;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -145,10 +145,8 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
|
|||||||
configuration.add(JVMConfigurationKeys.CLASSPATH_KEY, new File("compiler/tests")); // for @ExpectLoadError annotation
|
configuration.add(JVMConfigurationKeys.CLASSPATH_KEY, new File("compiler/tests")); // for @ExpectLoadError annotation
|
||||||
JetCoreEnvironment environment = JetCoreEnvironment.createForTests(getTestRootDisposable(), configuration);
|
JetCoreEnvironment environment = JetCoreEnvironment.createForTests(getTestRootDisposable(), configuration);
|
||||||
|
|
||||||
// we need the same binding trace for resolve from Java and Kotlin
|
BindingTrace trace = CliLightClassGenerationSupport.createTrace();
|
||||||
CliLightClassGenerationSupport support = CliLightClassGenerationSupport.getInstanceForCli(environment.getProject());
|
ModuleDescriptorImpl module = TopDownAnalyzerFacadeForJVM.createAnalyzeModule();
|
||||||
BindingTrace trace = support.getTrace();
|
|
||||||
ModuleDescriptorImpl module = support.newModule();
|
|
||||||
|
|
||||||
TopDownAnalysisParameters parameters = TopDownAnalysisParameters.create(
|
TopDownAnalysisParameters parameters = TopDownAnalysisParameters.create(
|
||||||
new LockBasedStorageManager(),
|
new LockBasedStorageManager(),
|
||||||
@@ -163,8 +161,7 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
|
|||||||
environment.getSourceFiles(),
|
environment.getSourceFiles(),
|
||||||
trace,
|
trace,
|
||||||
parameters,
|
parameters,
|
||||||
module
|
module);
|
||||||
);
|
|
||||||
|
|
||||||
PackageViewDescriptor packageView = module.getPackage(TEST_PACKAGE_FQNAME);
|
PackageViewDescriptor packageView = module.getPackage(TEST_PACKAGE_FQNAME);
|
||||||
assert packageView != null : "Test package not found";
|
assert packageView != null : "Test package not found";
|
||||||
|
|||||||
@@ -95,7 +95,6 @@ public final class LoadDescriptorUtil {
|
|||||||
InjectorForJavaDescriptorResolverUtil.create(jetCoreEnvironment.getProject(), trace, true);
|
InjectorForJavaDescriptorResolverUtil.create(jetCoreEnvironment.getProject(), trace, true);
|
||||||
ModuleDescriptorImpl module = injector.getModule();
|
ModuleDescriptorImpl module = injector.getModule();
|
||||||
|
|
||||||
CliLightClassGenerationSupport.getInstanceForCli(jetCoreEnvironment.getProject()).setModule(module);
|
|
||||||
PackageViewDescriptor packageView = module.getPackage(TEST_PACKAGE_FQNAME);
|
PackageViewDescriptor packageView = module.getPackage(TEST_PACKAGE_FQNAME);
|
||||||
assert packageView != null;
|
assert packageView != null;
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import org.jetbrains.jet.cli.jvm.compiler.CliLightClassGenerationSupport;
|
|||||||
import org.jetbrains.jet.lang.descriptors.impl.ModuleDescriptorImpl;
|
import org.jetbrains.jet.lang.descriptors.impl.ModuleDescriptorImpl;
|
||||||
import org.jetbrains.jet.lang.psi.JetFile;
|
import org.jetbrains.jet.lang.psi.JetFile;
|
||||||
import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
|
import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
|
||||||
|
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingTraceContext;
|
import org.jetbrains.jet.lang.resolve.BindingTraceContext;
|
||||||
import org.jetbrains.jet.lang.resolve.java.TopDownAnalyzerFacadeForJVM;
|
import org.jetbrains.jet.lang.resolve.java.TopDownAnalyzerFacadeForJVM;
|
||||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||||
@@ -74,17 +75,15 @@ public class JvmResolveUtil {
|
|||||||
@NotNull Collection<JetFile> files,
|
@NotNull Collection<JetFile> files,
|
||||||
@NotNull Predicate<PsiFile> filesToAnalyzeCompletely
|
@NotNull Predicate<PsiFile> filesToAnalyzeCompletely
|
||||||
) {
|
) {
|
||||||
BindingTraceContext bindingTraceContext = new BindingTraceContext();
|
|
||||||
|
|
||||||
ModuleDescriptorImpl module = TopDownAnalyzerFacadeForJVM.createJavaModule("<module>");
|
ModuleDescriptorImpl module = TopDownAnalyzerFacadeForJVM.createJavaModule("<module>");
|
||||||
module.addDependencyOnModule(module);
|
module.addDependencyOnModule(module);
|
||||||
module.addDependencyOnModule(KotlinBuiltIns.getInstance().getBuiltInsModule());
|
module.addDependencyOnModule(KotlinBuiltIns.getInstance().getBuiltInsModule());
|
||||||
module.seal();
|
module.seal();
|
||||||
|
|
||||||
CliLightClassGenerationSupport lightClassGenerationSupport = CliLightClassGenerationSupport.getInstanceForCli(project);
|
CliLightClassGenerationSupport lightClassGenerationSupport = CliLightClassGenerationSupport.getInstanceForCli(project);
|
||||||
if (lightClassGenerationSupport != null) {
|
BindingTrace trace = lightClassGenerationSupport != null ? CliLightClassGenerationSupport.createTrace() : new BindingTraceContext();
|
||||||
lightClassGenerationSupport.setModule(module);
|
|
||||||
}
|
return TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(
|
||||||
return TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(project, files, bindingTraceContext, filesToAnalyzeCompletely,
|
project, files, trace, filesToAnalyzeCompletely, module, null, null);
|
||||||
module, null, null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,10 +18,8 @@ package org.jetbrains.jet.lang.resolve.lazy;
|
|||||||
|
|
||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.intellij.openapi.project.Project;
|
|
||||||
import com.intellij.psi.PsiFile;
|
import com.intellij.psi.PsiFile;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.JetTestUtils;
|
|
||||||
import org.jetbrains.jet.cli.jvm.compiler.CliLightClassGenerationSupport;
|
import org.jetbrains.jet.cli.jvm.compiler.CliLightClassGenerationSupport;
|
||||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||||
import org.jetbrains.jet.context.ContextPackage;
|
import org.jetbrains.jet.context.ContextPackage;
|
||||||
@@ -49,22 +47,19 @@ public class LazyResolveTestUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static ModuleDescriptor doResolve(List<JetFile> files, JetCoreEnvironment environment) {
|
private static ModuleDescriptor doResolve(List<JetFile> files, JetCoreEnvironment environment) {
|
||||||
JetTestUtils.newTrace(environment);
|
|
||||||
|
|
||||||
GlobalContextImpl globalContext = ContextPackage.GlobalContext();
|
GlobalContextImpl globalContext = ContextPackage.GlobalContext();
|
||||||
TopDownAnalysisParameters params = TopDownAnalysisParameters.create(
|
TopDownAnalysisParameters params = TopDownAnalysisParameters.create(
|
||||||
globalContext.getStorageManager(),
|
globalContext.getStorageManager(),
|
||||||
globalContext.getExceptionTracker(),
|
globalContext.getExceptionTracker(),
|
||||||
Predicates.<PsiFile>alwaysTrue(),
|
Predicates.<PsiFile>alwaysTrue(),
|
||||||
false, false);
|
false, false);
|
||||||
CliLightClassGenerationSupport support = CliLightClassGenerationSupport.getInstanceForCli(environment.getProject());
|
BindingTrace trace = CliLightClassGenerationSupport.createTrace();
|
||||||
BindingTrace sharedTrace = support.getTrace();
|
ModuleDescriptorImpl sharedModule = TopDownAnalyzerFacadeForJVM.createAnalyzeModule();
|
||||||
ModuleDescriptorImpl sharedModule = support.newModule();
|
|
||||||
|
|
||||||
TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(
|
TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(
|
||||||
environment.getProject(),
|
environment.getProject(),
|
||||||
files,
|
files,
|
||||||
sharedTrace,
|
trace,
|
||||||
params, sharedModule);
|
params, sharedModule);
|
||||||
|
|
||||||
return sharedModule;
|
return sharedModule;
|
||||||
@@ -76,14 +71,7 @@ public class LazyResolveTestUtil {
|
|||||||
@NotNull JetCoreEnvironment environment,
|
@NotNull JetCoreEnvironment environment,
|
||||||
boolean addBuiltIns
|
boolean addBuiltIns
|
||||||
) {
|
) {
|
||||||
JetTestUtils.newTrace(environment);
|
return createResolveSessionForFiles(environment.getProject(), files, addBuiltIns);
|
||||||
|
|
||||||
Project project = environment.getProject();
|
|
||||||
CliLightClassGenerationSupport support = CliLightClassGenerationSupport.getInstanceForCli(project);
|
|
||||||
ResolveSession lazyResolveSession = createResolveSessionForFiles(project, files, addBuiltIns);
|
|
||||||
support.setModule((ModuleDescriptorImpl) lazyResolveSession.getModuleDescriptor());
|
|
||||||
|
|
||||||
return lazyResolveSession;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ModuleDescriptor resolveLazily(List<JetFile> files, JetCoreEnvironment environment) {
|
public static ModuleDescriptor resolveLazily(List<JetFile> files, JetCoreEnvironment environment) {
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ import org.jetbrains.jet.lang.resolve.kotlin.JavaDeclarationCheckerProvider
|
|||||||
import org.jetbrains.jet.lang.resolve.lazy.KotlinCodeAnalyzer
|
import org.jetbrains.jet.lang.resolve.lazy.KotlinCodeAnalyzer
|
||||||
import org.jetbrains.jet.lang.resolve.java.JavaFlexibleTypeCapabilitiesProvider
|
import org.jetbrains.jet.lang.resolve.java.JavaFlexibleTypeCapabilitiesProvider
|
||||||
import org.jetbrains.jet.context.LazyResolveToken
|
import org.jetbrains.jet.context.LazyResolveToken
|
||||||
|
import org.jetbrains.jet.lang.resolve.java.JavaLazyAnalyzerPostConstruct
|
||||||
|
import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolverPostConstruct
|
||||||
|
|
||||||
// NOTE: After making changes, you need to re-generate the injectors.
|
// NOTE: After making changes, you need to re-generate the injectors.
|
||||||
// To do that, you can run main in this file.
|
// To do that, you can run main in this file.
|
||||||
@@ -172,8 +174,9 @@ private fun generatorForTopDownAnalyzerForJvm() =
|
|||||||
javaClass<JavaPropertyInitializerEvaluatorImpl>(),
|
javaClass<JavaPropertyInitializerEvaluatorImpl>(),
|
||||||
javaClass<SamConversionResolverImpl>(),
|
javaClass<SamConversionResolverImpl>(),
|
||||||
javaClass<JavaSourceElementFactoryImpl>(),
|
javaClass<JavaSourceElementFactoryImpl>(),
|
||||||
javaClass<SingleModuleClassResolver>(),
|
|
||||||
javaClass<MutablePackageFragmentProvider>(),
|
javaClass<MutablePackageFragmentProvider>(),
|
||||||
|
javaClass<SingleModuleClassResolver>(),
|
||||||
|
javaClass<JavaLazyAnalyzerPostConstruct>(),
|
||||||
javaClass<JavaFlexibleTypeCapabilitiesProvider>()
|
javaClass<JavaFlexibleTypeCapabilitiesProvider>()
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -209,7 +212,8 @@ private fun generatorForJavaDescriptorResolver() =
|
|||||||
javaClass<JavaPropertyInitializerEvaluatorImpl>(),
|
javaClass<JavaPropertyInitializerEvaluatorImpl>(),
|
||||||
javaClass<SamConversionResolverImpl>(),
|
javaClass<SamConversionResolverImpl>(),
|
||||||
javaClass<JavaSourceElementFactoryImpl>(),
|
javaClass<JavaSourceElementFactoryImpl>(),
|
||||||
javaClass<SingleModuleClassResolver>()
|
javaClass<SingleModuleClassResolver>(),
|
||||||
|
javaClass<JavaDescriptorResolverPostConstruct>()
|
||||||
)
|
)
|
||||||
field(javaClass<VirtualFileFinder>(),
|
field(javaClass<VirtualFileFinder>(),
|
||||||
init = GivenExpression(javaClass<VirtualFileFinder>().getName() + ".SERVICE.getInstance(project)"))
|
init = GivenExpression(javaClass<VirtualFileFinder>().getName() + ".SERVICE.getInstance(project)"))
|
||||||
@@ -247,7 +251,8 @@ private fun generatorForLazyResolveWithJava() =
|
|||||||
javaClass<SamConversionResolverImpl>(),
|
javaClass<SamConversionResolverImpl>(),
|
||||||
javaClass<JavaSourceElementFactoryImpl>(),
|
javaClass<JavaSourceElementFactoryImpl>(),
|
||||||
javaClass<JavaFlexibleTypeCapabilitiesProvider>(),
|
javaClass<JavaFlexibleTypeCapabilitiesProvider>(),
|
||||||
javaClass<LazyResolveToken>()
|
javaClass<LazyResolveToken>(),
|
||||||
|
javaClass<JavaLazyAnalyzerPostConstruct>()
|
||||||
)
|
)
|
||||||
field(javaClass<AdditionalCheckerProvider>(),
|
field(javaClass<AdditionalCheckerProvider>(),
|
||||||
init = GivenExpression(javaClass<JavaDeclarationCheckerProvider>().getName() + ".INSTANCE$"))
|
init = GivenExpression(javaClass<JavaDeclarationCheckerProvider>().getName() + ".INSTANCE$"))
|
||||||
|
|||||||
@@ -247,8 +247,6 @@ private object KotlinResolveDataProvider {
|
|||||||
TargetPlatformDetector.getPlatform(analyzableElement.getContainingJetFile()).getAdditionalCheckerProvider()
|
TargetPlatformDetector.getPlatform(analyzableElement.getContainingJetFile()).getAdditionalCheckerProvider()
|
||||||
).getLazyTopDownAnalyzer()!!
|
).getLazyTopDownAnalyzer()!!
|
||||||
|
|
||||||
lazyTopDownAnalyzer.setKotlinCodeAnalyzer(resolveSession);
|
|
||||||
|
|
||||||
lazyTopDownAnalyzer.analyzeDeclarations(
|
lazyTopDownAnalyzer.analyzeDeclarations(
|
||||||
TopDownAnalysisParameters.createForLazy(
|
TopDownAnalysisParameters.createForLazy(
|
||||||
resolveSession.getStorageManager(),
|
resolveSession.getStorageManager(),
|
||||||
|
|||||||
@@ -158,6 +158,9 @@
|
|||||||
<projectService serviceInterface="org.jetbrains.jet.asJava.LightClassGenerationSupport"
|
<projectService serviceInterface="org.jetbrains.jet.asJava.LightClassGenerationSupport"
|
||||||
serviceImplementation="org.jetbrains.jet.plugin.caches.resolve.IDELightClassGenerationSupport"/>
|
serviceImplementation="org.jetbrains.jet.plugin.caches.resolve.IDELightClassGenerationSupport"/>
|
||||||
|
|
||||||
|
<projectService serviceInterface="org.jetbrains.jet.lang.resolve.CodeAnalyzerInitializer"
|
||||||
|
serviceImplementation="org.jetbrains.jet.lang.resolve.DummyCodeAnalyzerInitializer"/>
|
||||||
|
|
||||||
<projectService serviceInterface="org.jetbrains.jet.lang.parsing.JetScriptDefinitionProvider"
|
<projectService serviceInterface="org.jetbrains.jet.lang.parsing.JetScriptDefinitionProvider"
|
||||||
serviceImplementation="org.jetbrains.jet.lang.parsing.JetScriptDefinitionProvider"/>
|
serviceImplementation="org.jetbrains.jet.lang.parsing.JetScriptDefinitionProvider"/>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user