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


Java ProjectFileIndex.isInContent方法代码示例

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


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

示例1: getAdditionalResolveScope

import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
@Override
public SearchScope getAdditionalResolveScope(@NotNull VirtualFile file, Project project) {
  ProjectFileIndex index = ProjectFileIndex.SERVICE.getInstance(project);
  if (index.isInLibraryClasses(file) || index.isInContent(file)) {
    return null;
  }

  String fileExtension = file.getExtension();
  if ("class".equals(fileExtension) || JavaFileType.DEFAULT_EXTENSION.equals(fileExtension)) {
    for (PsiElementFinder finder : Extensions.getExtensions(PsiElementFinder.EP_NAME, project)) {
      if (finder instanceof NonClasspathClassFinder) {
        final List<VirtualFile> roots = ((NonClasspathClassFinder)finder).getClassRoots();
        for (VirtualFile root : roots) {
          if (VfsUtilCore.isAncestor(root, file, true)) {
            return NonClasspathDirectoriesScope.compose(roots);
          }
        }
      }
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:NonClasspathResolveScopeEnlarger.java

示例2: getPromptToMoveDirectoryLibrariesSafe

import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
@Nullable
private static String getPromptToMoveDirectoryLibrariesSafe(PsiElement[] elements) {
  if (elements.length == 0 || elements.length > 1) return null;
  final Project project = elements[0].getProject();
  final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
  if (!(elements[0] instanceof PsiDirectory)) return null;
  final PsiDirectory directory = ((PsiDirectory)elements[0]);
  if (RefactoringUtil.isSourceRoot(directory)) {
    return null;
  }
  final PsiPackage aPackage = JavaDirectoryService.getInstance().getPackage(directory);
  if (aPackage == null) return null;
  if ("".equals(aPackage.getQualifiedName())) return null;
  final PsiDirectory[] directories = aPackage.getDirectories();

  boolean inLib = false;
  for (PsiDirectory psiDirectory : directories) {
    inLib |= !fileIndex.isInContent(psiDirectory.getVirtualFile());
  }

  return inLib ? "Package \'" +
                 aPackage.getName() +
                 "\' contains directories in libraries which cannot be moved. Do you want to move current directory" : null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:JavaMoveClassesOrPackagesHandler.java

示例3: isVersioned

import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
public boolean isVersioned(@NotNull VirtualFile f, boolean shouldBeInContent) {
  if (!f.isInLocalFileSystem()) return false;

  if (!f.isDirectory() && StringUtil.endsWith(f.getNameSequence(), ".class")) return false;

  Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
  boolean isInContent = false;
  for (Project each : openProjects) {
    if (each.isDefault()) continue;
    if (!each.isInitialized()) continue;
    if (Comparing.equal(each.getWorkspaceFile(), f)) return false;
    ProjectFileIndex index = ProjectRootManager.getInstance(each).getFileIndex();
    
    if (index.isExcluded(f)) return false;
    isInContent |= index.isInContent(f);
  }
  if (shouldBeInContent && !isInContent) return false;
  
  // optimisation: FileTypeManager.isFileIgnored(f) already checked inside ProjectFileIndex.isIgnored()
  return openProjects.length != 0 || !FileTypeManager.getInstance().isFileIgnored(f);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:IdeaGateway.java

示例4: getScope

import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
@Nullable
private AnalysisScope getScope() {
  final Set<PsiFile> selectedScope = getSelectedScope(myRightTree);
  Set<PsiFile> result = new HashSet<PsiFile>();
  ((PackageDependenciesNode)myLeftTree.getModel().getRoot()).fillFiles(result, !mySettings.UI_FLATTEN_PACKAGES);
  selectedScope.removeAll(result);
  if (selectedScope.isEmpty()) return null;
  List<VirtualFile> files = new ArrayList<VirtualFile>();
  final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
  for (PsiFile psiFile : selectedScope) {
    final VirtualFile file = psiFile.getVirtualFile();
    LOG.assertTrue(file != null);
    if (fileIndex.isInContent(file)) {
      files.add(file);
    }
  }
  if (!files.isEmpty()) {
    return new AnalysisScope(myProject, files);
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:DependenciesPanel.java

示例5: filterElements

import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
@Override
public boolean filterElements(@NotNull ChooseByNameBase base,
                              @NotNull String pattern,
                              boolean everywhere,
                              @NotNull ProgressIndicator indicator,
                              @NotNull Processor<Object> consumer) {
  if (pattern.contains("/") || pattern.contains("\\")) {
    String path = FileUtil.toSystemIndependentName(ChooseByNamePopup.getTransformedPattern(pattern, myModel));
    VirtualFile vFile = LocalFileSystem.getInstance().findFileByPathIfCached(path);
    if (vFile != null) {
      ProjectFileIndex index = ProjectFileIndex.SERVICE.getInstance(myProject);
      if (index.isInContent(vFile) || index.isInLibraryClasses(vFile) || index.isInLibrarySource(vFile)) {
        PsiFileSystemItem fileOrDir = vFile.isDirectory() ?
                                      PsiManager.getInstance(myProject).findDirectory(vFile) :
                                      PsiManager.getInstance(myProject).findFile(vFile);
        if (fileOrDir != null && !consumer.process(fileOrDir)) {
          return false;
        }
      }
    }
  }

  return super.filterElements(base, pattern, everywhere, indicator, consumer);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:GotoFileItemProvider.java

示例6: selectDirectory

import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
@Nullable
public static PsiDirectory selectDirectory(Project project,
                                           PsiDirectory[] packageDirectories,
                                           PsiDirectory defaultDirectory,
                                           String postfixToShow) {
  ProjectFileIndex projectFileIndex = getInstance(project).getFileIndex();

  ArrayList<PsiDirectory> possibleDirs = new ArrayList<PsiDirectory>();
  for (PsiDirectory dir : packageDirectories) {
    if (!dir.isValid()) continue;
    if (!dir.isWritable()) continue;
    if (possibleDirs.contains(dir)) continue;
    if (!projectFileIndex.isInContent(dir.getVirtualFile())) continue;
    possibleDirs.add(dir);
  }

  if (possibleDirs.isEmpty()) return null;
  if (possibleDirs.size() == 1) return possibleDirs.get(0);

  if (getApplication().isUnitTestMode()) return possibleDirs.get(0);

  DirectoryChooser chooser = new DirectoryChooser(project);
  chooser.setTitle(message("title.choose.destination.directory"));
  chooser.fillList(possibleDirs.toArray(new PsiDirectory[possibleDirs.size()]), defaultDirectory, project, postfixToShow);
  return chooser.showAndGet() ? chooser.getSelectedDirectory() : null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:DirectoryChooserUtil.java

示例7: contains

import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
/** Copy of {@link com.intellij.ide.projectView.impl.nodes.AbstractProjectNode#contains(com.intellij.openapi.vfs.VirtualFile)}*/
@Override
public boolean contains(@NotNull VirtualFile file) {
  ProjectFileIndex index = ProjectRootManager.getInstance(getProject()).getFileIndex();
  final VirtualFile baseDir = getProject().getBaseDir();
  return index.isInContent(file) || index.isInLibraryClasses(file) || index.isInLibrarySource(file) ||
         (baseDir != null && VfsUtilCore.isAncestor(baseDir, file, false));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:AndroidViewProjectNode.java

示例8: getResolveScope

import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
@Nullable
@Override
public GlobalSearchScope getResolveScope(@NotNull VirtualFile file, Project project) {
  // For java only! For other languages resolve may be implemented with different rules, requiring larger scope.
  final FileType type = file.getFileType();
  if (type instanceof LanguageFileType && ((LanguageFileType)type).getLanguage() == JavaLanguage.INSTANCE) {
    ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex();
    if (index.isInContent(file) && !index.isInSource(file)) {
      return GlobalSearchScope.fileScope(project, file);
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:JavaOutOfSourcesResolveScopeProvider.java

示例9: tokenize

import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
@Override
public void tokenize(@NotNull PsiTypeElement element, TokenConsumer consumer) {
  final PsiType type = element.getType();
  if (type instanceof PsiDisjunctionType) {
    tokenizeComplexType(element, consumer);
    return;
  }

  final PsiClass psiClass = PsiUtil.resolveClassInType(type);

  if (psiClass == null || psiClass.getContainingFile() == null || psiClass.getContainingFile().getVirtualFile() == null) {
    return;
  }

  final String name = psiClass.getName();
  if (name == null) {
    return;
  }

  final VirtualFile virtualFile = psiClass.getContainingFile().getVirtualFile();

  final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(element.getProject()).getFileIndex();

  final boolean isInSource = (virtualFile != null) && fileIndex.isInContent(virtualFile);
  if (isInSource) {
    final String elementText = element.getText();
    if (elementText.contains(name)) {
      consumer.consumeToken(element, elementText, true, 0, getRangeToCheck(elementText, name), IdentifierSplitter.getInstance());
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:PsiTypeTokenizer.java

示例10: canSelect

import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
@Override
public boolean canSelect(final SelectInContext context) {
  final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(context.getProject()).getFileIndex();
  final VirtualFile file = context.getVirtualFile();
  if (file instanceof WrappingVirtualFile) {
    final Object o = ((WrappingVirtualFile)file).getWrappedObject(context.getProject());
    return o instanceof Facet;
  }
  return fileIndex.isInContent(file) || fileIndex.isInLibraryClasses(file) || fileIndex.isInLibrarySource(file)
         || StdFileTypes.IDEA_MODULE.equals(file.getFileType()) && findModuleByModuleFile(context.getProject(), file) != null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:ProjectStructureSelectInTarget.java

示例11: findSuitableFilesFor

import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
public static List<VirtualFile> findSuitableFilesFor(final String filePath, final Project project) {
  final ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex();

  // at first let's try to find file as is, by it's real path
  // and check that file belongs to current project
  // this location provider designed for tests thus we will check only project content
  // (we cannot check just sources or tests folders because RM doesn't use it
  final VirtualFile file = getByFullPath(filePath);
  final boolean inProjectContent = file != null && (index.isInContent(file));

  if (inProjectContent) {
    return Collections.singletonList(file);
  }

  //split file by "/" in parts
  final LinkedList<String> folders = new LinkedList<String>();
  final StringTokenizer st = new StringTokenizer(filePath, "/", false);
  String fileName = null;
  while (st.hasMoreTokens()) {
    final String pathComponent = st.nextToken();
    if (st.hasMoreTokens()) {
      folders.addFirst(pathComponent);
    } else {
      // last token
      fileName = pathComponent;
    }
  }
  if (fileName == null) {
    return Collections.emptyList();
  }
  final List<VirtualFile> target = findFilesClosestToTarget(folders, collectCandidates(project, fileName, true), MIN_PROXIMITY_THRESHOLD);
  return target.isEmpty() && file != null ? Collections.singletonList(file) : target;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:TestsLocationProviderUtil.java

示例12: isProjectFile

import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
private static boolean isProjectFile(@NotNull VirtualFile file, @NotNull Project project) {
  ProjectFileIndex fileIndex = ProjectFileIndex.SERVICE.getInstance(project);
  if (fileIndex.isInContent(file)) return true;
  if (!Registry.is("ide.hide.excluded.files") && fileIndex.isExcluded(file) && !fileIndex.isUnderIgnored(file)) return true;
  
  if (project instanceof ProjectEx && !project.isDefault()) {
    if (ProjectUtil.isDirectoryBased(project)) {
      VirtualFile baseDir = project.getBaseDir();
      VirtualFile dotIdea = baseDir == null ? null : baseDir.findChild(Project.DIRECTORY_STORE_FOLDER);
      if (dotIdea != null && VfsUtilCore.isAncestor(dotIdea, file, false)) return true;
    }

    IProjectStore store = (IProjectStore)ServiceKt.getStateStore(project);
    String filePath = file.getPath();
    if (FileUtil.namesEqual(filePath, store.getWorkspaceFilePath()) || FileUtil.namesEqual(filePath, store.getProjectFilePath())) {
      return true;
    }
    for (Module module : ModuleManager.getInstance(project).getModules()) {
      if (FileUtil.namesEqual(filePath, module.getModuleFilePath())) {
        return true;
      }
    }
  }

  for (NonProjectFileWritingAccessExtension each : Extensions.getExtensions(NonProjectFileWritingAccessExtension.EP_NAME, project)) {
    if(each.isWritable(file)) return true;
  }

  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:NonProjectFileWritingAccessProvider.java

示例13: isInSet

import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
@Override
public boolean isInSet(@NotNull final VirtualFile file) {
  final ProjectFileIndex index = myRootManager.getFileIndex();
  if (index.isInContent(file) || index.isInLibraryClasses(file) || index.isInLibrarySource(file)) {
    return !myFileTypeManager.isFileIgnored(file);
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:FileBasedIndexProjectHandler.java

示例14: getTopLevelRoots

import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
public List<VirtualFile> getTopLevelRoots() {
  List<VirtualFile> topLevelContentRoots = new ArrayList<VirtualFile>();
  ProjectRootManager prm = ProjectRootManager.getInstance(myProject);
  ProjectFileIndex index = prm.getFileIndex();

  for (VirtualFile root : prm.getContentRoots()) {
    VirtualFile parent = root.getParent();
    if (parent == null || !index.isInContent(parent)) {
      topLevelContentRoots.add(root);
    }
  }
  return topLevelContentRoots;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:ProjectViewDirectoryHelper.java

示例15: contains

import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
@Override
public boolean contains(@NotNull VirtualFile file) {
  ProjectFileIndex index = ProjectRootManager.getInstance(getProject()).getFileIndex();
  final VirtualFile baseDir = getProject().getBaseDir();
  return index.isInContent(file) || index.isInLibraryClasses(file) || index.isInLibrarySource(file) ||
         (baseDir != null && VfsUtil.isAncestor(baseDir, file, false));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:AbstractProjectNode.java


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