当前位置: 首页>>代码示例>>Java>>正文


Java FileIndexFacade.getInstance方法代码示例

本文整理汇总了Java中com.intellij.openapi.roots.FileIndexFacade.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java FileIndexFacade.getInstance方法的具体用法?Java FileIndexFacade.getInstance怎么用?Java FileIndexFacade.getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.roots.FileIndexFacade的用法示例。


在下文中一共展示了FileIndexFacade.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: mapClass

import com.intellij.openapi.roots.FileIndexFacade; //导入方法依赖的package包/类
@Nullable
private PsiClass mapClass(@NotNull PsiClass psiClass) {
  String qualifiedName = psiClass.getQualifiedName();
  if (qualifiedName == null) {
    return psiClass;
  }

  PsiFile file = psiClass.getContainingFile();
  if (file == null || !file.getViewProvider().isPhysical()) {
    return psiClass;
  }

  final VirtualFile vFile = file.getVirtualFile();
  if (vFile == null) {
    return psiClass;
  }
  
  final FileIndexFacade index = FileIndexFacade.getInstance(file.getProject());
  if (!index.isInSource(vFile) && !index.isInLibrarySource(vFile) && !index.isInLibraryClasses(vFile)) {
    return psiClass;
  }

  return JavaPsiFacade.getInstance(psiClass.getProject()).findClass(qualifiedName, myResolveScope);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:TypeCorrector.java

示例2: getPsiClasses

import com.intellij.openapi.roots.FileIndexFacade; //导入方法依赖的package包/类
@NotNull
public static PsiClass[] getPsiClasses(@NotNull PsiDirectory dir, PsiFile[] psiFiles) {
  FileIndexFacade index = FileIndexFacade.getInstance(dir.getProject());
  VirtualFile virtualDir = dir.getVirtualFile();
  boolean onlyCompiled = index.isInLibraryClasses(virtualDir) && !index.isInSourceContent(virtualDir);

  List<PsiClass> classes = null;
  for (PsiFile file : psiFiles) {
    if (onlyCompiled && !(file instanceof ClsFileImpl)) {
      continue;
    }
    if (file instanceof PsiClassOwner && file.getViewProvider().getLanguages().size() == 1) {
      PsiClass[] psiClasses = ((PsiClassOwner)file).getClasses();
      if (psiClasses.length == 0) continue;
      if (classes == null) classes = new ArrayList<PsiClass>();
      ContainerUtil.addAll(classes, psiClasses);
    }
  }
  return classes == null ? PsiClass.EMPTY_ARRAY : classes.toArray(new PsiClass[classes.size()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:CoreJavaDirectoryService.java

示例3: processFilesContainingAllKeys

import com.intellij.openapi.roots.FileIndexFacade; //导入方法依赖的package包/类
private static boolean processFilesContainingAllKeys(@NotNull Project project,
                                                     @NotNull final GlobalSearchScope scope,
                                                     @Nullable final Condition<Integer> checker,
                                                     @NotNull final Collection<IdIndexEntry> keys,
                                                     @NotNull final Processor<VirtualFile> processor) {
  final FileIndexFacade index = FileIndexFacade.getInstance(project);
  return DumbService.getInstance(project).runReadActionInSmartMode(new Computable<Boolean>() {
    @Override
    public Boolean compute() {
      return FileBasedIndex.getInstance().processFilesContainingAllKeys(IdIndex.NAME, keys, scope, checker, new Processor<VirtualFile>() {
        @Override
        public boolean process(VirtualFile file) {
          return !index.shouldBeFound(scope, file) || processor.process(file);
        }
      });
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:PsiSearchHelperImpl.java

示例4: getClasses

import com.intellij.openapi.roots.FileIndexFacade; //导入方法依赖的package包/类
@NotNull
@Override
public PsiClass[] getClasses(@NotNull PsiDirectory dir) {
  LOG.assertTrue(dir.isValid());

  FileIndexFacade index = FileIndexFacade.getInstance(dir.getProject());
  VirtualFile virtualDir = dir.getVirtualFile();
  boolean onlyCompiled = index.isInLibraryClasses(virtualDir) && !index.isInSourceContent(virtualDir);

  List<PsiClass> classes = null;
  for (PsiFile file : dir.getFiles()) {
    if (onlyCompiled && !(file instanceof ClsFileImpl)) {
      continue;
    }
    if (file instanceof PsiClassOwner && file.getViewProvider().getLanguages().size() == 1) {
      PsiClass[] psiClasses = ((PsiClassOwner)file).getClasses();
      if (psiClasses.length == 0) continue;
      if (classes == null) classes = new ArrayList<PsiClass>();
      ContainerUtil.addAll(classes, psiClasses);
    }
  }
  return classes == null ? PsiClass.EMPTY_ARRAY : classes.toArray(new PsiClass[classes.size()]);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:24,代码来源:CoreJavaDirectoryService.java

示例5: processFilesWithText

import com.intellij.openapi.roots.FileIndexFacade; //导入方法依赖的package包/类
public boolean processFilesWithText(@NotNull final GlobalSearchScope scope,
                                    final short searchContext,
                                    final boolean caseSensitively,
                                    @NotNull String text,
                                    @NotNull final Processor<VirtualFile> processor) {
  List<IdIndexEntry> entries = getWordEntries(text, caseSensitively);
  if (entries.isEmpty()) return true;

  final CommonProcessors.CollectProcessor<VirtualFile> collectProcessor = new CommonProcessors.CollectProcessor<VirtualFile>();
  processFilesContainingAllKeys(scope, new Condition<Integer>() {
    @Override
    public boolean value(Integer integer) {
      return (integer.intValue() & searchContext) != 0;
    }
  }, collectProcessor, entries);

  final FileIndexFacade index = FileIndexFacade.getInstance(myManager.getProject());
  return ContainerUtil.process(collectProcessor.getResults(), new ReadActionProcessor<VirtualFile>() {
    @Override
    public boolean processInReadAction(VirtualFile virtualFile) {
      return !index.shouldBeFound(scope, virtualFile) || processor.process(virtualFile);
    }
  });
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:25,代码来源:PsiSearchHelperImpl.java

示例6: getClassNames

import com.intellij.openapi.roots.FileIndexFacade; //导入方法依赖的package包/类
@NotNull
@Override
public Set<String> getClassNames(@NotNull PsiPackage psiPackage, @NotNull GlobalSearchScope scope) {
  Set<String> names = null;
  FileIndexFacade facade = FileIndexFacade.getInstance(myProject);
  for (PsiDirectory dir : psiPackage.getDirectories(scope)) {
    for (PsiFile file : dir.getFiles()) {
      if (file instanceof PsiClassOwner && file.getViewProvider().getLanguages().size() == 1) {
        VirtualFile vFile = file.getVirtualFile();
        if (vFile != null &&
            !(file instanceof PsiCompiledElement) &&
            !facade.isInSourceContent(vFile) &&
            (!scope.isForceSearchingInLibrarySources() || !StubTreeLoader.getInstance().canHaveStub(vFile))) {
          continue;
        }

        Set<String> inFile =
          file instanceof PsiClassOwnerEx ? ((PsiClassOwnerEx)file).getClassNames() : getClassNames(((PsiClassOwner)file).getClasses());

        if (inFile.isEmpty()) continue;
        if (names == null) names = new HashSet<String>();
        names.addAll(inFile);
      }
    }

  }
  return names == null ? Collections.<String>emptySet() : names;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:PsiElementFinderImpl.java

示例7: checkClassUnderSources

import com.intellij.openapi.roots.FileIndexFacade; //导入方法依赖的package包/类
private boolean checkClassUnderSources(final PsiElement element, final Project project) {
  final PsiFile file = element.getContainingFile();
  if (file != null && file.getVirtualFile() != null) {
    final FileIndexFacade indexFacade = FileIndexFacade.getInstance(project);
    final VirtualFile vf = file.getVirtualFile();
    return indexFacade.isInSource(vf) || indexFacade.isInSourceContent(vf);
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:PsiClassFavoriteNodeProvider.java

示例8: getPsiFile

import com.intellij.openapi.roots.FileIndexFacade; //导入方法依赖的package包/类
/**
 * Tries to find PSI file for a virtual file and throws assertion error with debug info if it is null.
 */
@NotNull
public static PsiFile getPsiFile(@NotNull Project project, @NotNull VirtualFile file) {
  PsiManager psiManager = PsiManager.getInstance(project);
  PsiFile psi = psiManager.findFile(file);
  if (psi != null) return psi;
  FileType fileType = file.getFileType();
  FileViewProvider viewProvider = psiManager.findViewProvider(file);
  Document document = FileDocumentManager.getInstance().getDocument(file);
  boolean ignored = !(file instanceof LightVirtualFile) && FileTypeRegistry.getInstance().isFileIgnored(file);
  VirtualFile vDir = file.getParent();
  PsiDirectory psiDir = vDir == null ? null : PsiManager.getInstance(project).findDirectory(vDir);
  FileIndexFacade indexFacade = FileIndexFacade.getInstance(project);
  StringBuilder sb = new StringBuilder();
  sb.append("valid=").append(file.isValid()).
    append(" isDirectory=").append(file.isDirectory()).
    append(" hasDocument=").append(document != null).
    append(" length=").append(file.getLength());
  sb.append("\nproject=").append(project.getName()).
    append(" default=").append(project.isDefault()).
    append(" open=").append(project.isOpen());;
  sb.append("\nfileType=").append(fileType.getName()).append("/").append(fileType.getClass().getName());
  sb.append("\nisIgnored=").append(ignored);
  sb.append(" underIgnored=").append(indexFacade.isUnderIgnored(file));
  sb.append(" inLibrary=").append(indexFacade.isInLibrarySource(file) || indexFacade.isInLibraryClasses(file));
  sb.append(" parentDir=").append(vDir == null ? "no-vfs" : vDir.isDirectory() ? "has-vfs-dir" : "has-vfs-file").
    append("/").append(psiDir == null ? "no-psi" : "has-psi");
  sb.append("\nviewProvider=").append(viewProvider == null ? "null" : viewProvider.getClass().getName());
  if (viewProvider != null) {
    List<PsiFile> files = viewProvider.getAllFiles();
    sb.append(" language=").append(viewProvider.getBaseLanguage().getID());
    sb.append(" physical=").append(viewProvider.isPhysical());
    sb.append(" rootCount=").append(files.size());
    for (PsiFile o : files) {
      sb.append("\n  root=").append(o.getLanguage().getID()).append("/").append(o.getClass().getName());
    }
  }
  LOG.error("no PSI for file '" + file.getName() + "'", new Attachment(file.getPresentableUrl(), sb.toString()));
  throw new AssertionError();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:43,代码来源:PsiUtilCore.java

示例9: buildProjectScope

import com.intellij.openapi.roots.FileIndexFacade; //导入方法依赖的package包/类
@NotNull
@Override
public GlobalSearchScope buildProjectScope() {
  final ProjectRootManager projectRootManager = ProjectRootManager.getInstance(myProject);
  if (projectRootManager == null) {
    return new EverythingGlobalScope(myProject) {
      @Override
      public boolean isSearchInLibraries() {
        return false;
      }
    };
  }
  return new ProjectScopeImpl(myProject, FileIndexFacade.getInstance(myProject));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:ProjectScopeBuilderImpl.java

示例10: buildProjectScope

import com.intellij.openapi.roots.FileIndexFacade; //导入方法依赖的package包/类
/**
 * Project directories are commonly included in PYTHONPATH and as a result are listed as library classes. Core logic
 * includes them in project scope only if they are also marked as source roots. Python code is often not marked as source
 * root, so we need to override the core logic and check only whether the file is under project content.
 *
 * @return project search scope
 */
@NotNull
@Override
public GlobalSearchScope buildProjectScope() {
  final FileIndexFacade fileIndex = FileIndexFacade.getInstance(myProject);
  return new ProjectScopeImpl(myProject, fileIndex) {
    @Override
    public boolean contains(@NotNull VirtualFile file) {
      if (file instanceof VirtualFileWindow) return true;
      return fileIndex.isInContent(file);
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:PyProjectScopeBuilder.java

示例11: isInSourceFiles

import com.intellij.openapi.roots.FileIndexFacade; //导入方法依赖的package包/类
private static boolean isInSourceFiles(@Nullable VirtualFile file, @NotNull Project project) {
  if (file != null && !(file instanceof LightVirtualFile)) {
    final FileIndexFacade index = FileIndexFacade.getInstance(project);
    if (index.isInSource(file) || index.isInLibraryClasses(file)) {
      return true;
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:GrFileIndexUtil.java

示例12: filterOutIgnored

import com.intellij.openapi.roots.FileIndexFacade; //导入方法依赖的package包/类
@NotNull
private static Collection<VirtualFile> filterOutIgnored(
    @NotNull Project project, @NotNull Collection<VirtualFile> files) {
  final ChangeListManager changeListManager = ChangeListManager.getInstance(project);
  final FileIndexFacade fileIndex = FileIndexFacade.getInstance(project);
  return Collections2.filter(
      files, file -> !changeListManager.isIgnoredFile(file) && !fileIndex.isExcludedFile(file));
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:9,代码来源:SetupCloudRepositoryAction.java

示例13: getClassNames

import com.intellij.openapi.roots.FileIndexFacade; //导入方法依赖的package包/类
@NotNull
@Override
public Set<String> getClassNames(@NotNull PsiPackage psiPackage, @NotNull GlobalSearchScope scope) {
  Set<String> names = null;
  FileIndexFacade facade = FileIndexFacade.getInstance(myProject);
  for (PsiDirectory dir : psiPackage.getDirectories(scope)) {
    for (PsiFile file : dir.getFiles()) {
      if (file instanceof PsiClassOwner && file.getViewProvider().getLanguages().size() == 1) {
        VirtualFile vFile = file.getVirtualFile();
        if (vFile != null &&
            !(file instanceof PsiCompiledElement) &&
            !facade.isInSourceContent(vFile) &&
            (!scope.isForceSearchingInLibrarySources() ||
             !StubTreeLoader.getInstance().canHaveStub(vFile))) {
          continue;
        }

        Set<String> inFile = file instanceof PsiClassOwnerEx ? ((PsiClassOwnerEx)file).getClassNames() : getClassNames(((PsiClassOwner)file).getClasses());

        if (inFile.isEmpty()) continue;
        if (names == null) names = new HashSet<String>();
        names.addAll(inFile);
      }
    }

  }
  return names == null ? Collections.<String>emptySet() : names;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:29,代码来源:JavaPsiFacadeImpl.java

示例14: isCheapEnoughToSearch

import com.intellij.openapi.roots.FileIndexFacade; //导入方法依赖的package包/类
@NotNull
@Override
public SearchCostResult isCheapEnoughToSearch(@NotNull String name,
                                              @NotNull final GlobalSearchScope scope,
                                              @Nullable final PsiFile fileToIgnoreOccurencesIn,
                                              @Nullable final ProgressIndicator progress) {
  final AtomicInteger count = new AtomicInteger();
  final FileIndexFacade index = FileIndexFacade.getInstance(myManager.getProject());
  final Processor<VirtualFile> processor = new Processor<VirtualFile>() {
    private final VirtualFile fileToIgnoreOccurencesInVirtualFile =
      fileToIgnoreOccurencesIn != null ? fileToIgnoreOccurencesIn.getVirtualFile() : null;

    @Override
    public boolean process(VirtualFile file) {
      if (progress != null) progress.checkCanceled();
      if (Comparing.equal(file, fileToIgnoreOccurencesInVirtualFile)) return true;
      if (!index.shouldBeFound(scope, file)) return true;
      final int value = count.incrementAndGet();
      return value < 10;
    }
  };
  List<IdIndexEntry> keys = getWordEntries(name, true);
  boolean cheap = keys.isEmpty() || processFilesContainingAllKeys(scope, null, processor, keys);

  if (!cheap) {
    return SearchCostResult.TOO_MANY_OCCURRENCES;
  }

  return count.get() == 0 ? SearchCostResult.ZERO_OCCURRENCES : SearchCostResult.FEW_OCCURRENCES;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:31,代码来源:PsiSearchHelperImpl.java

示例15: getPsiFile

import com.intellij.openapi.roots.FileIndexFacade; //导入方法依赖的package包/类
/**
 * Tries to find PSI file for a virtual file and throws assertion error with debug info if it is null.
 */
@Nonnull
public static PsiFile getPsiFile(@Nonnull Project project, @Nonnull VirtualFile file) {
  PsiManager psiManager = PsiManager.getInstance(project);
  PsiFile psi = psiManager.findFile(file);
  if (psi != null) return psi;
  FileType fileType = file.getFileType();
  FileViewProvider viewProvider = psiManager.findViewProvider(file);
  Document document = FileDocumentManager.getInstance().getDocument(file);
  boolean ignored = !(file instanceof LightVirtualFile) && FileTypeRegistry.getInstance().isFileIgnored(file);
  VirtualFile vDir = file.getParent();
  PsiDirectory psiDir = vDir == null ? null : PsiManager.getInstance(project).findDirectory(vDir);
  FileIndexFacade indexFacade = FileIndexFacade.getInstance(project);
  StringBuilder sb = new StringBuilder();
  sb.append("valid=").append(file.isValid()).
          append(" isDirectory=").append(file.isDirectory()).
          append(" hasDocument=").append(document != null).
          append(" length=").append(file.getLength());
  sb.append("\nproject=").append(project.getName()).
          append(" default=").append(project.isDefault()).
          append(" open=").append(project.isOpen());;
  sb.append("\nfileType=").append(fileType.getName()).append("/").append(fileType.getClass().getName());
  sb.append("\nisIgnored=").append(ignored);
  sb.append(" underIgnored=").append(indexFacade.isUnderIgnored(file));
  sb.append(" inLibrary=").append(indexFacade.isInLibrarySource(file) || indexFacade.isInLibraryClasses(file));
  sb.append(" parentDir=").append(vDir == null ? "no-vfs" : vDir.isDirectory() ? "has-vfs-dir" : "has-vfs-file").
          append("/").append(psiDir == null ? "no-psi" : "has-psi");
  sb.append("\nviewProvider=").append(viewProvider == null ? "null" : viewProvider.getClass().getName());
  if (viewProvider != null) {
    List<PsiFile> files = viewProvider.getAllFiles();
    sb.append(" language=").append(viewProvider.getBaseLanguage().getID());
    sb.append(" physical=").append(viewProvider.isPhysical());
    sb.append(" rootCount=").append(files.size());
    for (PsiFile o : files) {
      sb.append("\n  root=").append(o.getLanguage().getID()).append("/").append(o.getClass().getName());
    }
  }
  LOG.error("no PSI for file '" + file.getName() + "'", new Attachment(file.getPresentableUrl(), sb.toString()));
  throw new AssertionError();
}
 
开发者ID:consulo,项目名称:consulo,代码行数:43,代码来源:PsiUtilCore.java


注:本文中的com.intellij.openapi.roots.FileIndexFacade.getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。