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


Java ProjectFileIndex.isInLibrarySource方法代码示例

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


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

示例1: adjustElement

import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
@Nullable
@Override
public PsiElement adjustElement(final PsiElement psiElement) {
  final ProjectFileIndex index = ProjectRootManager.getInstance(psiElement.getProject()).getFileIndex();
  final PsiFile containingFile = psiElement.getContainingFile();
  if (containingFile != null) {
    final VirtualFile file = containingFile.getVirtualFile();
    if (file != null &&
        (index.isUnderSourceRootOfType(file, JavaModuleSourceRootTypes.SOURCES) || index.isInLibraryClasses(file) || index.isInLibrarySource(file))) {
      if (psiElement instanceof PsiJavaFile) {
        final PsiJavaFile psiJavaFile = (PsiJavaFile)psiElement;
        if (psiJavaFile.getViewProvider().getBaseLanguage() == JavaLanguage.INSTANCE) {
          final PsiClass[] psiClasses = psiJavaFile.getClasses();
          if (psiClasses.length == 1) {
            return psiClasses[0];
          }
        }
      }
      if (psiElement instanceof PsiClass) {
        return psiElement;
      }
    }
    return containingFile;
  }
  return psiElement;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:JavaNavBarExtension.java

示例2: getModulesFor

import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
private Module[] getModulesFor(PsiDirectory dir) {
  final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
  final VirtualFile vFile = dir.getVirtualFile();
  final Set<Module> modules = new HashSet<Module>();
  final Module module = fileIndex.getModuleForFile(vFile);
  if (module != null) {
    modules.add(module);
  }
  if (fileIndex.isInLibrarySource(vFile) || fileIndex.isInLibraryClasses(vFile)) {
    final List<OrderEntry> orderEntries = fileIndex.getOrderEntriesForFile(vFile);
    if (orderEntries.isEmpty()) {
      return Module.EMPTY_ARRAY;
    }
    for (OrderEntry entry : orderEntries) {
      modules.add(entry.getOwnerModule());
    }
  }
  return modules.toArray(new Module[modules.size()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:PackageViewPane.java

示例3: groupUsage

import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
@Override
public UsageGroup groupUsage(@NotNull Usage usage) {
  if (!(usage instanceof PsiElementUsage)) {
    return null;
  }
  PsiElementUsage elementUsage = (PsiElementUsage)usage;

  PsiElement element = elementUsage.getElement();
  VirtualFile virtualFile = PsiUtilCore.getVirtualFile(element);

  if (virtualFile == null) {
    return null;
  }
  ProjectFileIndex fileIndex = ProjectRootManager.getInstance(element.getProject()).getFileIndex();
  boolean isInLib = fileIndex.isInLibraryClasses(virtualFile) || fileIndex.isInLibrarySource(virtualFile);
  if (isInLib) return LIBRARY;
  boolean isInTest = fileIndex.isInTestSourceContent(virtualFile);
  return isInTest ? TEST : PRODUCTION;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:UsageScopeGroupingRule.java

示例4: addSourceDirectoriesFromLibraries

import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
private static void addSourceDirectoriesFromLibraries(@NotNull Project project,
                                                      @NotNull VirtualFile file,
                                                      @NotNull Collection<VirtualFile> outSourceRoots) {
  ProjectFileIndex index = ProjectFileIndex.SERVICE.getInstance(project);
  // if we already are in the sources, search just in this directory only
  if (index.isInLibrarySource(file)) return;
  VirtualFile classRoot = index.getClassRootForFile(file);
  if (classRoot == null) return;
  String relativePath = VfsUtilCore.getRelativePath(file, classRoot);
  if (relativePath == null) return;
  for (OrderEntry orderEntry : index.getOrderEntriesForFile(file)) {
    for (VirtualFile sourceRoot : orderEntry.getFiles(OrderRootType.SOURCES)) {
      VirtualFile sourceFile = sourceRoot.findFileByRelativePath(relativePath);
      if (sourceFile != null) {
        outSourceRoots.add(sourceFile);
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:FindInProjectUtil.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: canSelect

import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
private boolean canSelect(VirtualFile vFile) {
  if (vFile != null && vFile.isValid()) {
    ProjectFileIndex index = ProjectRootManager.getInstance(myProject).getFileIndex();
    if (index.getContentRootForFile(vFile, false) != null) {
      return true;
    }

    if (index.isInLibraryClasses(vFile) || index.isInLibrarySource(vFile)) {
      return true;
    }

    return Comparing.equal(vFile.getParent(), myProject.getBaseDir());
  }

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

示例7: adjustElement

import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
@Override
public PsiElement adjustElement(PsiElement psiElement) {
  final ProjectFileIndex index = ProjectRootManager.getInstance(psiElement.getProject()).getFileIndex();
  final PsiFile containingFile = psiElement.getContainingFile();
  if (containingFile instanceof GroovyFileBase) {
    final VirtualFile file = containingFile.getVirtualFile();
    if (file != null && (index.isUnderSourceRootOfType(file, JavaModuleSourceRootTypes.SOURCES) || index.isInLibraryClasses(file) || index.isInLibrarySource(file))) {
      if (psiElement instanceof GroovyFileBase) {
        final GroovyFileBase grFile = (GroovyFileBase)psiElement;
        if (grFile.getViewProvider().getBaseLanguage().equals(GroovyLanguage.INSTANCE)) {
          final PsiClass[] psiClasses = grFile.getClasses();
          if (psiClasses.length == 1 && !grFile.isScript()) {
            return psiClasses[0];
          }
        }
      }
      else if (psiElement instanceof GrTypeDefinition) {
        return psiElement;
      }
    }

    return containingFile;
  }

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

示例8: getModule

import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
@Nullable
protected static Module getModule(PsiDirectory dir) {
  Project project = dir.getProject();
  final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();

  final VirtualFile vFile = dir.getVirtualFile();
  if (fileIndex.isInLibrarySource(vFile) || fileIndex.isInLibraryClasses(vFile)) {
    final List<OrderEntry> orderEntries = fileIndex.getOrderEntriesForFile(vFile);
    if (orderEntries.isEmpty()) {
      return null;
    }
    Set<Module> modules = new HashSet<Module>();
    for (OrderEntry orderEntry : orderEntries) {
      modules.add(orderEntry.getOwnerModule());
    }
    final Module[] candidates = modules.toArray(new Module[modules.size()]);
    Arrays.sort(candidates, ModuleManager.getInstance(project).moduleDependencyComparator());
    return candidates[0];
  }
  return fileIndex.getModuleForFile(vFile);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:GeneratePluginClassAction.java

示例9: contains

import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
@Override
public boolean contains(@NotNull final VirtualFile file) {
  ProjectFileIndex index = ProjectRootManager.getInstance(getProject()).getFileIndex();
  if (!index.isInLibrarySource(file) && !index.isInLibraryClasses(file)) return false;

  return someChildContainsFile(file, false);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:PackageViewLibrariesNode.java

示例10: isInLibraryContentOnly

import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
private boolean isInLibraryContentOnly(final VirtualFile vFile) {
  if (vFile == null) {
    return false;
  }
  ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
  return (projectFileIndex.isInLibraryClasses(vFile) || projectFileIndex.isInLibrarySource(vFile)) && !projectFileIndex.isInSourceContent(vFile);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:PackagesPaneSelectInTarget.java

示例11: 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

示例12: getInherentResolveScope

import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
private GlobalSearchScope getInherentResolveScope(VirtualFile vFile) {
  ProjectFileIndex projectFileIndex = myProjectRootManager.getFileIndex();
  Module module = projectFileIndex.getModuleForFile(vFile);
  if (module != null) {
    boolean includeTests = projectFileIndex.isInTestSourceContent(vFile);
    return GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module, includeTests);
  }

  if (!projectFileIndex.isInLibrarySource(vFile) && !projectFileIndex.isInLibraryClasses(vFile)) {
    return GlobalSearchScope.allScope(myProject);
  }
  
  return LibraryScopeCache.getInstance(myProject).getLibraryScope(projectFileIndex.getOrderEntriesForFile(vFile));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:ResolveScopeManagerImpl.java

示例13: filterNotInLibrary

import com.intellij.openapi.roots.ProjectFileIndex; //导入方法依赖的package包/类
@NotNull
private static List<PropertiesFile> filterNotInLibrary(@NotNull Project project,
                                                       @NotNull List<PropertiesFile> propertiesFiles) {
  final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();

  final List<PropertiesFile> result = new ArrayList<PropertiesFile>(propertiesFiles.size());
  for (final PropertiesFile file : propertiesFiles) {
    if (!fileIndex.isInLibraryClasses(file.getVirtualFile()) && !fileIndex.isInLibrarySource(file.getVirtualFile())) {
      result.add(file);
    }
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:InvalidPropertyKeyInspection.java

示例14: 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

示例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.isInLibrarySource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。