Refactoring: Introduce EMPTY AnalyzeExhaust constant

This commit is contained in:
Nikolay Krasko
2013-08-15 18:07:43 +04:00
parent 58aaa2bc00
commit a4f452a943
2 changed files with 3 additions and 7 deletions
@@ -24,6 +24,7 @@ import org.jetbrains.jet.lang.resolve.BodiesResolveContext;
import org.jetbrains.jet.lang.types.ErrorUtils;
public class AnalyzeExhaust {
public static final AnalyzeExhaust EMPTY = success(BindingContext.EMPTY, ErrorUtils.getErrorModule());
public static AnalyzeExhaust success(@NotNull BindingContext bindingContext, @NotNull ModuleDescriptor module) {
return new AnalyzeExhaust(bindingContext, module, null, null);
@@ -69,6 +70,7 @@ public class AnalyzeExhaust {
@NotNull
public Throwable getError() {
if (error == null) throw new IllegalStateException("Should be called only for error analyze result");
return error;
}
@@ -45,7 +45,6 @@ import org.jetbrains.jet.lang.resolve.*;
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
import org.jetbrains.jet.lang.resolve.java.JetFilesProvider;
import org.jetbrains.jet.lang.resolve.lazy.ResolveSession;
import org.jetbrains.jet.lang.types.ErrorUtils;
import org.jetbrains.jet.plugin.caches.resolve.*;
import org.jetbrains.jet.plugin.util.ApplicationUtils;
@@ -162,13 +161,12 @@ public final class AnalyzerFacadeWithCache {
public AnalyzeExhaust createValue(JetFile file) {
try {
if (DumbService.isDumb(file.getProject())) {
return emptyExhaust();
return AnalyzeExhaust.EMPTY;
}
ApplicationUtils.warnTimeConsuming(LOG);
AnalyzeExhaust analyzeExhaustHeaders = analyzeHeadersWithCacheOnFile(file);
return analyzeBodies(analyzeExhaustHeaders, file);
}
catch (ProcessCanceledException e) {
@@ -183,10 +181,6 @@ public final class AnalyzerFacadeWithCache {
return Result.create(cache, PsiModificationTracker.MODIFICATION_COUNT);
}
private static AnalyzeExhaust emptyExhaust() {
return AnalyzeExhaust.success(BindingContext.EMPTY, ErrorUtils.getErrorModule());
}
private static AnalyzeExhaust analyzeHeadersWithCacheOnFile(@NotNull JetFile fileToCache) {
VirtualFile virtualFile = fileToCache.getVirtualFile();
if (LightClassUtil.belongsToKotlinBuiltIns(fileToCache) ||