Support for files registered in Xcode project but residing out of content root
authorMaxim Shafirov <max@jetbrains.com>
Fri, 23 Sep 2011 17:57:54 +0000 (21:57 +0400)
committerMaxim Shafirov <max@jetbrains.com>
Fri, 23 Sep 2011 18:01:17 +0000 (22:01 +0400)
platform/core-api/src/com/intellij/openapi/roots/FileIndexFacade.java
platform/lang-impl/src/com/intellij/openapi/vcs/impl/ProjectFileIndexFacade.java
platform/lang-impl/src/com/intellij/psi/impl/cache/impl/IndexCacheManagerImpl.java
platform/lang-impl/src/com/intellij/psi/impl/search/PsiSearchHelperImpl.java
platform/vcs-impl/src/com/intellij/openapi/vcs/impl/DefaultFileIndexFacade.java

index e4250e898e4b446d21bdac34ab8b70c58a74d7d2..598954811b6abe60eda94f40093bf42c329fcf41 100644 (file)
@@ -15,6 +15,7 @@
  */
 package com.intellij.openapi.roots;
 
+import com.intellij.openapi.components.ServiceManager;
 import com.intellij.openapi.module.Module;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.vfs.VirtualFile;
@@ -30,9 +31,14 @@ public abstract class FileIndexFacade {
     myProject = project;
   }
 
+  public static FileIndexFacade getInstance(Project project) {
+    return ServiceManager.getService(project, FileIndexFacade.class);
+  }
+
   public abstract boolean isInContent(VirtualFile file);
   public abstract boolean isInSource(VirtualFile file);
   public abstract boolean isInLibraryClasses(VirtualFile file);
+  public abstract boolean isInLibrarySource(VirtualFile file);
   public abstract boolean isExcludedFile(VirtualFile file);
 
   @Nullable
index 9928dc2a960a8ae184146c6ea81a9e4b9238651f..bef825a4f88e4949e5d0ff237e9102ad3b0683cb 100644 (file)
@@ -51,6 +51,11 @@ public class ProjectFileIndexFacade extends FileIndexFacade {
     return myRootManager.getFileIndex().isInLibraryClasses(file);
   }
 
+  @Override
+  public boolean isInLibrarySource(VirtualFile file) {
+    return myRootManager.getFileIndex().isInLibrarySource(file);
+  }
+
   public boolean isExcludedFile(final VirtualFile file) {
     return myRootManager.getFileIndex().isIgnored(file);
   }
index ced908fd080c7432519f1d170aeae4ec0033d448..1801359bd76c416d1bac7b8c6e16474bb278f702 100644 (file)
@@ -24,6 +24,7 @@ import com.intellij.openapi.progress.ProcessCanceledException;
 import com.intellij.openapi.progress.ProgressManager;
 import com.intellij.openapi.project.IndexNotReadyException;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.roots.FileIndexFacade;
 import com.intellij.openapi.roots.ProjectFileIndex;
 import com.intellij.openapi.roots.ProjectRootManager;
 import com.intellij.openapi.vfs.VirtualFile;
@@ -72,7 +73,7 @@ public class IndexCacheManagerImpl implements CacheManager{
     return processor.getResults().isEmpty() ? PsiFile.EMPTY_ARRAY : processor.toArray(PsiFile.EMPTY_ARRAY);
   }
 
-  public static boolean shouldBeFound(GlobalSearchScope scope, VirtualFile virtualFile, ProjectFileIndex index) {
+  public static boolean shouldBeFound(GlobalSearchScope scope, VirtualFile virtualFile, FileIndexFacade index) {
     return (scope.isSearchOutsideRootModel() || index.isInContent(virtualFile) || index.isInLibrarySource(virtualFile)) && !virtualFile.getFileType().isBinary();
   }
 
@@ -104,7 +105,7 @@ public class IndexCacheManagerImpl implements CacheManager{
 
     if (vFiles.isEmpty()) return true;
 
-    final ProjectFileIndex index = ProjectRootManager.getInstance(myProject).getFileIndex();
+    final FileIndexFacade index = FileIndexFacade.getInstance(myProject);
 
     final Processor<VirtualFile> virtualFileProcessor = new ReadActionProcessor<VirtualFile>() {
       @Override
index 3812fabe709f227b88516c2664e6f251d6a62c21..d96b223146f6e826ba2cf2679ab21eed251678ef 100644 (file)
@@ -26,8 +26,7 @@ import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.progress.ProcessCanceledException;
 import com.intellij.openapi.progress.ProgressIndicator;
 import com.intellij.openapi.progress.ProgressManager;
-import com.intellij.openapi.roots.ProjectFileIndex;
-import com.intellij.openapi.roots.ProjectRootManager;
+import com.intellij.openapi.roots.FileIndexFacade;
 import com.intellij.openapi.util.Computable;
 import com.intellij.openapi.util.Ref;
 import com.intellij.openapi.util.TextRange;
@@ -656,7 +655,7 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
 
   private MultiMap<VirtualFile, RequestWithProcessor> collectFiles(MultiMap<Set<IdIndexEntry>, RequestWithProcessor> singles,
                                                                    ProgressIndicator progress) {
-    final ProjectFileIndex index = ProjectRootManager.getInstance(myManager.getProject()).getFileIndex();
+    final FileIndexFacade index = FileIndexFacade.getInstance(myManager.getProject());
     final MultiMap<VirtualFile, RequestWithProcessor> result = createMultiMap();
     for (Set<IdIndexEntry> key : singles.keySet()) {
       if (key.isEmpty()) {
@@ -707,7 +706,7 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
   }
 
   private static MultiMap<VirtualFile, RequestWithProcessor> findFilesWithIndexEntry(final IdIndexEntry entry,
-                                                                                     final ProjectFileIndex index,
+                                                                                     final FileIndexFacade index,
                                                                                      final Collection<RequestWithProcessor> data,
                                                                                      final GlobalSearchScope commonScope,
                                                                                      final ProgressIndicator progress) {
index 97c05132e651f283dc73549b5904e69cf9be51ae..e5b40d5e0cf2281298cd83dafe99eda6bc420ae2 100644 (file)
@@ -49,6 +49,11 @@ public class DefaultFileIndexFacade extends FileIndexFacade {
     return false;
   }
 
+  @Override
+  public boolean isInLibrarySource(VirtualFile file) {
+    return false;
+  }
+
   public boolean isExcludedFile(final VirtualFile file) {
     return false;
   }