Fix searching for usages outside of roots model (namely in objective-c frameworks).

This commit is contained in:
Maxim Shafirov
2011-03-24 19:53:36 +03:00
parent 54015f44ac
commit 51f8fd98ba
2 changed files with 4 additions and 2 deletions
@@ -111,12 +111,13 @@ public class IndexCacheManagerImpl implements CacheManager{
if (vFiles.isEmpty()) return true;
final ProjectFileIndex index = ProjectRootManager.getInstance(myProject).getFileIndex();
final boolean globalScope = scope.isSearchOutsideRootModel();
final Processor<VirtualFile> virtualFileProcessor = new ReadActionProcessor<VirtualFile>() {
@Override
public boolean processInReadAction(VirtualFile virtualFile) {
LOG.assertTrue(virtualFile.isValid());
if (virtualFile.isValid() && scope.contains(virtualFile) && shouldBeFound(virtualFile, index)) {
if (virtualFile.isValid() && scope.contains(virtualFile) && (globalScope || shouldBeFound(virtualFile, index))) {
final PsiFile psiFile = myPsiManager.findFile(virtualFile);
return psiFile == null || psiFileProcessor.process(psiFile);
}
@@ -674,13 +674,14 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
final GlobalSearchScope commonScope,
final ProgressIndicator progress) {
final MultiMap<VirtualFile, RequestWithProcessor> local = createMultiMap();
final boolean inRootsOnly = !commonScope.isSearchOutsideRootModel();
ApplicationManager.getApplication().runReadAction(new Runnable() {
public void run() {
if (progress != null) progress.checkCanceled();
FileBasedIndex.getInstance().processValues(IdIndex.NAME, entry, null, new FileBasedIndex.ValueProcessor<Integer>() {
public boolean process(VirtualFile file, Integer value) {
if (progress != null) progress.checkCanceled();
if (!IndexCacheManagerImpl.shouldBeFound(file, index)) {
if (inRootsOnly && !IndexCacheManagerImpl.shouldBeFound(file, index)) {
return true;
}
int mask = value.intValue();