AnalyzerFacade.Setup introduced
This commit is contained in:
+2
-4
@@ -24,7 +24,6 @@ import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.analyzer.AnalyzerFacade;
|
||||
import org.jetbrains.jet.analyzer.AnalyzerFacadeForEverything;
|
||||
import org.jetbrains.jet.context.ContextPackage;
|
||||
import org.jetbrains.jet.context.GlobalContext;
|
||||
import org.jetbrains.jet.context.GlobalContextImpl;
|
||||
@@ -32,7 +31,6 @@ import org.jetbrains.jet.descriptors.serialization.descriptors.MemberFilter;
|
||||
import org.jetbrains.jet.di.InjectorForLazyResolveWithJava;
|
||||
import org.jetbrains.jet.di.InjectorForTopDownAnalyzerForJvm;
|
||||
import org.jetbrains.jet.lang.descriptors.DependencyKind;
|
||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.*;
|
||||
@@ -61,8 +59,8 @@ public enum AnalyzerFacadeForJVM implements AnalyzerFacade {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ResolveSession getLazyResolveSession(@NotNull Project fileProject, @NotNull Collection<JetFile> files) {
|
||||
return createLazyResolveSession(fileProject, files, new BindingTraceContext(), true);
|
||||
public Setup createSetup(@NotNull Project fileProject, @NotNull Collection<JetFile> files) {
|
||||
return new BasicSetup(createLazyResolveSession(fileProject, files, new BindingTraceContext(), true));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -25,8 +25,28 @@ import java.util.Collection;
|
||||
|
||||
public interface AnalyzerFacade {
|
||||
|
||||
interface Setup {
|
||||
@NotNull
|
||||
ResolveSession getLazyResolveSession();
|
||||
}
|
||||
|
||||
class BasicSetup implements Setup {
|
||||
|
||||
private final ResolveSession resolveSession;
|
||||
|
||||
public BasicSetup(@NotNull ResolveSession session) {
|
||||
resolveSession = session;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ResolveSession getLazyResolveSession() {
|
||||
return resolveSession;
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
ResolveSession getLazyResolveSession(
|
||||
Setup createSetup(
|
||||
@NotNull Project project,
|
||||
@NotNull Collection<JetFile> files
|
||||
);
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.intellij.psi.util.CachedValuesManager;
|
||||
import com.intellij.psi.util.PsiModificationTracker;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.analyzer.AnalyzerFacade;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.java.JetFilesProvider;
|
||||
import org.jetbrains.jet.lang.resolve.lazy.ResolveSession;
|
||||
@@ -71,7 +72,8 @@ public abstract class DeclarationsCacheProvider {
|
||||
@Override
|
||||
public synchronized Result<ResolveSessionForBodies> compute() {
|
||||
Collection<JetFile> files = JetFilesProvider.getInstance(project).allInScope(GlobalSearchScope.allScope(project));
|
||||
ResolveSession resolveSession = AnalyzerFacadeProvider.getAnalyzerFacade(platform).getLazyResolveSession(project, files);
|
||||
AnalyzerFacade facade = AnalyzerFacadeProvider.getAnalyzerFacade(platform);
|
||||
ResolveSession resolveSession = facade.createSetup(project, files).getLazyResolveSession();
|
||||
return Result.create(new ResolveSessionForBodies(project, resolveSession), PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ class KotlinCacheService(val project: Project) {
|
||||
val allFiles = JetFilesProvider.getInstance(project).allInScope(GlobalSearchScope.allScope(project))
|
||||
|
||||
val files = if (syntheticFile == null) allFiles else collectFilesForSyntheticFile(allFiles, syntheticFile)
|
||||
val resolveSession = AnalyzerFacadeProvider.getAnalyzerFacade(platform).getLazyResolveSession(project, files)
|
||||
val resolveSession = AnalyzerFacadeProvider.getAnalyzerFacade(platform).createSetup(project, files).getLazyResolveSession()
|
||||
CachedValueProvider.Result.create(ResolveSessionForBodies(project, resolveSession), PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT)
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.intellij.util.containers.SLRUCache;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.analyzer.AnalyzerFacade;
|
||||
import org.jetbrains.jet.lang.psi.JetElement;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
@@ -103,7 +104,8 @@ public final class AnalyzerFacadeWithCache {
|
||||
files.remove(file.getOriginalFile());
|
||||
}
|
||||
|
||||
ResolveSession resolveSession = AnalyzerFacadeProvider.getAnalyzerFacadeForFile(file).getLazyResolveSession(fileProject, files);
|
||||
AnalyzerFacade facade = AnalyzerFacadeProvider.getAnalyzerFacadeForFile(file);
|
||||
ResolveSession resolveSession = facade.createSetup(fileProject, files).getLazyResolveSession();
|
||||
return Result.create(new ResolveSessionForBodies(file, resolveSession), PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -20,7 +20,6 @@ import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.analyzer.AnalyzerFacade;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.lazy.ResolveSession;
|
||||
import org.jetbrains.k2js.analyze.AnalyzerFacadeForJS;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -34,7 +33,7 @@ public enum JSAnalyzerFacadeForIDEA implements AnalyzerFacade {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ResolveSession getLazyResolveSession(@NotNull Project project, @NotNull Collection<JetFile> files) {
|
||||
return AnalyzerFacadeForJS.getLazyResolveSession(files, new IDEAConfig(project));
|
||||
public Setup createSetup(@NotNull Project project, @NotNull Collection<JetFile> files) {
|
||||
return new BasicSetup(AnalyzerFacadeForJS.getLazyResolveSession(files, new IDEAConfig(project)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,8 +82,8 @@ public class JetRunConfigurationProducer extends RuntimeConfigurationProducer im
|
||||
PsiFile psiFile = location.getPsiElement().getContainingFile();
|
||||
if (psiFile instanceof JetFile) {
|
||||
JetFile jetFile = (JetFile) psiFile;
|
||||
AnalyzerFacade analyzerFacade = AnalyzerFacadeProvider.getAnalyzerFacadeForFile(jetFile);
|
||||
ResolveSession resolveSession = analyzerFacade.getLazyResolveSession(jetFile.getProject(), Collections.singleton(jetFile));
|
||||
AnalyzerFacade facade = AnalyzerFacadeProvider.getAnalyzerFacadeForFile(jetFile);
|
||||
ResolveSession resolveSession = facade.createSetup(jetFile.getProject(), Collections.singleton(jetFile)).getLazyResolveSession();
|
||||
MainFunctionDetector mainFunctionDetector = new MainFunctionDetector(resolveSession);
|
||||
if (mainFunctionDetector.hasMain(jetFile.getDeclarations())) {
|
||||
return jetFile;
|
||||
|
||||
Reference in New Issue
Block a user