AnalyzerFacadeWithCache simply redirects to KotlinCacheService now
This commit is contained in:
@@ -16,26 +16,11 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.plugin.project;
|
package org.jetbrains.jet.plugin.project;
|
||||||
|
|
||||||
import com.intellij.openapi.project.Project;
|
|
||||||
import com.intellij.psi.search.GlobalSearchScope;
|
|
||||||
import com.intellij.psi.util.CachedValue;
|
|
||||||
import com.intellij.psi.util.CachedValueProvider;
|
|
||||||
import com.intellij.psi.util.CachedValuesManager;
|
|
||||||
import com.intellij.psi.util.PsiModificationTracker;
|
|
||||||
import com.intellij.util.containers.SLRUCache;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.jetbrains.jet.analyzer.AnalyzerFacade;
|
|
||||||
import org.jetbrains.jet.lang.psi.JetElement;
|
import org.jetbrains.jet.lang.psi.JetElement;
|
||||||
import org.jetbrains.jet.lang.psi.JetFile;
|
import org.jetbrains.jet.lang.psi.JetFile;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
import org.jetbrains.jet.lang.resolve.java.JetFilesProvider;
|
import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage;
|
||||||
import org.jetbrains.jet.lang.resolve.lazy.ResolveSession;
|
|
||||||
import org.jetbrains.jet.plugin.caches.resolve.DeclarationsCacheProvider;
|
|
||||||
import org.jetbrains.jet.plugin.caches.resolve.KotlinCacheManager;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
public final class AnalyzerFacadeWithCache {
|
public final class AnalyzerFacadeWithCache {
|
||||||
|
|
||||||
@@ -50,55 +35,6 @@ public final class AnalyzerFacadeWithCache {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static ResolveSessionForBodies getLazyResolveSessionForFile(@NotNull JetFile file) {
|
public static ResolveSessionForBodies getLazyResolveSessionForFile(@NotNull JetFile file) {
|
||||||
Project project = file.getProject();
|
return ResolvePackage.getLazyResolveSession(file);
|
||||||
DeclarationsCacheProvider provider = KotlinCacheManager.getInstance(project).getRegisteredProvider(TargetPlatformDetector.getPlatform(file));
|
|
||||||
|
|
||||||
if (!provider.areDeclarationsAvailable(file)) {
|
|
||||||
// There can be request for temp files (in completion) or non-source (in library) files. Create temp sessions for them.
|
|
||||||
CachedValue<ResolveSessionForBodies> cachedValue;
|
|
||||||
|
|
||||||
synchronized (PER_FILE_SESSION_CACHE) {
|
|
||||||
cachedValue = PER_FILE_SESSION_CACHE.get(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
return cachedValue.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
return provider.getLazyResolveSession();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final SLRUCache<JetFile, CachedValue<ResolveSessionForBodies>> PER_FILE_SESSION_CACHE = new SLRUCache<JetFile, CachedValue<ResolveSessionForBodies>>(2, 3) {
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public CachedValue<ResolveSessionForBodies> createValue(final JetFile file) {
|
|
||||||
final Project fileProject = file.getProject();
|
|
||||||
return CachedValuesManager.getManager(fileProject).createCachedValue(
|
|
||||||
// Each value monitors OUT_OF_CODE_BLOCK_MODIFICATION_COUNT and modification tracker of the stored value
|
|
||||||
new CachedValueProvider<ResolveSessionForBodies>() {
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public Result<ResolveSessionForBodies> compute() {
|
|
||||||
Project project = file.getProject();
|
|
||||||
|
|
||||||
|
|
||||||
Collection<JetFile> files = new HashSet<JetFile>(JetFilesProvider.getInstance(project).allInScope(GlobalSearchScope.allScope(project)));
|
|
||||||
|
|
||||||
// Add requested file to the list of files for searching declarations
|
|
||||||
files.add(file);
|
|
||||||
|
|
||||||
if (file != file.getOriginalFile()) {
|
|
||||||
// Given file can be a non-physical copy of the file in list (completion case). Remove the prototype file.
|
|
||||||
|
|
||||||
//noinspection SuspiciousMethodCalls
|
|
||||||
files.remove(file.getOriginalFile());
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
true);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user