Rename: AnalyzeExhaust -> AnalysisResult

This commit is contained in:
Pavel V. Talanov
2014-11-20 17:29:09 +03:00
parent e4670a791d
commit bce399f5fd
33 changed files with 193 additions and 196 deletions
@@ -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
@@ -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);
}
});
@@ -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)
);