Rename: AnalyzeExhaust -> AnalysisResult
This commit is contained in:
@@ -30,7 +30,7 @@ import java.util.List;
|
||||
public class CompilerPluginContext {
|
||||
@NotNull
|
||||
private final Project project;
|
||||
//TODO: should we in fact store AnalyzeExhaust here?
|
||||
//TODO: should we in fact store AnalysisResult here?
|
||||
@NotNull
|
||||
private final BindingContext context;
|
||||
@NotNull
|
||||
|
||||
+13
-13
@@ -25,7 +25,7 @@ import com.intellij.psi.util.PsiFormatUtil;
|
||||
import kotlin.Function0;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.analyzer.AnalysisResult;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.diagnostics.*;
|
||||
@@ -66,7 +66,7 @@ public final class AnalyzerWithCompilerReport {
|
||||
@NotNull
|
||||
private final MessageCollector messageCollectorWrapper;
|
||||
@Nullable
|
||||
private AnalyzeExhaust analyzeExhaust = null;
|
||||
private AnalysisResult analysisResult = null;
|
||||
|
||||
public AnalyzerWithCompilerReport(@NotNull final MessageCollector collector) {
|
||||
messageCollectorWrapper = new MessageCollector() {
|
||||
@@ -99,8 +99,8 @@ public final class AnalyzerWithCompilerReport {
|
||||
}
|
||||
|
||||
private void reportIncompleteHierarchies() {
|
||||
assert analyzeExhaust != null;
|
||||
Collection<ClassDescriptor> incompletes = analyzeExhaust.getBindingContext().getKeys(BindingContext.INCOMPLETE_HIERARCHY);
|
||||
assert analysisResult != null;
|
||||
Collection<ClassDescriptor> incompletes = analysisResult.getBindingContext().getKeys(BindingContext.INCOMPLETE_HIERARCHY);
|
||||
if (!incompletes.isEmpty()) {
|
||||
StringBuilder message = new StringBuilder("The following classes have incomplete hierarchies:\n");
|
||||
for (ClassDescriptor incomplete : incompletes) {
|
||||
@@ -112,8 +112,8 @@ public final class AnalyzerWithCompilerReport {
|
||||
}
|
||||
|
||||
private void reportAlternativeSignatureErrors() {
|
||||
assert analyzeExhaust != null;
|
||||
BindingContext bc = analyzeExhaust.getBindingContext();
|
||||
assert analysisResult != null;
|
||||
BindingContext bc = analysisResult.getBindingContext();
|
||||
Collection<DeclarationDescriptor> descriptorsWithErrors = bc.getKeys(JavaBindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS);
|
||||
if (!descriptorsWithErrors.isEmpty()) {
|
||||
StringBuilder message = new StringBuilder("The following Java entities have annotations with wrong Kotlin signatures:\n");
|
||||
@@ -137,8 +137,8 @@ public final class AnalyzerWithCompilerReport {
|
||||
}
|
||||
|
||||
private void reportAbiVersionErrors() {
|
||||
assert analyzeExhaust != null;
|
||||
BindingContext bindingContext = analyzeExhaust.getBindingContext();
|
||||
assert analysisResult != null;
|
||||
BindingContext bindingContext = analysisResult.getBindingContext();
|
||||
|
||||
Collection<VirtualFileKotlinClass> errorClasses = bindingContext.getKeys(TraceBasedErrorReporter.ABI_VERSION_ERRORS);
|
||||
for (VirtualFileKotlinClass kotlinClass : errorClasses) {
|
||||
@@ -212,20 +212,20 @@ public final class AnalyzerWithCompilerReport {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public AnalyzeExhaust getAnalyzeExhaust() {
|
||||
return analyzeExhaust;
|
||||
public AnalysisResult getAnalysisResult() {
|
||||
return analysisResult;
|
||||
}
|
||||
|
||||
public boolean hasErrors() {
|
||||
return hasErrors;
|
||||
}
|
||||
|
||||
public void analyzeAndReport(@NotNull Collection<JetFile> files, @NotNull Function0<AnalyzeExhaust> analyzer) {
|
||||
analyzeExhaust = analyzer.invoke();
|
||||
public void analyzeAndReport(@NotNull Collection<JetFile> files, @NotNull Function0<AnalysisResult> analyzer) {
|
||||
analysisResult = analyzer.invoke();
|
||||
reportAbiVersionErrors();
|
||||
reportSyntaxErrors(files);
|
||||
//noinspection ConstantConditions
|
||||
reportDiagnostics(analyzeExhaust.getBindingContext().getDiagnostics(), messageCollectorWrapper);
|
||||
reportDiagnostics(analysisResult.getBindingContext().getDiagnostics(), messageCollectorWrapper);
|
||||
reportIncompleteHierarchies();
|
||||
reportAlternativeSignatureErrors();
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ import kotlin.Function0;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.OutputFileCollection;
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.analyzer.AnalysisResult;
|
||||
import org.jetbrains.jet.cli.common.CLICompiler;
|
||||
import org.jetbrains.jet.cli.common.CLIConfigurationKeys;
|
||||
import org.jetbrains.jet.cli.common.ExitCode;
|
||||
@@ -198,9 +198,9 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
|
||||
private static boolean analyzeAndReportErrors(@NotNull MessageCollector messageCollector,
|
||||
@NotNull final List<JetFile> sources, @NotNull final Config config) {
|
||||
AnalyzerWithCompilerReport analyzerWithCompilerReport = new AnalyzerWithCompilerReport(messageCollector);
|
||||
analyzerWithCompilerReport.analyzeAndReport(sources, new Function0<AnalyzeExhaust>() {
|
||||
analyzerWithCompilerReport.analyzeAndReport(sources, new Function0<AnalysisResult>() {
|
||||
@Override
|
||||
public AnalyzeExhaust invoke() {
|
||||
public AnalysisResult invoke() {
|
||||
return TopDownAnalyzerFacadeForJS.analyzeFiles(sources, Predicates.<PsiFile>alwaysTrue(), config);
|
||||
}
|
||||
});
|
||||
|
||||
+20
-21
@@ -30,7 +30,7 @@ import kotlin.modules.AllModules;
|
||||
import kotlin.modules.Module;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.analyzer.AnalysisResult;
|
||||
import org.jetbrains.jet.asJava.FilteredJvmDiagnostics;
|
||||
import org.jetbrains.jet.cli.common.CLIConfigurationKeys;
|
||||
import org.jetbrains.jet.cli.common.CompilerPlugin;
|
||||
@@ -41,7 +41,6 @@ import org.jetbrains.jet.cli.jvm.JVMConfigurationKeys;
|
||||
import org.jetbrains.jet.codegen.*;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.codegen.state.Progress;
|
||||
import org.jetbrains.jet.config.CommonConfigurationKeys;
|
||||
import org.jetbrains.jet.config.CompilerConfiguration;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.ModuleDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.parsing.JetScriptDefinition;
|
||||
@@ -117,12 +116,12 @@ public class KotlinToJVMBytecodeCompiler {
|
||||
try {
|
||||
environment = JetCoreEnvironment.createForProduction(parentDisposable, compilerConfiguration);
|
||||
|
||||
AnalyzeExhaust exhaust = analyze(environment);
|
||||
if (exhaust == null) {
|
||||
AnalysisResult result = analyze(environment);
|
||||
if (result == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
exhaust.throwIfError();
|
||||
result.throwIfError();
|
||||
|
||||
for (Module module : chunk) {
|
||||
List<JetFile> jetFiles = CompileEnvironmentUtil.getJetFiles(
|
||||
@@ -134,7 +133,7 @@ public class KotlinToJVMBytecodeCompiler {
|
||||
}
|
||||
);
|
||||
GenerationState generationState =
|
||||
generate(environment, exhaust, jetFiles, module.getModuleName(), new File(module.getOutputDirectory()));
|
||||
generate(environment, result, jetFiles, module.getModuleName(), new File(module.getOutputDirectory()));
|
||||
outputFiles.put(module, generationState.getFactory());
|
||||
}
|
||||
}
|
||||
@@ -270,26 +269,26 @@ public class KotlinToJVMBytecodeCompiler {
|
||||
|
||||
@Nullable
|
||||
public static GenerationState analyzeAndGenerate(@NotNull JetCoreEnvironment environment) {
|
||||
AnalyzeExhaust exhaust = analyze(environment);
|
||||
AnalysisResult result = analyze(environment);
|
||||
|
||||
if (exhaust == null) {
|
||||
if (result == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
exhaust.throwIfError();
|
||||
result.throwIfError();
|
||||
|
||||
return generate(environment, exhaust, environment.getSourceFiles(), null, null);
|
||||
return generate(environment, result, environment.getSourceFiles(), null, null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static AnalyzeExhaust analyze(@NotNull final JetCoreEnvironment environment) {
|
||||
private static AnalysisResult analyze(@NotNull final JetCoreEnvironment environment) {
|
||||
AnalyzerWithCompilerReport analyzerWithCompilerReport = new AnalyzerWithCompilerReport(
|
||||
environment.getConfiguration().get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY));
|
||||
analyzerWithCompilerReport.analyzeAndReport(
|
||||
environment.getSourceFiles(), new Function0<AnalyzeExhaust>() {
|
||||
environment.getSourceFiles(), new Function0<AnalysisResult>() {
|
||||
@NotNull
|
||||
@Override
|
||||
public AnalyzeExhaust invoke() {
|
||||
public AnalysisResult invoke() {
|
||||
CliLightClassGenerationSupport support = CliLightClassGenerationSupport.getInstanceForCli(environment.getProject());
|
||||
BindingTrace sharedTrace = support.getTrace();
|
||||
ModuleDescriptorImpl sharedModule = support.newModule();
|
||||
@@ -307,22 +306,22 @@ public class KotlinToJVMBytecodeCompiler {
|
||||
}
|
||||
);
|
||||
|
||||
AnalyzeExhaust exhaust = analyzerWithCompilerReport.getAnalyzeExhaust();
|
||||
assert exhaust != null : "AnalyzeExhaust should be non-null, compiling: " + environment.getSourceFiles();
|
||||
AnalysisResult result = analyzerWithCompilerReport.getAnalysisResult();
|
||||
assert result != null : "AnalysisResult should be non-null, compiling: " + environment.getSourceFiles();
|
||||
|
||||
CompilerPluginContext context = new CompilerPluginContext(environment.getProject(), exhaust.getBindingContext(),
|
||||
CompilerPluginContext context = new CompilerPluginContext(environment.getProject(), result.getBindingContext(),
|
||||
environment.getSourceFiles());
|
||||
for (CompilerPlugin plugin : environment.getConfiguration().getList(CLIConfigurationKeys.COMPILER_PLUGINS)) {
|
||||
plugin.processFiles(context);
|
||||
}
|
||||
|
||||
return analyzerWithCompilerReport.hasErrors() ? null : exhaust;
|
||||
return analyzerWithCompilerReport.hasErrors() ? null : result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static GenerationState generate(
|
||||
@NotNull JetCoreEnvironment environment,
|
||||
@NotNull AnalyzeExhaust exhaust,
|
||||
@NotNull AnalysisResult result,
|
||||
@NotNull List<JetFile> sourceFiles,
|
||||
@Nullable String moduleId,
|
||||
File outputDirectory
|
||||
@@ -343,8 +342,8 @@ public class KotlinToJVMBytecodeCompiler {
|
||||
environment.getProject(),
|
||||
ClassBuilderFactories.BINARIES,
|
||||
Progress.DEAF,
|
||||
exhaust.getModuleDescriptor(),
|
||||
exhaust.getBindingContext(),
|
||||
result.getModuleDescriptor(),
|
||||
result.getBindingContext(),
|
||||
sourceFiles,
|
||||
configuration.get(JVMConfigurationKeys.DISABLE_CALL_ASSERTIONS, false),
|
||||
configuration.get(JVMConfigurationKeys.DISABLE_PARAM_ASSERTIONS, false),
|
||||
@@ -360,7 +359,7 @@ public class KotlinToJVMBytecodeCompiler {
|
||||
AnalyzerWithCompilerReport.reportDiagnostics(
|
||||
new FilteredJvmDiagnostics(
|
||||
diagnosticHolder.getBindingContext().getDiagnostics(),
|
||||
exhaust.getBindingContext().getDiagnostics()
|
||||
result.getBindingContext().getDiagnostics()
|
||||
),
|
||||
environment.getConfiguration().get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY)
|
||||
);
|
||||
|
||||
+4
-4
@@ -22,7 +22,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.analyzer.AnalysisResult;
|
||||
import org.jetbrains.jet.context.ContextPackage;
|
||||
import org.jetbrains.jet.context.GlobalContext;
|
||||
import org.jetbrains.jet.di.InjectorForTopDownAnalyzerForJvm;
|
||||
@@ -57,7 +57,7 @@ public enum TopDownAnalyzerFacadeForJVM {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static AnalyzeExhaust analyzeFilesWithJavaIntegration(
|
||||
public static AnalysisResult analyzeFilesWithJavaIntegration(
|
||||
Project project,
|
||||
Collection<JetFile> files,
|
||||
BindingTrace trace,
|
||||
@@ -72,7 +72,7 @@ public enum TopDownAnalyzerFacadeForJVM {
|
||||
incrementalCacheProvider);
|
||||
}
|
||||
|
||||
public static AnalyzeExhaust analyzeFilesWithJavaIntegrationWithCustomContext(
|
||||
public static AnalysisResult analyzeFilesWithJavaIntegrationWithCustomContext(
|
||||
@NotNull Project project,
|
||||
@NotNull GlobalContext globalContext,
|
||||
@NotNull Collection<JetFile> files,
|
||||
@@ -109,7 +109,7 @@ public enum TopDownAnalyzerFacadeForJVM {
|
||||
additionalProviders.add(injector.getJavaDescriptorResolver().getPackageFragmentProvider());
|
||||
|
||||
injector.getTopDownAnalyzer().analyzeFiles(topDownAnalysisParameters, files, additionalProviders);
|
||||
return AnalyzeExhaust.success(trace.getBindingContext(), module);
|
||||
return AnalysisResult.success(trace.getBindingContext(), module);
|
||||
}
|
||||
finally {
|
||||
injector.destroy();
|
||||
|
||||
+7
-7
@@ -21,13 +21,13 @@ import org.jetbrains.jet.lang.resolve.BindingContext
|
||||
import org.jetbrains.jet.lang.types.ErrorUtils
|
||||
import kotlin.platform.platformStatic
|
||||
|
||||
public data open class AnalyzeExhaust protected (
|
||||
public data open class AnalysisResult protected (
|
||||
public val bindingContext: BindingContext,
|
||||
public val moduleDescriptor: ModuleDescriptor
|
||||
) {
|
||||
|
||||
public val error: Throwable
|
||||
get() = if (this is Error) this.exception else throw IllegalStateException("Should only be called for error analyze exhaust")
|
||||
get() = if (this is Error) this.exception else throw IllegalStateException("Should only be called for error analysis result")
|
||||
|
||||
public fun isError(): Boolean = this is Error
|
||||
|
||||
@@ -37,16 +37,16 @@ public data open class AnalyzeExhaust protected (
|
||||
}
|
||||
}
|
||||
|
||||
private class Error(bindingContext: BindingContext, val exception: Throwable) : AnalyzeExhaust(bindingContext, ErrorUtils.getErrorModule())
|
||||
private class Error(bindingContext: BindingContext, val exception: Throwable) : AnalysisResult(bindingContext, ErrorUtils.getErrorModule())
|
||||
|
||||
class object {
|
||||
public val EMPTY: AnalyzeExhaust = success(BindingContext.EMPTY, ErrorUtils.getErrorModule())
|
||||
public val EMPTY: AnalysisResult = success(BindingContext.EMPTY, ErrorUtils.getErrorModule())
|
||||
|
||||
platformStatic public fun success(bindingContext: BindingContext, module: ModuleDescriptor): AnalyzeExhaust {
|
||||
return AnalyzeExhaust(bindingContext, module)
|
||||
platformStatic public fun success(bindingContext: BindingContext, module: ModuleDescriptor): AnalysisResult {
|
||||
return AnalysisResult(bindingContext, module)
|
||||
}
|
||||
|
||||
platformStatic public fun error(bindingContext: BindingContext, error: Throwable): AnalyzeExhaust {
|
||||
platformStatic public fun error(bindingContext: BindingContext, error: Throwable): AnalysisResult {
|
||||
return Error(bindingContext, error)
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@ import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.analyzer.AnalysisResult;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.CliLightClassGenerationSupport;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||
import org.jetbrains.jet.codegen.forTestCompile.ForTestCompileRuntime;
|
||||
@@ -93,7 +93,7 @@ import static org.jetbrains.jet.ConfigurationKind.ALL;
|
||||
import static org.jetbrains.jet.ConfigurationKind.JDK_AND_ANNOTATIONS;
|
||||
import static org.jetbrains.jet.cli.jvm.JVMConfigurationKeys.ANNOTATIONS_PATH_KEY;
|
||||
import static org.jetbrains.jet.cli.jvm.JVMConfigurationKeys.CLASSPATH_KEY;
|
||||
import static org.jetbrains.jet.jvm.compiler.LoadDescriptorUtil.compileKotlinToDirAndGetAnalyzeExhaust;
|
||||
import static org.jetbrains.jet.jvm.compiler.LoadDescriptorUtil.compileKotlinToDirAndGetAnalysisResult;
|
||||
import static org.jetbrains.jet.lang.psi.PsiPackage.JetPsiFactory;
|
||||
|
||||
public class JetTestUtils {
|
||||
@@ -244,12 +244,12 @@ public class JetTestUtils {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static AnalyzeExhaust analyzeFile(@NotNull JetFile file) {
|
||||
public static AnalysisResult analyzeFile(@NotNull JetFile file) {
|
||||
return JvmResolveUtil.analyzeOneFileWithJavaIntegration(file);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static AnalyzeExhaust analyzeFileWithoutBody(@NotNull JetFile file) {
|
||||
public static AnalysisResult analyzeFileWithoutBody(@NotNull JetFile file) {
|
||||
return JvmResolveUtil.analyzeFilesWithJavaIntegration(file.getProject(),
|
||||
Collections.singleton(file),
|
||||
Predicates.<PsiFile>alwaysFalse());
|
||||
@@ -486,7 +486,7 @@ public class JetTestUtils {
|
||||
@NotNull Disposable disposable
|
||||
) throws IOException {
|
||||
if (!ktFiles.isEmpty()) {
|
||||
compileKotlinToDirAndGetAnalyzeExhaust(ktFiles, outDir, disposable, ALL);
|
||||
compileKotlinToDirAndGetAnalysisResult(ktFiles, outDir, disposable, ALL);
|
||||
}
|
||||
else {
|
||||
boolean mkdirs = outDir.mkdirs();
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.ConfigurationKind;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.analyzer.AnalysisResult;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||
import org.jetbrains.jet.lang.cfg.pseudocode.Pseudocode;
|
||||
import org.jetbrains.jet.lang.cfg.pseudocode.PseudocodeImpl;
|
||||
@@ -54,9 +54,9 @@ public abstract class AbstractPseudocodeTest extends KotlinTestWithEnvironment {
|
||||
JetFile jetFile = JetTestUtils.loadJetFile(getProject(), file);
|
||||
|
||||
Map<JetElement, Pseudocode> data = new LinkedHashMap<JetElement, Pseudocode>();
|
||||
AnalyzeExhaust analyzeExhaust = JetTestUtils.analyzeFile(jetFile);
|
||||
AnalysisResult analysisResult = JetTestUtils.analyzeFile(jetFile);
|
||||
List<JetDeclaration> declarations = jetFile.getDeclarations();
|
||||
BindingContext bindingContext = analyzeExhaust.getBindingContext();
|
||||
BindingContext bindingContext = analysisResult.getBindingContext();
|
||||
for (JetDeclaration declaration : declarations) {
|
||||
addDeclaration(data, bindingContext, declaration);
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.JetTestCaseBuilder;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.analyzer.AnalysisResult;
|
||||
import org.jetbrains.jet.cli.jvm.JVMConfigurationKeys;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||
import org.jetbrains.jet.codegen.forTestCompile.ForTestCompileRuntime;
|
||||
@@ -52,18 +52,18 @@ public class CodegenTestUtil {
|
||||
|
||||
@NotNull
|
||||
public static ClassFileFactory generateFiles(@NotNull JetCoreEnvironment environment, @NotNull CodegenTestFiles files) {
|
||||
AnalyzeExhaust analyzeExhaust = JvmResolveUtil.analyzeFilesWithJavaIntegrationAndCheckForErrors(
|
||||
AnalysisResult analysisResult = JvmResolveUtil.analyzeFilesWithJavaIntegrationAndCheckForErrors(
|
||||
environment.getProject(),
|
||||
files.getPsiFiles(),
|
||||
Predicates.<PsiFile>alwaysTrue()
|
||||
);
|
||||
analyzeExhaust.throwIfError();
|
||||
AnalyzingUtils.throwExceptionOnErrors(analyzeExhaust.getBindingContext());
|
||||
analysisResult.throwIfError();
|
||||
AnalyzingUtils.throwExceptionOnErrors(analysisResult.getBindingContext());
|
||||
CompilerConfiguration configuration = environment.getConfiguration();
|
||||
BindingTraceContext forExtraDiagnostics = new BindingTraceContext();
|
||||
GenerationState state = new GenerationState(
|
||||
environment.getProject(), ClassBuilderFactories.TEST, Progress.DEAF,
|
||||
analyzeExhaust.getModuleDescriptor(), analyzeExhaust.getBindingContext(), files.getPsiFiles(),
|
||||
analysisResult.getModuleDescriptor(), analysisResult.getBindingContext(), files.getPsiFiles(),
|
||||
configuration.get(JVMConfigurationKeys.DISABLE_CALL_ASSERTIONS, false),
|
||||
configuration.get(JVMConfigurationKeys.DISABLE_PARAM_ASSERTIONS, false),
|
||||
GenerationState.GenerateClassFilter.GENERATE_ALL,
|
||||
|
||||
@@ -20,7 +20,7 @@ import com.google.common.base.Predicates;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.analyzer.AnalysisResult;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.lazy.JvmResolveUtil;
|
||||
@@ -40,26 +40,26 @@ public class GenerationUtils {
|
||||
|
||||
@NotNull
|
||||
public static GenerationState compileFileGetGenerationStateForTest(@NotNull JetFile psiFile) {
|
||||
AnalyzeExhaust analyzeExhaust = JvmResolveUtil.analyzeOneFileWithJavaIntegrationAndCheckForErrors(psiFile);
|
||||
return compileFilesGetGenerationState(psiFile.getProject(), analyzeExhaust, Collections.singletonList(psiFile));
|
||||
AnalysisResult analysisResult = JvmResolveUtil.analyzeOneFileWithJavaIntegrationAndCheckForErrors(psiFile);
|
||||
return compileFilesGetGenerationState(psiFile.getProject(), analysisResult, Collections.singletonList(psiFile));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static GenerationState compileManyFilesGetGenerationStateForTest(@NotNull Project project, @NotNull List<JetFile> files) {
|
||||
AnalyzeExhaust analyzeExhaust = JvmResolveUtil.analyzeFilesWithJavaIntegrationAndCheckForErrors(
|
||||
AnalysisResult analysisResult = JvmResolveUtil.analyzeFilesWithJavaIntegrationAndCheckForErrors(
|
||||
project, files, Predicates.<PsiFile>alwaysTrue());
|
||||
return compileFilesGetGenerationState(project, analyzeExhaust, files);
|
||||
return compileFilesGetGenerationState(project, analysisResult, files);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static GenerationState compileFilesGetGenerationState(
|
||||
@NotNull Project project,
|
||||
@NotNull AnalyzeExhaust analyzeExhaust,
|
||||
@NotNull AnalysisResult analysisResult,
|
||||
@NotNull List<JetFile> files
|
||||
) {
|
||||
analyzeExhaust.throwIfError();
|
||||
GenerationState state = new GenerationState(project, ClassBuilderFactories.TEST, analyzeExhaust.getModuleDescriptor(),
|
||||
analyzeExhaust.getBindingContext(), files);
|
||||
analysisResult.throwIfError();
|
||||
GenerationState state = new GenerationState(project, ClassBuilderFactories.TEST, analysisResult.getModuleDescriptor(),
|
||||
analysisResult.getBindingContext(), files);
|
||||
KotlinCodegenFacade.compileCorrectFiles(state, CompilationErrorHandler.THROW_EXCEPTION);
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.jetbrains.jet.ConfigurationKind;
|
||||
import org.jetbrains.jet.JetTestCaseBuilder;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.TestJdkKind;
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.analyzer.AnalysisResult;
|
||||
import org.jetbrains.jet.cli.jvm.JVMConfigurationKeys;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.CliLightClassGenerationSupport;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||
@@ -80,7 +80,7 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
|
||||
File sourcesDir = new File(expectedFileName.replaceFirst("\\.txt$", ""));
|
||||
|
||||
List<File> kotlinSources = FileUtil.findFilesByMask(Pattern.compile(".+\\.kt"), sourcesDir);
|
||||
compileKotlinToDirAndGetAnalyzeExhaust(kotlinSources, tmpdir, myTestRootDisposable, ConfigurationKind.JDK_ONLY);
|
||||
compileKotlinToDirAndGetAnalysisResult(kotlinSources, tmpdir, myTestRootDisposable, ConfigurationKind.JDK_ONLY);
|
||||
|
||||
List<File> javaSources = FileUtil.findFilesByMask(Pattern.compile(".+\\.java"), sourcesDir);
|
||||
Pair<PackageViewDescriptor, BindingContext> binaryPackageAndContext = compileJavaAndLoadTestPackageAndBindingContextFromBinary(
|
||||
@@ -104,10 +104,10 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
|
||||
protected void doTestCompiledKotlin(@NotNull String ktFileName, @NotNull ConfigurationKind configurationKind) throws Exception {
|
||||
File ktFile = new File(ktFileName);
|
||||
File txtFile = new File(ktFileName.replaceFirst("\\.kt$", ".txt"));
|
||||
AnalyzeExhaust exhaust = compileKotlinToDirAndGetAnalyzeExhaust(Collections.singletonList(ktFile), tmpdir, getTestRootDisposable(),
|
||||
AnalysisResult result = compileKotlinToDirAndGetAnalysisResult(Collections.singletonList(ktFile), tmpdir, getTestRootDisposable(),
|
||||
configurationKind);
|
||||
|
||||
PackageViewDescriptor packageFromSource = exhaust.getModuleDescriptor().getPackage(TEST_PACKAGE_FQNAME);
|
||||
PackageViewDescriptor packageFromSource = result.getModuleDescriptor().getPackage(TEST_PACKAGE_FQNAME);
|
||||
assert packageFromSource != null : "Package " + TEST_PACKAGE_FQNAME + " not found";
|
||||
Assert.assertEquals("test", packageFromSource.getName().asString());
|
||||
|
||||
@@ -194,10 +194,10 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
|
||||
);
|
||||
JetFile jetFile = JetTestUtils.createFile(kotlinSrc.getPath(), FileUtil.loadFile(kotlinSrc, true), environment.getProject());
|
||||
|
||||
AnalyzeExhaust exhaust = JvmResolveUtil.analyzeFilesWithJavaIntegrationAndCheckForErrors(
|
||||
AnalysisResult result = JvmResolveUtil.analyzeFilesWithJavaIntegrationAndCheckForErrors(
|
||||
environment.getProject(), Collections.singleton(jetFile), Predicates.<PsiFile>alwaysTrue()
|
||||
);
|
||||
PackageViewDescriptor packageView = exhaust.getModuleDescriptor().getPackage(TEST_PACKAGE_FQNAME);
|
||||
PackageViewDescriptor packageView = result.getModuleDescriptor().getPackage(TEST_PACKAGE_FQNAME);
|
||||
assertNotNull(packageView);
|
||||
|
||||
validateAndCompareDescriptorWithFile(packageView, DONT_INCLUDE_METHODS_OF_OBJECT.withValidationStrategy(
|
||||
|
||||
+6
-6
@@ -24,7 +24,7 @@ import org.jetbrains.jet.ConfigurationKind;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.MockLibraryUtil;
|
||||
import org.jetbrains.jet.TestJdkKind;
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.analyzer.AnalysisResult;
|
||||
import org.jetbrains.jet.cli.common.messages.AnalyzerWithCompilerReport;
|
||||
import org.jetbrains.jet.cli.common.messages.MessageCollectorPlainTextToStream;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||
@@ -82,11 +82,11 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
|
||||
private PackageViewDescriptor analyzeFileToPackageView(@NotNull File... extraClassPath) throws IOException {
|
||||
Project project = createEnvironment(Arrays.asList(extraClassPath)).getProject();
|
||||
|
||||
AnalyzeExhaust exhaust = JvmResolveUtil.analyzeOneFileWithJavaIntegrationAndCheckForErrors(
|
||||
AnalysisResult result = JvmResolveUtil.analyzeOneFileWithJavaIntegrationAndCheckForErrors(
|
||||
JetTestUtils.loadJetFile(project, getTestDataFileWithExtension("kt"))
|
||||
);
|
||||
|
||||
PackageViewDescriptor packageView = exhaust.getModuleDescriptor().getPackage(LoadDescriptorUtil.TEST_PACKAGE_FQNAME);
|
||||
PackageViewDescriptor packageView = result.getModuleDescriptor().getPackage(LoadDescriptorUtil.TEST_PACKAGE_FQNAME);
|
||||
assertNotNull("Failed to find package: " + LoadDescriptorUtil.TEST_PACKAGE_FQNAME, packageView);
|
||||
return packageView;
|
||||
}
|
||||
@@ -174,12 +174,12 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
|
||||
|
||||
Project project = createEnvironment(Collections.singletonList(tmpdir)).getProject();
|
||||
|
||||
AnalyzeExhaust exhaust = JvmResolveUtil.analyzeOneFileWithJavaIntegration(
|
||||
AnalysisResult result = JvmResolveUtil.analyzeOneFileWithJavaIntegration(
|
||||
JetTestUtils.loadJetFile(project, getTestDataFileWithExtension("kt"))
|
||||
);
|
||||
exhaust.throwIfError();
|
||||
result.throwIfError();
|
||||
|
||||
BindingContext bindingContext = exhaust.getBindingContext();
|
||||
BindingContext bindingContext = result.getBindingContext();
|
||||
AnalyzerWithCompilerReport.reportDiagnostics(bindingContext.getDiagnostics(), MessageCollectorPlainTextToStream.PLAIN_TEXT_TO_SYSTEM_ERR);
|
||||
|
||||
assertEquals("There should be no diagnostics", 0, Iterables.size(bindingContext.getDiagnostics()));
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.ConfigurationKind;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.TestJdkKind;
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.analyzer.AnalysisResult;
|
||||
import org.jetbrains.jet.cli.common.output.outputUtils.OutputUtilsPackage;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.CliLightClassGenerationSupport;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||
@@ -45,13 +45,11 @@ import org.jetbrains.jet.lang.resolve.BindingTraceContext;
|
||||
import org.jetbrains.jet.lang.resolve.lazy.JvmResolveUtil;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.jet.JetTestUtils.createEnvironmentWithMockJdkAndIdeaAnnotations;
|
||||
@@ -65,18 +63,18 @@ public final class LoadDescriptorUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static AnalyzeExhaust compileKotlinToDirAndGetAnalyzeExhaust(
|
||||
public static AnalysisResult compileKotlinToDirAndGetAnalysisResult(
|
||||
@NotNull List<File> kotlinFiles,
|
||||
@NotNull File outDir,
|
||||
@NotNull Disposable disposable,
|
||||
@NotNull ConfigurationKind configurationKind
|
||||
) {
|
||||
JetFilesAndExhaust fileAndExhaust = JetFilesAndExhaust.createJetFilesAndAnalyze(kotlinFiles, disposable, configurationKind);
|
||||
AnalyzeExhaust exhaust = fileAndExhaust.getExhaust();
|
||||
List<JetFile> files = fileAndExhaust.getJetFiles();
|
||||
GenerationState state = GenerationUtils.compileFilesGetGenerationState(files.get(0).getProject(), exhaust, files);
|
||||
JetFilesAndAnalysisResult filesAndResult = JetFilesAndAnalysisResult.createJetFilesAndAnalyze(kotlinFiles, disposable, configurationKind);
|
||||
AnalysisResult result = filesAndResult.getAnalysisResult();
|
||||
List<JetFile> files = filesAndResult.getJetFiles();
|
||||
GenerationState state = GenerationUtils.compileFilesGetGenerationState(files.get(0).getProject(), result, files);
|
||||
OutputUtilsPackage.writeAllTo(state.getFactory(), outDir);
|
||||
return exhaust;
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -126,9 +124,9 @@ public final class LoadDescriptorUtil {
|
||||
));
|
||||
}
|
||||
|
||||
private static class JetFilesAndExhaust {
|
||||
private static class JetFilesAndAnalysisResult {
|
||||
@NotNull
|
||||
public static JetFilesAndExhaust createJetFilesAndAnalyze(
|
||||
public static JetFilesAndAnalysisResult createJetFilesAndAnalyze(
|
||||
@NotNull List<File> kotlinFiles,
|
||||
@NotNull Disposable disposable,
|
||||
@NotNull ConfigurationKind configurationKind
|
||||
@@ -146,17 +144,17 @@ public final class LoadDescriptorUtil {
|
||||
}
|
||||
}
|
||||
});
|
||||
AnalyzeExhaust exhaust = JvmResolveUtil.analyzeFilesWithJavaIntegrationAndCheckForErrors(
|
||||
AnalysisResult result = JvmResolveUtil.analyzeFilesWithJavaIntegrationAndCheckForErrors(
|
||||
jetCoreEnvironment.getProject(), jetFiles, Predicates.<PsiFile>alwaysTrue());
|
||||
return new JetFilesAndExhaust(jetFiles, exhaust);
|
||||
return new JetFilesAndAnalysisResult(jetFiles, result);
|
||||
}
|
||||
|
||||
private final List<JetFile> jetFiles;
|
||||
private final AnalyzeExhaust exhaust;
|
||||
private final AnalysisResult result;
|
||||
|
||||
private JetFilesAndExhaust(@NotNull List<JetFile> jetFiles, @NotNull AnalyzeExhaust exhaust) {
|
||||
private JetFilesAndAnalysisResult(@NotNull List<JetFile> jetFiles, @NotNull AnalysisResult result) {
|
||||
this.jetFiles = jetFiles;
|
||||
this.exhaust = exhaust;
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -165,8 +163,8 @@ public final class LoadDescriptorUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public AnalyzeExhaust getExhaust() {
|
||||
return exhaust;
|
||||
public AnalysisResult getAnalysisResult() {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import com.google.common.base.Predicates;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.analyzer.AnalysisResult;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.CliLightClassGenerationSupport;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.ModuleDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
@@ -35,24 +35,24 @@ import java.util.Collections;
|
||||
|
||||
public class JvmResolveUtil {
|
||||
@NotNull
|
||||
public static AnalyzeExhaust analyzeOneFileWithJavaIntegrationAndCheckForErrors(@NotNull JetFile file) {
|
||||
public static AnalysisResult analyzeOneFileWithJavaIntegrationAndCheckForErrors(@NotNull JetFile file) {
|
||||
AnalyzingUtils.checkForSyntacticErrors(file);
|
||||
|
||||
AnalyzeExhaust analyzeExhaust = analyzeOneFileWithJavaIntegration(file);
|
||||
AnalysisResult analysisResult = analyzeOneFileWithJavaIntegration(file);
|
||||
|
||||
AnalyzingUtils.throwExceptionOnErrors(analyzeExhaust.getBindingContext());
|
||||
AnalyzingUtils.throwExceptionOnErrors(analysisResult.getBindingContext());
|
||||
|
||||
return analyzeExhaust;
|
||||
return analysisResult;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static AnalyzeExhaust analyzeOneFileWithJavaIntegration(@NotNull JetFile file) {
|
||||
public static AnalysisResult analyzeOneFileWithJavaIntegration(@NotNull JetFile file) {
|
||||
return analyzeFilesWithJavaIntegration(file.getProject(), Collections.singleton(file),
|
||||
Predicates.<PsiFile>alwaysTrue());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static AnalyzeExhaust analyzeFilesWithJavaIntegrationAndCheckForErrors(
|
||||
public static AnalysisResult analyzeFilesWithJavaIntegrationAndCheckForErrors(
|
||||
@NotNull Project project,
|
||||
@NotNull Collection<JetFile> files,
|
||||
@NotNull Predicate<PsiFile> filesToAnalyzeCompletely
|
||||
@@ -61,15 +61,15 @@ public class JvmResolveUtil {
|
||||
AnalyzingUtils.checkForSyntacticErrors(file);
|
||||
}
|
||||
|
||||
AnalyzeExhaust analyzeExhaust = analyzeFilesWithJavaIntegration(project, files, filesToAnalyzeCompletely);
|
||||
AnalysisResult analysisResult = analyzeFilesWithJavaIntegration(project, files, filesToAnalyzeCompletely);
|
||||
|
||||
AnalyzingUtils.throwExceptionOnErrors(analyzeExhaust.getBindingContext());
|
||||
AnalyzingUtils.throwExceptionOnErrors(analysisResult.getBindingContext());
|
||||
|
||||
return analyzeExhaust;
|
||||
return analysisResult;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static AnalyzeExhaust analyzeFilesWithJavaIntegration(
|
||||
public static AnalysisResult analyzeFilesWithJavaIntegration(
|
||||
@NotNull Project project,
|
||||
@NotNull Collection<JetFile> files,
|
||||
@NotNull Predicate<PsiFile> filesToAnalyzeCompletely
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.jetbrains.jet.ConfigurationKind;
|
||||
import org.jetbrains.jet.JetLiteFixture;
|
||||
import org.jetbrains.jet.JetTestCaseBuilder;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.analyzer.AnalysisResult;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
@@ -94,14 +94,14 @@ public class DescriptorRendererTest extends JetLiteFixture {
|
||||
private void doTest() throws IOException {
|
||||
String fileName = getTestName(false) + ".kt";
|
||||
JetFile psiFile = createPsiFile(null, fileName, loadFile(fileName));
|
||||
AnalyzeExhaust analyzeExhaust =
|
||||
AnalysisResult analysisResult =
|
||||
JvmResolveUtil.analyzeOneFileWithJavaIntegration(psiFile);
|
||||
final BindingContext bindingContext = analyzeExhaust.getBindingContext();
|
||||
final BindingContext bindingContext = analysisResult.getBindingContext();
|
||||
final List<DeclarationDescriptor> descriptors = new ArrayList<DeclarationDescriptor>();
|
||||
|
||||
FqName fqName = psiFile.getPackageFqName();
|
||||
if (!fqName.isRoot()) {
|
||||
PackageViewDescriptor packageDescriptor = analyzeExhaust.getModuleDescriptor().getPackage(fqName);
|
||||
PackageViewDescriptor packageDescriptor = analysisResult.getModuleDescriptor().getPackage(fqName);
|
||||
descriptors.add(packageDescriptor);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import com.intellij.psi.PsiQualifiedNamedElement;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.analyzer.AnalysisResult;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.diagnostics.Diagnostic;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils;
|
||||
@@ -142,9 +142,9 @@ public abstract class ExpectedResolveData {
|
||||
}
|
||||
|
||||
Project project = files.iterator().next().getProject();
|
||||
AnalyzeExhaust analyzeExhaust = JvmResolveUtil.analyzeFilesWithJavaIntegration(
|
||||
AnalysisResult analysisResult = JvmResolveUtil.analyzeFilesWithJavaIntegration(
|
||||
project, files, Predicates.<PsiFile>alwaysTrue());
|
||||
return analyzeExhaust.getBindingContext();
|
||||
return analysisResult.getBindingContext();
|
||||
}
|
||||
|
||||
public final void checkResult(BindingContext bindingContext) {
|
||||
|
||||
+4
-4
@@ -23,7 +23,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.JetLiteFixture;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.analyzer.AnalysisResult;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
@@ -317,8 +317,8 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends JetLiteFix
|
||||
@NotNull
|
||||
protected JetFile getFile(@NotNull String content) {
|
||||
JetFile ktFile = JetTestUtils.createFile("dummy.kt", content, getProject());
|
||||
AnalyzeExhaust analyzeExhaust = analyzeFile(ktFile);
|
||||
context = analyzeExhaust.getBindingContext();
|
||||
AnalysisResult analysisResult = analyzeFile(ktFile);
|
||||
context = analysisResult.getBindingContext();
|
||||
|
||||
return ktFile;
|
||||
}
|
||||
@@ -336,7 +336,7 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends JetLiteFix
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected AnalyzeExhaust analyzeFile(@NotNull JetFile ktFile) {
|
||||
protected AnalysisResult analyzeFile(@NotNull JetFile ktFile) {
|
||||
return JetTestUtils.analyzeFile(ktFile);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.jetbrains.jet.resolve.annotation
|
||||
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust
|
||||
import org.jetbrains.jet.analyzer.AnalysisResult
|
||||
import org.jetbrains.jet.lang.psi.JetFile
|
||||
import org.jetbrains.jet.JetTestUtils
|
||||
|
||||
@@ -26,5 +26,5 @@ class AnnotationDescriptorResolveWithoutAnalyzeBodyTest : AnnotationDescriptorRe
|
||||
checkAnnotationOnAllExceptLocalDeclarations(content, expectedAnnotation)
|
||||
}
|
||||
|
||||
override fun analyzeFile(ktFile: JetFile): AnalyzeExhaust = JetTestUtils.analyzeFileWithoutBody(ktFile)
|
||||
override fun analyzeFile(ktFile: JetFile): AnalysisResult = JetTestUtils.analyzeFileWithoutBody(ktFile)
|
||||
}
|
||||
@@ -19,7 +19,7 @@ package org.jetbrains.jet.test.util;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.analyzer.AnalysisResult;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
@@ -43,8 +43,8 @@ public class RecursiveDescriptorProcessorTest extends KotlinTestWithEnvironment
|
||||
File txtFile = new File("compiler/testData/recursiveProcessor/declarations.txt");
|
||||
String text = FileUtil.loadFile(ktFile, true);
|
||||
JetFile jetFile = JetTestUtils.createFile("declarations.kt", text, getEnvironment().getProject());
|
||||
AnalyzeExhaust exhaust = JetTestUtils.analyzeFile(jetFile);
|
||||
PackageViewDescriptor testPackage = exhaust.getModuleDescriptor().getPackage(FqName.topLevel(Name.identifier("test")));
|
||||
AnalysisResult result = JetTestUtils.analyzeFile(jetFile);
|
||||
PackageViewDescriptor testPackage = result.getModuleDescriptor().getPackage(FqName.topLevel(Name.identifier("test")));
|
||||
assert testPackage != null;
|
||||
|
||||
List<String> descriptors = recursivelyCollectDescriptors(testPackage);
|
||||
|
||||
@@ -21,7 +21,7 @@ import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.jet.ConfigurationKind;
|
||||
import org.jetbrains.jet.JetLiteFixture;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.analyzer.AnalysisResult;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||
import org.jetbrains.jet.di.InjectorForTests;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
@@ -86,7 +86,7 @@ public class JetDefaultModalityModifiersTest extends JetLiteFixture {
|
||||
List<JetDeclaration> declarations = file.getDeclarations();
|
||||
JetDeclaration aClass = declarations.get(0);
|
||||
assert aClass instanceof JetClass;
|
||||
AnalyzeExhaust bindingContext = JvmResolveUtil.analyzeOneFileWithJavaIntegrationAndCheckForErrors(file);
|
||||
AnalysisResult bindingContext = JvmResolveUtil.analyzeOneFileWithJavaIntegrationAndCheckForErrors(file);
|
||||
DeclarationDescriptor classDescriptor = bindingContext.getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, aClass);
|
||||
WritableScopeImpl scope = new WritableScopeImpl(
|
||||
libraryScope, root, RedeclarationHandler.DO_NOTHING, "JetDefaultModalityModifiersTest");
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ package org.jetbrains.jet.plugin.caches.resolve
|
||||
import org.jetbrains.jet.lang.psi.JetElement
|
||||
import org.jetbrains.jet.lang.psi.JetFile
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust
|
||||
import org.jetbrains.jet.analyzer.AnalysisResult
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.util.containers.SLRUCache
|
||||
import com.intellij.psi.util.PsiModificationTracker
|
||||
@@ -172,7 +172,7 @@ public class KotlinCacheService(val project: Project) {
|
||||
return getCacheToAnalyzeFiles(listOf(file)).getLazyResolveSession(file)
|
||||
}
|
||||
|
||||
public fun getAnalysisResults(elements: Collection<JetElement>): AnalyzeExhaust {
|
||||
public fun getAnalysisResults(elements: Collection<JetElement>): AnalysisResult {
|
||||
val files = elements.map { it.getContainingJetFile() }.toSet()
|
||||
assertAreInSameModule(files)
|
||||
|
||||
|
||||
+16
-16
@@ -20,7 +20,7 @@ import org.jetbrains.jet.lang.psi.JetElement
|
||||
import org.jetbrains.jet.lang.psi.JetFile
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust
|
||||
import org.jetbrains.jet.analyzer.AnalysisResult
|
||||
import com.intellij.psi.util.CachedValuesManager
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils
|
||||
import com.intellij.util.containers.SLRUCache
|
||||
@@ -100,7 +100,7 @@ private class KotlinResolveCache(
|
||||
CachedValueProvider.Result(results, PsiModificationTracker.MODIFICATION_COUNT, resolverProvider.exceptionTracker)
|
||||
}, false)
|
||||
|
||||
fun getAnalysisResultsForElements(elements: Collection<JetElement>): AnalyzeExhaust {
|
||||
fun getAnalysisResultsForElements(elements: Collection<JetElement>): AnalysisResult {
|
||||
val slruCache = synchronized(analysisResults) {
|
||||
analysisResults.getValue()!!
|
||||
}
|
||||
@@ -113,24 +113,24 @@ private class KotlinResolveCache(
|
||||
val withError = results.firstOrNull { it.isError() }
|
||||
val bindingContext = CompositeBindingContext.create(results.map { it.bindingContext })
|
||||
return if (withError != null)
|
||||
AnalyzeExhaust.error(bindingContext, withError.error)
|
||||
AnalysisResult.error(bindingContext, withError.error)
|
||||
else
|
||||
//TODO: (module refactoring) several elements are passed here in debugger
|
||||
AnalyzeExhaust.success(bindingContext, getLazyResolveSession(elements.first()).getModuleDescriptor())
|
||||
AnalysisResult.success(bindingContext, getLazyResolveSession(elements.first()).getModuleDescriptor())
|
||||
}
|
||||
}
|
||||
|
||||
private class PerFileAnalysisCache(val file: JetFile, val resolveSession: ResolveSessionForBodies) {
|
||||
private val cache = HashMap<PsiElement, AnalyzeExhaust>()
|
||||
private val cache = HashMap<PsiElement, AnalysisResult>()
|
||||
|
||||
private fun lookUp(analyzableElement: JetElement): AnalyzeExhaust? {
|
||||
private fun lookUp(analyzableElement: JetElement): AnalysisResult? {
|
||||
// Looking for parent elements that are already analyzed
|
||||
// Also removing all elements whose parents are already analyzed, to guarantee consistency
|
||||
val descendantsOfCurrent = arrayListOf<PsiElement>()
|
||||
val toRemove = hashSetOf<PsiElement>()
|
||||
|
||||
var current: PsiElement? = analyzableElement
|
||||
var result: AnalyzeExhaust? = null
|
||||
var result: AnalysisResult? = null
|
||||
while (current != null) {
|
||||
val cached = cache[current]
|
||||
if (cached != null) {
|
||||
@@ -148,12 +148,12 @@ private class PerFileAnalysisCache(val file: JetFile, val resolveSession: Resolv
|
||||
return result
|
||||
}
|
||||
|
||||
fun getAnalysisResults(element: JetElement): AnalyzeExhaust {
|
||||
fun getAnalysisResults(element: JetElement): AnalysisResult {
|
||||
assert (element.getContainingJetFile() == file, "Wrong file. Expected $file, but was ${element.getContainingJetFile()}")
|
||||
|
||||
val analyzableParent = KotlinResolveDataProvider.findAnalyzableParent(element)
|
||||
|
||||
return synchronized(this) { (): AnalyzeExhaust ->
|
||||
return synchronized(this) { (): AnalysisResult ->
|
||||
|
||||
val cached = lookUp(analyzableParent)
|
||||
if (cached != null) return@synchronized cached
|
||||
@@ -166,10 +166,10 @@ private class PerFileAnalysisCache(val file: JetFile, val resolveSession: Resolv
|
||||
}
|
||||
}
|
||||
|
||||
private fun analyze(analyzableElement: JetElement): AnalyzeExhaust {
|
||||
private fun analyze(analyzableElement: JetElement): AnalysisResult {
|
||||
val project = analyzableElement.getProject()
|
||||
if (DumbService.isDumb(project)) {
|
||||
return AnalyzeExhaust.EMPTY
|
||||
return AnalysisResult.EMPTY
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -182,7 +182,7 @@ private class PerFileAnalysisCache(val file: JetFile, val resolveSession: Resolv
|
||||
DiagnosticUtils.throwIfRunningOnServer(e)
|
||||
LOG.error(e)
|
||||
|
||||
return AnalyzeExhaust.error(BindingContext.EMPTY, e)
|
||||
return AnalysisResult.error(BindingContext.EMPTY, e)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -222,10 +222,10 @@ private object KotlinResolveDataProvider {
|
||||
?: element.getContainingJetFile()
|
||||
}
|
||||
|
||||
fun analyze(project: Project, resolveSession: ResolveSessionForBodies, analyzableElement: JetElement): AnalyzeExhaust {
|
||||
fun analyze(project: Project, resolveSession: ResolveSessionForBodies, analyzableElement: JetElement): AnalysisResult {
|
||||
try {
|
||||
if (analyzableElement is JetCodeFragment) {
|
||||
return AnalyzeExhaust.success(
|
||||
return AnalysisResult.success(
|
||||
analyzeExpressionCodeFragment(resolveSession, analyzableElement),
|
||||
resolveSession.getModuleDescriptor()
|
||||
)
|
||||
@@ -259,7 +259,7 @@ private object KotlinResolveDataProvider {
|
||||
),
|
||||
listOf(analyzableElement)
|
||||
)
|
||||
return AnalyzeExhaust.success(
|
||||
return AnalysisResult.success(
|
||||
trace.getBindingContext(),
|
||||
resolveSession.getModuleDescriptor()
|
||||
)
|
||||
@@ -271,7 +271,7 @@ private object KotlinResolveDataProvider {
|
||||
DiagnosticUtils.throwIfRunningOnServer(e)
|
||||
LOG.error(e)
|
||||
|
||||
return AnalyzeExhaust.error(BindingContext.EMPTY, e)
|
||||
return AnalysisResult.error(BindingContext.EMPTY, e)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.jetbrains.jet.plugin.caches.resolve
|
||||
|
||||
import org.jetbrains.jet.lang.psi.JetElement
|
||||
import org.jetbrains.jet.lang.psi.JetFile
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust
|
||||
import org.jetbrains.jet.analyzer.AnalysisResult
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||
import org.jetbrains.jet.lang.psi.JetDeclaration
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor
|
||||
@@ -28,7 +28,7 @@ public fun JetElement.getLazyResolveSession(): ResolutionFacade {
|
||||
return KotlinCacheService.getInstance(getProject()).getResolutionFacade(listOf(this))
|
||||
}
|
||||
|
||||
public fun JetElement.getAnalysisResults(vararg extraFiles: JetFile): AnalyzeExhaust {
|
||||
public fun JetElement.getAnalysisResults(vararg extraFiles: JetFile): AnalysisResult {
|
||||
return KotlinCacheService.getInstance(getProject()).getAnalysisResults(listOf(this) + extraFiles.toList())
|
||||
}
|
||||
|
||||
@@ -48,8 +48,8 @@ public fun JetElement.getBindingContext(): BindingContext {
|
||||
return getAnalysisResults().bindingContext
|
||||
}
|
||||
|
||||
public fun getAnalysisResultsForElements(elements: Collection<JetElement>): AnalyzeExhaust {
|
||||
if (elements.isEmpty()) return AnalyzeExhaust.EMPTY
|
||||
public fun getAnalysisResultsForElements(elements: Collection<JetElement>): AnalysisResult {
|
||||
if (elements.isEmpty()) return AnalysisResult.EMPTY
|
||||
val element = elements.first()
|
||||
return KotlinCacheService.getInstance(element.getProject()).getAnalysisResults(elements)
|
||||
}
|
||||
@@ -35,7 +35,7 @@ import com.intellij.xml.util.XmlStringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.analyzer.AnalysisResult;
|
||||
import org.jetbrains.jet.lang.diagnostics.Diagnostic;
|
||||
import org.jetbrains.jet.lang.diagnostics.Errors;
|
||||
import org.jetbrains.jet.lang.diagnostics.Severity;
|
||||
@@ -101,12 +101,12 @@ public class JetPsiChecker implements Annotator, HighlightRangeExtension {
|
||||
|
||||
JetFile file = (JetFile) element.getContainingFile();
|
||||
|
||||
AnalyzeExhaust analyzeExhaust = ResolvePackage.getAnalysisResults(file);
|
||||
if (analyzeExhaust.isError()) {
|
||||
throw new ProcessCanceledException(analyzeExhaust.getError());
|
||||
AnalysisResult analysisResult = ResolvePackage.getAnalysisResults(file);
|
||||
if (analysisResult.isError()) {
|
||||
throw new ProcessCanceledException(analysisResult.getError());
|
||||
}
|
||||
|
||||
BindingContext bindingContext = analyzeExhaust.getBindingContext();
|
||||
BindingContext bindingContext = analysisResult.getBindingContext();
|
||||
|
||||
for (HighlightingVisitor visitor : getAfterAnalysisVisitor(holder, bindingContext)) {
|
||||
element.accept(visitor);
|
||||
|
||||
@@ -38,7 +38,7 @@ import com.sun.jdi.request.ClassPrepareRequest;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.analyzer.AnalysisResult;
|
||||
import org.jetbrains.jet.codegen.AsmUtil;
|
||||
import org.jetbrains.jet.codegen.ClassBuilderFactories;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
@@ -326,11 +326,11 @@ public class JetPositionManager implements PositionManager {
|
||||
GlobalSearchScope packageFacadeScope = key.second.contentScope();
|
||||
Collection<JetFile> packageFiles = findFilesWithExactPackage(key.first, packageFacadeScope, project);
|
||||
|
||||
AnalyzeExhaust analyzeExhaust = ResolvePackage.getAnalysisResultsForElements(packageFiles);
|
||||
analyzeExhaust.throwIfError();
|
||||
AnalysisResult analysisResult = ResolvePackage.getAnalysisResultsForElements(packageFiles);
|
||||
analysisResult.throwIfError();
|
||||
|
||||
GenerationState state = new GenerationState(project, ClassBuilderFactories.THROW_EXCEPTION,
|
||||
analyzeExhaust.getModuleDescriptor(), analyzeExhaust.getBindingContext(),
|
||||
analysisResult.getModuleDescriptor(), analysisResult.getBindingContext(),
|
||||
new ArrayList<JetFile>(packageFiles)
|
||||
);
|
||||
state.beforeCompile();
|
||||
|
||||
@@ -280,17 +280,17 @@ class KotlinEvaluator(val codeFragment: JetCodeFragment,
|
||||
throw EvaluateExceptionUtil.createEvaluateException(e.getMessage())
|
||||
}
|
||||
|
||||
val analyzeExhaust = this.getAnalysisResults(createFlexibleTypesFile())
|
||||
if (analyzeExhaust.isError()) {
|
||||
throw EvaluateExceptionUtil.createEvaluateException(analyzeExhaust.error)
|
||||
val analysisResult = this.getAnalysisResults(createFlexibleTypesFile())
|
||||
if (analysisResult.isError()) {
|
||||
throw EvaluateExceptionUtil.createEvaluateException(analysisResult.error)
|
||||
}
|
||||
|
||||
val bindingContext = analyzeExhaust.bindingContext
|
||||
val bindingContext = analysisResult.bindingContext
|
||||
bindingContext.getDiagnostics().firstOrNull { it.getSeverity() == Severity.ERROR }?.let {
|
||||
throw EvaluateExceptionUtil.createEvaluateException(DefaultErrorMessages.RENDERER.render(it))
|
||||
}
|
||||
|
||||
analyzeExhaust
|
||||
analysisResult
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ import com.intellij.util.Alarm;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.OutputFile;
|
||||
import org.jetbrains.jet.OutputFileCollection;
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.analyzer.AnalysisResult;
|
||||
import org.jetbrains.jet.codegen.ClassBuilderFactories;
|
||||
import org.jetbrains.jet.codegen.CompilationErrorHandler;
|
||||
import org.jetbrains.jet.codegen.KotlinCodegenFacade;
|
||||
@@ -107,12 +107,12 @@ public class KotlinBytecodeToolWindow extends JPanel implements Disposable {
|
||||
|
||||
GenerationState state;
|
||||
try {
|
||||
AnalyzeExhaust exhaust = ResolvePackage.getAnalysisResults(jetFile);
|
||||
if (exhaust.isError()) {
|
||||
return printStackTraceToString(exhaust.getError());
|
||||
AnalysisResult result = ResolvePackage.getAnalysisResults(jetFile);
|
||||
if (result.isError()) {
|
||||
return printStackTraceToString(result.getError());
|
||||
}
|
||||
state = new GenerationState(jetFile.getProject(), ClassBuilderFactories.TEST, Progress.DEAF,
|
||||
exhaust.getModuleDescriptor(), exhaust.getBindingContext(),
|
||||
result.getModuleDescriptor(), result.getBindingContext(),
|
||||
Collections.singletonList(jetFile), !enableAssertions.isSelected(), !enableAssertions.isSelected(),
|
||||
GenerationState.GenerateClassFilter.GENERATE_ALL,
|
||||
!enableInline.isSelected(), !enableOptimization.isSelected(), null, null,
|
||||
|
||||
+3
-3
@@ -144,9 +144,9 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
|
||||
private val typeCandidates = HashMap<TypeInfo, List<TypeCandidate>>();
|
||||
|
||||
{
|
||||
val exhaust = config.currentFile.getAnalysisResults()
|
||||
currentFileContext = exhaust.bindingContext
|
||||
currentFileModule = exhaust.moduleDescriptor
|
||||
val result = config.currentFile.getAnalysisResults()
|
||||
currentFileContext = result.bindingContext
|
||||
currentFileModule = result.moduleDescriptor
|
||||
}
|
||||
|
||||
public var placement: CallablePlacement by Delegates.notNull()
|
||||
|
||||
+3
-3
@@ -66,15 +66,15 @@ object CreateParameterActionFactory: JetSingleIntentionActionFactory() {
|
||||
}
|
||||
|
||||
override fun createAction(diagnostic: Diagnostic): IntentionAction? {
|
||||
val exhaust = (diagnostic.getPsiFile() as? JetFile)?.getAnalysisResults() ?: return null
|
||||
val context = exhaust.bindingContext
|
||||
val result = (diagnostic.getPsiFile() as? JetFile)?.getAnalysisResults() ?: return null
|
||||
val context = result.bindingContext
|
||||
|
||||
val refExpr = QuickFixUtil.getParentElementOfType(diagnostic, javaClass<JetSimpleNameExpression>()) ?: return null
|
||||
if (refExpr.getQualifiedElement() != refExpr) return null
|
||||
|
||||
val varExpected = refExpr.getAssignmentByLHS() != null
|
||||
|
||||
val paramType = refExpr.getExpressionForTypeGuess().guessTypes(context, exhaust.moduleDescriptor).let {
|
||||
val paramType = refExpr.getExpressionForTypeGuess().guessTypes(context, result.moduleDescriptor).let {
|
||||
when (it.size) {
|
||||
0 -> KotlinBuiltIns.getInstance().getAnyType()
|
||||
1 -> it.first()
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.ConfigurationKind;
|
||||
import org.jetbrains.jet.JetLiteFixture;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.analyzer.AnalysisResult;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticFactory;
|
||||
import org.jetbrains.jet.lang.diagnostics.Diagnostic;
|
||||
@@ -82,8 +82,8 @@ public abstract class AbstractDiagnosticMessageTest extends JetLiteFixture {
|
||||
MessageType messageType = getMessageTypeDirective(directives);
|
||||
|
||||
JetFile psiFile = createPsiFile(null, fileName, loadFile(fileName));
|
||||
AnalyzeExhaust analyzeExhaust = JvmResolveUtil.analyzeOneFileWithJavaIntegration(psiFile);
|
||||
BindingContext bindingContext = analyzeExhaust.getBindingContext();
|
||||
AnalysisResult analysisResult = JvmResolveUtil.analyzeOneFileWithJavaIntegration(psiFile);
|
||||
BindingContext bindingContext = analysisResult.getBindingContext();
|
||||
|
||||
List<Diagnostic> diagnostics = ContainerUtil.filter(bindingContext.getDiagnostics().all(), new Condition<Diagnostic>() {
|
||||
@Override
|
||||
|
||||
@@ -23,7 +23,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.analyzer.AnalysisResult;
|
||||
import org.jetbrains.jet.context.ContextPackage;
|
||||
import org.jetbrains.jet.context.GlobalContextImpl;
|
||||
import org.jetbrains.jet.di.InjectorForTopDownAnalyzerForJs;
|
||||
@@ -58,7 +58,7 @@ public final class TopDownAnalyzerFacadeForJS {
|
||||
|
||||
//TODO: refactor
|
||||
@NotNull
|
||||
public static AnalyzeExhaust analyzeFiles(
|
||||
public static AnalysisResult analyzeFiles(
|
||||
@NotNull Collection<JetFile> files,
|
||||
@NotNull Predicate<PsiFile> filesToAnalyzeCompletely,
|
||||
@NotNull Config config
|
||||
@@ -91,7 +91,7 @@ public final class TopDownAnalyzerFacadeForJS {
|
||||
files :
|
||||
Config.withJsLibAdded(files, config);
|
||||
injector.getTopDownAnalyzer().analyzeFiles(topDownAnalysisParameters, allFiles);
|
||||
return AnalyzeExhaust.success(trace.getBindingContext(), owner);
|
||||
return AnalysisResult.success(trace.getBindingContext(), owner);
|
||||
}
|
||||
finally {
|
||||
injector.destroy();
|
||||
|
||||
+9
-9
@@ -23,7 +23,7 @@ import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.analyzer.AnalysisResult;
|
||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.psi.JetPsiFactory;
|
||||
@@ -44,7 +44,7 @@ public class LibrarySourcesConfigWithCaching extends LibrarySourcesConfig {
|
||||
Arrays.asList("@" + STDLIB_JS_MODULE_NAME, PathUtil.getKotlinPathsForDistDirectory().getJsLibJarPath().getAbsolutePath());
|
||||
|
||||
private static List<JetFile> jsLibFiles;
|
||||
private static AnalyzeExhaust exhaust;
|
||||
private static AnalysisResult result;
|
||||
|
||||
private BindingContext libraryContext;
|
||||
private ModuleDescriptor libraryModule;
|
||||
@@ -79,7 +79,7 @@ public class LibrarySourcesConfigWithCaching extends LibrarySourcesConfig {
|
||||
@Override
|
||||
public ModuleDescriptor getLibraryModule() {
|
||||
if (libraryModule == null) {
|
||||
libraryModule = getExhaust().getModuleDescriptor();
|
||||
libraryModule = getResult().getModuleDescriptor();
|
||||
}
|
||||
|
||||
return libraryModule;
|
||||
@@ -90,8 +90,8 @@ public class LibrarySourcesConfigWithCaching extends LibrarySourcesConfig {
|
||||
public BindingContext getLibraryContext() {
|
||||
if (libraryContext == null) {
|
||||
//TODO check errors?
|
||||
// TopDownAnalyzerFacadeForJS.checkForErrors(allLibFiles, exhaust.getBindingContext());
|
||||
libraryContext = getExhaust().getBindingContext();
|
||||
// TopDownAnalyzerFacadeForJS.checkForErrors(allLibFiles, result.getBindingContext());
|
||||
libraryContext = getResult().getBindingContext();
|
||||
}
|
||||
|
||||
return libraryContext;
|
||||
@@ -118,17 +118,17 @@ public class LibrarySourcesConfigWithCaching extends LibrarySourcesConfig {
|
||||
return jetFile;
|
||||
}
|
||||
|
||||
private AnalyzeExhaust getExhaust() {
|
||||
if (exhaust == null) {
|
||||
private AnalysisResult getResult() {
|
||||
if (result == null) {
|
||||
//noinspection AssignmentToStaticFieldFromInstanceMethod
|
||||
exhaust = TopDownAnalyzerFacadeForJS.analyzeFiles(
|
||||
result = TopDownAnalyzerFacadeForJS.analyzeFiles(
|
||||
generateLibFiles(),
|
||||
Predicates.<PsiFile>alwaysFalse(),
|
||||
createConfigWithoutLibFiles(getProject(), getModuleId(), getTarget())
|
||||
);
|
||||
}
|
||||
|
||||
return exhaust;
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.OutputFileCollection;
|
||||
import org.jetbrains.jet.SimpleOutputFile;
|
||||
import org.jetbrains.jet.SimpleOutputFileCollection;
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.analyzer.AnalysisResult;
|
||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
@@ -154,10 +154,10 @@ public final class K2JSTranslator {
|
||||
public JsProgram generateProgram(@NotNull List<JetFile> filesToTranslate,
|
||||
@NotNull MainCallParameters mainCallParameters)
|
||||
throws TranslationException {
|
||||
AnalyzeExhaust analyzeExhaust = TopDownAnalyzerFacadeForJS.analyzeFiles(filesToTranslate, Predicates.<PsiFile>alwaysTrue(), config);
|
||||
BindingContext bindingContext = analyzeExhaust.getBindingContext();
|
||||
AnalysisResult analysisResult = TopDownAnalyzerFacadeForJS.analyzeFiles(filesToTranslate, Predicates.<PsiFile>alwaysTrue(), config);
|
||||
BindingContext bindingContext = analysisResult.getBindingContext();
|
||||
TopDownAnalyzerFacadeForJS.checkForErrors(Config.withJsLibAdded(filesToTranslate, config), bindingContext);
|
||||
ModuleDescriptor moduleDescriptor = analyzeExhaust.getModuleDescriptor();
|
||||
ModuleDescriptor moduleDescriptor = analysisResult.getModuleDescriptor();
|
||||
return Translation.generateAst(bindingContext, filesToTranslate, mainCallParameters, moduleDescriptor, config);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user