Move module creation into TopDownAnalyzerFacadeForJVM#analyzeFilesWithJavaIntegration
The only place where the logic has changed is in AbstractDiagnosticsTest, where modules are already created and sealed before the analysis. Copy-paste the container creation logic there (it's almost fine because it's also present in a bunch of other tests), and simplify it: get rid of incremental compilation and other stuff irrelevant for diagnostic tests. This is needed to make analyzeFilesWithJavaIntegration configure the module properly before sealing it
This commit is contained in:
@@ -20,6 +20,7 @@ import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import junit.framework.ComparisonFailure;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.analyzer.AnalysisResult;
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.CliLightClassGenerationSupport;
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles;
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.JvmPackagePartProvider;
|
||||
@@ -28,14 +29,12 @@ import org.jetbrains.kotlin.cli.jvm.config.JvmContentRootsKt;
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration;
|
||||
import org.jetbrains.kotlin.config.ContentRootsKt;
|
||||
import org.jetbrains.kotlin.config.JVMConfigurationKeys;
|
||||
import org.jetbrains.kotlin.context.ModuleContext;
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.PackageViewDescriptor;
|
||||
import org.jetbrains.kotlin.psi.KtFile;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||
import org.jetbrains.kotlin.resolve.jvm.TopDownAnalyzerFacadeForJVM;
|
||||
import org.jetbrains.kotlin.resolve.lazy.JvmResolveUtil;
|
||||
@@ -155,19 +154,17 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
|
||||
ContentRootsKt.addKotlinSourceRoot(configuration, sourcesDir.getAbsolutePath());
|
||||
JvmContentRootsKt.addJavaSourceRoot(configuration, new File("compiler/testData/loadJava/include"));
|
||||
JvmContentRootsKt.addJavaSourceRoot(configuration, tmpdir);
|
||||
|
||||
|
||||
KotlinCoreEnvironment environment =
|
||||
KotlinCoreEnvironment.createForTests(getTestRootDisposable(), configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES);
|
||||
|
||||
BindingTrace trace = new CliLightClassGenerationSupport.NoScopeRecordCliBindingTrace();
|
||||
ModuleContext moduleContext = TopDownAnalyzerFacadeForJVM.createContextWithSealedModule(environment.getProject(), configuration);
|
||||
|
||||
TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(
|
||||
moduleContext, environment.getSourceFiles(), trace, configuration, new JvmPackagePartProvider(environment)
|
||||
AnalysisResult result = TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(
|
||||
environment.getProject(), environment.getSourceFiles(), new CliLightClassGenerationSupport.NoScopeRecordCliBindingTrace(),
|
||||
configuration, new JvmPackagePartProvider(environment)
|
||||
);
|
||||
|
||||
PackageViewDescriptor packageView = moduleContext.getModule().getPackage(TEST_PACKAGE_FQNAME);
|
||||
checkJavaPackage(expectedFile, packageView, trace.getBindingContext(), DONT_INCLUDE_METHODS_OF_OBJECT);
|
||||
PackageViewDescriptor packageView = result.getModuleDescriptor().getPackage(TEST_PACKAGE_FQNAME);
|
||||
checkJavaPackage(expectedFile, packageView, result.getBindingContext(), DONT_INCLUDE_METHODS_OF_OBJECT);
|
||||
}
|
||||
|
||||
// TODO: add more tests on inherited parameter names, but currently impossible because of KT-4509
|
||||
|
||||
@@ -88,8 +88,7 @@ public class JvmResolveUtil {
|
||||
@NotNull PackagePartProvider packagePartProvider
|
||||
) {
|
||||
return TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(
|
||||
TopDownAnalyzerFacadeForJVM.createContextWithSealedModule(project, configuration),
|
||||
files, new CliLightClassGenerationSupport.CliBindingTrace(), configuration, packagePartProvider
|
||||
project, files, new CliLightClassGenerationSupport.CliBindingTrace(), configuration, packagePartProvider
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user