本文整理汇总了Java中com.intellij.util.indexing.FileBasedIndex.getContainingFiles方法的典型用法代码示例。如果您正苦于以下问题:Java FileBasedIndex.getContainingFiles方法的具体用法?Java FileBasedIndex.getContainingFiles怎么用?Java FileBasedIndex.getContainingFiles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.util.indexing.FileBasedIndex
的用法示例。
在下文中一共展示了FileBasedIndex.getContainingFiles方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: collectServices
import com.intellij.util.indexing.FileBasedIndex; //导入方法依赖的package包/类
private void collectServices(Project project) {
FileBasedIndex index = FileBasedIndex.getInstance();
Collection<VirtualFile> containingFiles = index.getContainingFiles(
FileTypeIndex.NAME,
PhpFileType.INSTANCE,
GlobalSearchScope.allScope(project)
);
containingFiles.removeIf(virtualFile -> !(virtualFile.getName().contains("ext_localconf.php")));
for (VirtualFile projectFile : containingFiles) {
PsiFile psiFile = PsiManager.getInstance(project).findFile(projectFile);
if (psiFile != null) {
psiFile.accept(new CoreServiceDefinitionParserVisitor(serviceMap));
}
}
}
示例2: canRun
import com.intellij.util.indexing.FileBasedIndex; //导入方法依赖的package包/类
@Override
protected void canRun() throws ConfigurationException {
String newName = getNewName();
if (Comparing.strEqual(newName, key)) {
throw new ConfigurationException(null);
}
if (StringUtils.isBlank(newName) || newName.endsWith(".")) {
throw new ConfigurationException("\'" + getNewName() + "\' is not a valid key");
}
FileBasedIndex index = FileBasedIndex.getInstance();
Collection<VirtualFile> files = index.getContainingFiles(TranslationCallIndex.KEY, newName, GlobalSearchScope.allScope(getProject()));
if (!files.isEmpty()) {
throw new ConfigurationException("\'" + getNewName() + "\' already exists");
}
}
示例3: resolveInner
import com.intellij.util.indexing.FileBasedIndex; //导入方法依赖的package包/类
@Override
@Nullable
public PsiElement resolveInner() {
final FileBasedIndex instance = FileBasedIndex.getInstance();
final Project project = getElement().getProject();
final String id = getCanonicalText();
final Collection<VirtualFile> files = instance.getContainingFiles(EmberTemplateCacheIndex.TEMPLATE_CACHE_INDEX, id,
GlobalSearchScope.allScope(project));
final Ref<PsiElement> result = new Ref<PsiElement>();
for (VirtualFile file : files) {
final PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
EmberTemplateCacheIndex.processTemplates(psiFile, new Processor<XmlAttribute>() {
@Override
public boolean process(XmlAttribute attribute) {
if (id.equals(attribute.getValue())) {
result.set(attribute.getValueElement());
}
return result.isNull();
}
});
}
return result.get();
}
示例4: getFilesWithTodoItems
import com.intellij.util.indexing.FileBasedIndex; //导入方法依赖的package包/类
@Override
@Nonnull
public PsiFile[] getFilesWithTodoItems() {
if (myProject.isDefault()) {
return PsiFile.EMPTY_ARRAY;
}
final FileBasedIndex fileBasedIndex = FileBasedIndex.getInstance();
final Set<PsiFile> allFiles = new HashSet<>();
final ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
for (IndexPattern indexPattern : IndexPatternUtil.getIndexPatterns()) {
final Collection<VirtualFile> files = fileBasedIndex.getContainingFiles(
TodoIndex.NAME,
new TodoIndexEntry(indexPattern.getPatternString(), indexPattern.isCaseSensitive()), GlobalSearchScope.allScope(myProject));
ApplicationManager.getApplication().runReadAction(() -> {
for (VirtualFile file : files) {
if (projectFileIndex.isInContent(file)) {
final PsiFile psiFile = myPsiManager.findFile(file);
if (psiFile != null) {
allFiles.add(psiFile);
}
}
}
});
}
return allFiles.isEmpty() ? PsiFile.EMPTY_ARRAY : PsiUtilCore.toPsiFileArray(allFiles);
}
示例5: isMainOpenApiFile
import com.intellij.util.indexing.FileBasedIndex; //导入方法依赖的package包/类
public boolean isMainOpenApiFile(final VirtualFile virtualFile, final Project project) {
final FileBasedIndex index = FileBasedIndex.getInstance();
final Collection<VirtualFile> openApiFiles =
index.getContainingFiles(OpenApiFileIndex.OPEN_API_INDEX_ID,
OpenApiFileIndex.MAIN_OPEN_API_FILE, GlobalSearchScope.allScope(project));
return openApiFiles.contains(virtualFile);
}
示例6: isMainSwaggerFile
import com.intellij.util.indexing.FileBasedIndex; //导入方法依赖的package包/类
public boolean isMainSwaggerFile(final VirtualFile virtualFile, final Project project) {
final FileBasedIndex index = FileBasedIndex.getInstance();
final Collection<VirtualFile> swaggerFiles =
index.getContainingFiles(SwaggerFileIndex.SWAGGER_INDEX_ID,
SwaggerFileIndex.MAIN_SWAGGER_FILE, GlobalSearchScope.allScope(project));
return swaggerFiles.contains(virtualFile);
}
示例7: getFilesWithTodoItems
import com.intellij.util.indexing.FileBasedIndex; //导入方法依赖的package包/类
@Override
@NotNull
public PsiFile[] getFilesWithTodoItems() {
if (myProject.isDefault()) {
return PsiFile.EMPTY_ARRAY;
}
final FileBasedIndex fileBasedIndex = FileBasedIndex.getInstance();
final Set<PsiFile> allFiles = new HashSet<PsiFile>();
final ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
for (IndexPattern indexPattern : IndexPatternUtil.getIndexPatterns()) {
final Collection<VirtualFile> files = fileBasedIndex.getContainingFiles(
TodoIndex.NAME,
new TodoIndexEntry(indexPattern.getPatternString(), indexPattern.isCaseSensitive()), GlobalSearchScope.allScope(myProject));
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
for (VirtualFile file : files) {
if (projectFileIndex.isInContent(file)) {
final PsiFile psiFile = myPsiManager.findFile(file);
if (psiFile != null) {
allFiles.add(psiFile);
}
}
}
}
});
}
return allFiles.isEmpty() ? PsiFile.EMPTY_ARRAY : PsiUtilCore.toPsiFileArray(allFiles);
}
示例8: runDetector
import com.intellij.util.indexing.FileBasedIndex; //导入方法依赖的package包/类
private List<? extends DetectedFrameworkDescription> runDetector(Integer detectorId,
FileBasedIndex index,
DetectionExcludesConfiguration excludesConfiguration,
final boolean processNewFilesOnly) {
Collection<VirtualFile> acceptedFiles = index.getContainingFiles(FrameworkDetectionIndex.NAME, detectorId, GlobalSearchScope.projectScope(myProject));
final Collection<VirtualFile> filesToProcess;
if (processNewFilesOnly) {
filesToProcess = myDetectedFrameworksData.retainNewFiles(detectorId, acceptedFiles);
}
else {
filesToProcess = new ArrayList<VirtualFile>(acceptedFiles);
}
FrameworkDetector detector = FrameworkDetectorRegistry.getInstance().getDetectorById(detectorId);
if (detector == null) {
LOG.info("Framework detector not found by id " + detectorId);
return Collections.emptyList();
}
((DetectionExcludesConfigurationImpl)excludesConfiguration).removeExcluded(filesToProcess, detector.getFrameworkType());
if (LOG.isDebugEnabled()) {
LOG.debug("Detector '" + detector.getDetectorId() + "': " + acceptedFiles.size() + " accepted files, " + filesToProcess.size() + " files to process");
}
final List<? extends DetectedFrameworkDescription> frameworks;
if (!filesToProcess.isEmpty()) {
frameworks = detector.detect(filesToProcess, new FrameworkDetectionContextImpl(myProject));
}
else {
frameworks = Collections.emptyList();
}
return frameworks;
}
示例9: isUsed
import com.intellij.util.indexing.FileBasedIndex; //导入方法依赖的package包/类
private boolean isUsed(Project project, FileBasedIndex index, String key) {
if (key == null) {
return false;
}
Collection<VirtualFile> files = index.getContainingFiles(TranslationCallIndex.KEY, key, GlobalSearchScope.allScope(project));
return !files.isEmpty() || isUsed(project, index, TranslationUtils.getParentKey(key));
}