register JavaResolveCache in JavaCoreEnvironment

This commit is contained in:
Dmitry Jemerov
2011-12-27 22:42:59 +01:00
parent 026079252b
commit 1e0714b310
2 changed files with 15 additions and 11 deletions
@@ -37,6 +37,7 @@ import com.intellij.psi.impl.compiled.ClassFileStubBuilder;
import com.intellij.psi.impl.compiled.ClsStubBuilderFactory;
import com.intellij.psi.impl.compiled.DefaultClsStubBuilderFactory;
import com.intellij.psi.impl.file.PsiPackageImplementationHelper;
import com.intellij.psi.impl.source.resolve.JavaResolveCache;
import com.intellij.psi.impl.source.resolve.PsiResolveHelperImpl;
import com.intellij.psi.impl.source.tree.CoreJavaASTFactory;
import com.intellij.psi.stubs.BinaryFileStubBuilders;
@@ -80,7 +81,8 @@ public class JavaCoreEnvironment extends CoreEnvironment {
myProject.registerService(PsiResolveHelper.class, new PsiResolveHelperImpl(myPsiManager));
myProject.registerService(LanguageLevelProjectExtension.class, new CoreLanguageLevelProjectExtension());
myProject.registerService(PackageIndex.class, myFileManager);
myProject.registerService(JavaResolveCache.class, new JavaResolveCache(null));
myApplication.registerService(EmptySubstitutor.class, new EmptySubstitutorImpl());
myApplication.registerService(JavaDirectoryService.class, new CoreJavaDirectoryService());
}
@@ -70,16 +70,18 @@ public class JavaResolveCache {
myVarToConstValueMapPhysical = new ConcurrentWeakHashMap<PsiVariable, Object>();
myVarToConstValueMapNonPhysical = new ConcurrentWeakHashMap<PsiVariable, Object>();
messageBus.connect().subscribe(PsiManagerImpl.ANY_PSI_CHANGE_TOPIC, new AnyPsiChangeListener() {
@Override
public void beforePsiChanged(boolean isPhysical) {
clearCaches(isPhysical);
}
@Override
public void afterPsiChanged(boolean isPhysical) {
}
});
if (messageBus != null) {
messageBus.connect().subscribe(PsiManagerImpl.ANY_PSI_CHANGE_TOPIC, new AnyPsiChangeListener() {
@Override
public void beforePsiChanged(boolean isPhysical) {
clearCaches(isPhysical);
}
@Override
public void afterPsiChanged(boolean isPhysical) {
}
});
}
}
private void clearCaches(boolean isPhysical) {