com.intellij.util.indexing.FileBasedIndex Java Examples
The following examples show how to use
com.intellij.util.indexing.FileBasedIndex.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AnnotationLightCodeInsightFixtureTestCase.java From idea-php-annotation-plugin with MIT License | 6 votes |
public void assertIndex(@NotNull ID<String, ?> id, boolean notCondition, @NotNull String... keys) { for (String key : keys) { final Collection<VirtualFile> virtualFiles = new ArrayList<VirtualFile>(); FileBasedIndex.getInstance().getFilesWithKey(id, new HashSet<>(Collections.singletonList(key)), virtualFile -> { virtualFiles.add(virtualFile); return true; }, GlobalSearchScope.allScope(getProject())); if(notCondition && virtualFiles.size() > 0) { fail(String.format("Fail that ID '%s' not contains '%s'", id.toString(), key)); } else if(!notCondition && virtualFiles.size() == 0) { fail(String.format("Fail that ID '%s' contains '%s'", id.toString(), key)); } } }
Example #2
Source File: EelProvider.java From intellij-neos with GNU General Public License v3.0 | 6 votes |
@Override protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) { Project project = parameters.getPosition().getProject(); Collection<String> contexts = FileBasedIndex.getInstance().getAllKeys(DefaultContextFileIndex.KEY, project); for (String eelHelper : contexts) { List<String> helpers = FileBasedIndex.getInstance().getValues(DefaultContextFileIndex.KEY, eelHelper, GlobalSearchScope.allScope(project)); if (!helpers.isEmpty()) { for (String helper : helpers) { Collection<PhpClass> classes = PhpIndex.getInstance(project).getClassesByFQN(helper); for (PhpClass phpClass : classes) { for (Method method : phpClass.getMethods()) { if (!method.getAccess().isPublic()) { continue; } if (method.getName().equals("allowsCallOfMethod")) { continue; } String completionText = eelHelper + "." + method.getName() + "()"; result.addElement(LookupElementBuilder.create(completionText).withIcon(PhpIcons.METHOD_ICON)); } } } } } }
Example #3
Source File: AppConfigReferences.java From Thinkphp5-Plugin with MIT License | 6 votes |
/** * 获取提示信息 * * @return 返回提示集合 */ @NotNull @Override public Collection<LookupElement> getLookupElements() { final Collection<LookupElement> lookupElements = new ArrayList<>(); CollectProjectUniqueKeys ymlProjectProcessor = new CollectProjectUniqueKeys(getProject(), ConfigKeyStubIndex.KEY); //扫描文件获取key, 放入ymlProjectProcessor FileBasedIndex.getInstance().processAllKeys(ConfigKeyStubIndex.KEY, ymlProjectProcessor, getProject()); for (String key : ymlProjectProcessor.getResult()) { lookupElements.add(LookupElementBuilder.create(key).withIcon(LaravelIcons.CONFIG)); } return lookupElements; }
Example #4
Source File: IndexTranslatorProvider.java From idea-php-symfony2-plugin with MIT License | 6 votes |
@NotNull @Override public Collection<PsiElement> getTranslationTargets(@NotNull Project project, @NotNull String translationKey, @NotNull String domain) { Collection<PsiElement> psiFoundElements = new ArrayList<>(); Collection<VirtualFile> files = new HashSet<>(); FileBasedIndex.getInstance().getFilesWithKey(TranslationStubIndex.KEY, new HashSet<>(Collections.singletonList(domain)), virtualFile -> { files.add(virtualFile); return true; }, GlobalSearchScope.allScope(project)); for (PsiFile psiFile : PsiElementUtils.convertVirtualFilesToPsiFiles(project, files)) { psiFoundElements.addAll(TranslationUtil.getTranslationKeyTargetInsideFile(psiFile, domain, translationKey)); } return psiFoundElements; }
Example #5
Source File: EelHelperMethodAnnotator.java From intellij-neos with GNU General Public License v3.0 | 6 votes |
@Override public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) { if (element instanceof FusionMethodCall) { FusionMethodCall methodCall = (FusionMethodCall) element; if (methodCall.getPrevSibling() != null && methodCall.getPrevSibling().getPrevSibling() instanceof FusionCompositeIdentifier) { FusionCompositeIdentifier compositeId = (FusionCompositeIdentifier) methodCall.getPrevSibling().getPrevSibling(); List<String> helpers = FileBasedIndex.getInstance().getValues(DefaultContextFileIndex.KEY, compositeId.getText(), GlobalSearchScope.allScope(element.getProject())); if (!helpers.isEmpty()) { for (String helper : helpers) { if (PhpElementsUtil.getClassMethod(element.getProject(), helper, methodCall.getMethodName().getText()) != null) { return; } } holder.createErrorAnnotation(methodCall, "Unresolved EEL helper method"); } } } }
Example #6
Source File: DoctrineMetadataUtil.java From idea-php-symfony2-plugin with MIT License | 6 votes |
/** * Find metadata model in which the given repository class is used * eg "@ORM\Entity(repositoryClass="FOOBAR")", xml or yaml */ @NotNull public static Collection<DoctrineModelInterface> findMetadataModelForRepositoryClass(final @NotNull Project project, @NotNull String repositoryClass) { repositoryClass = StringUtils.stripStart(repositoryClass,"\\"); Collection<DoctrineModelInterface> models = new ArrayList<>(); for (String key : FileIndexCaches.getIndexKeysCache(project, CLASS_KEYS, DoctrineMetadataFileStubIndex.KEY)) { for (DoctrineModelInterface repositoryDefinition : FileBasedIndex.getInstance().getValues(DoctrineMetadataFileStubIndex.KEY, key, GlobalSearchScope.allScope(project))) { String myRepositoryClass = repositoryDefinition.getRepositoryClass(); if(StringUtils.isBlank(myRepositoryClass) || !repositoryClass.equalsIgnoreCase(StringUtils.stripStart(myRepositoryClass, "\\"))) { continue; } models.add(repositoryDefinition); } } return models; }
Example #7
Source File: DoctrineMetadataUtil.java From idea-php-symfony2-plugin with MIT License | 6 votes |
/** * Try to find repository class on models scope on its metadata definition */ @Nullable public static PhpClass getClassRepository(final @NotNull Project project, final @NotNull String className) { for (VirtualFile virtualFile : FileBasedIndex.getInstance().getContainingFiles(DoctrineMetadataFileStubIndex.KEY, className, GlobalSearchScope.allScope(project))) { final String[] phpClass = {null}; FileBasedIndex.getInstance().processValues(DoctrineMetadataFileStubIndex.KEY, className, virtualFile, (virtualFile1, model) -> { if (phpClass[0] != null || model == null || model.getRepositoryClass() == null) { return true; } // piping value out of this index thread phpClass[0] = model.getRepositoryClass(); return true; }, GlobalSearchScope.allScope(project)); if(phpClass[0] != null) { return PhpElementsUtil.getClassInsideNamespaceScope(project, className, phpClass[0]); } } return null; }
Example #8
Source File: AnnotationLightCodeInsightFixtureTestCase.java From idea-php-generics-plugin with MIT License | 6 votes |
public void assertIndex(@NotNull ID<String, ?> id, boolean notCondition, @NotNull String... keys) { for (String key : keys) { final Collection<VirtualFile> virtualFiles = new ArrayList<VirtualFile>(); FileBasedIndex.getInstance().getFilesWithKey(id, new HashSet<>(Collections.singletonList(key)), virtualFile -> { virtualFiles.add(virtualFile); return true; }, GlobalSearchScope.allScope(getProject())); if(notCondition && virtualFiles.size() > 0) { fail(String.format("Fail that ID '%s' not contains '%s'", id.toString(), key)); } else if(!notCondition && virtualFiles.size() == 0) { fail(String.format("Fail that ID '%s' contains '%s'", id.toString(), key)); } } }
Example #9
Source File: AnnotationUtil.java From idea-php-annotation-plugin with MIT License | 6 votes |
@NotNull private static Collection<PsiFile> getFilesImplementingAnnotation(@NotNull Project project, @NotNull String phpClassName) { Collection<VirtualFile> files = new HashSet<>(); FileBasedIndex.getInstance().getFilesWithKey(AnnotationUsageIndex.KEY, new HashSet<>(Collections.singletonList(phpClassName)), virtualFile -> { files.add(virtualFile); return true; }, GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.allScope(project), PhpFileType.INSTANCE)); Collection<PsiFile> elements = new ArrayList<>(); for (VirtualFile file : files) { PsiFile psiFile = PsiManager.getInstance(project).findFile(file); if(psiFile == null) { continue; } elements.add(psiFile); } return elements; }
Example #10
Source File: TwigUtil.java From idea-php-symfony2-plugin with MIT License | 6 votes |
public static Collection<PsiElement> getTwigMacroTargets(final Project project, final String name) { final Collection<PsiElement> targets = new ArrayList<>(); FileBasedIndex.getInstance().getFilesWithKey(TwigMacroFunctionStubIndex.KEY, new HashSet<>(Collections.singletonList(name)), virtualFile -> { PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile); if (psiFile != null) { PsiTreeUtil.processElements(psiFile, psiElement -> { if (TwigPattern.getTwigMacroNameKnownPattern(name).accepts(psiElement)) { targets.add(psiElement); } return true; }); } return true; }, GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.allScope(project), TwigFileType.INSTANCE)); return targets; }
Example #11
Source File: IndexUtil.java From idea-php-drupal-symfony2-bridge with MIT License | 6 votes |
@NotNull public static Collection<PhpClass> getFormClassForId(@NotNull Project project, @NotNull String id) { Collection<PhpClass> phpClasses = new ArrayList<>(); for (String key : SymfonyProcessors.createResult(project, ConfigEntityTypeAnnotationIndex.KEY)) { if(!id.equals(key)) { continue; } for (String value : FileBasedIndex.getInstance().getValues(ConfigEntityTypeAnnotationIndex.KEY, key, GlobalSearchScope.allScope(project))) { phpClasses.addAll(PhpElementsUtil.getClassesInterface(project, value)); } } return phpClasses; }
Example #12
Source File: CompileContextImpl.java From consulo with Apache License 2.0 | 6 votes |
@Override public boolean isGenerated(VirtualFile file) { if (myGeneratedSources.contains(FileBasedIndex.getFileId(file))) { return true; } if (isUnderRoots(myRootToModuleMap.keySet(), file)) { return true; } final Module module = getModuleByFile(file); if (module != null) { for (AdditionalOutputDirectoriesProvider provider : AdditionalOutputDirectoriesProvider.EP_NAME.getExtensionList()) { for (String path : provider.getOutputDirectories(getProject(), module)) { if (path != null && VfsUtilCore.isAncestor(new File(path), new File(file.getPath()), true)) { return true; } } } } return false; }
Example #13
Source File: TwigControllerUsageControllerRelatedGotoCollector.java From idea-php-symfony2-plugin with MIT License | 6 votes |
@Override public void collectGotoRelatedItems(ControllerActionGotoRelatedCollectorParameter parameter) { Method method = parameter.getMethod(); PhpClass containingClass = method.getContainingClass(); if (containingClass == null) { return; } String controllerAction = StringUtils.stripStart(containingClass.getPresentableFQN(), "\\") + "::" + method.getName(); Collection<VirtualFile> targets = new HashSet<>(); FileBasedIndex.getInstance().getFilesWithKey(TwigControllerStubIndex.KEY, new HashSet<>(Collections.singletonList(controllerAction)), virtualFile -> { targets.add(virtualFile); return true; }, GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.allScope(parameter.getProject()), TwigFileType.INSTANCE)); for (PsiFile psiFile: PsiElementUtils.convertVirtualFilesToPsiFiles(parameter.getProject(), targets)) { TwigUtil.visitControllerFunctions(psiFile, pair -> { if (pair.getFirst().equalsIgnoreCase(controllerAction)) { parameter.add(new RelatedPopupGotoLineMarker.PopupGotoRelatedItem(pair.getSecond()).withIcon(TwigIcons.TwigFileIcon, Symfony2Icons.TWIG_LINE_MARKER)); } }); } }
Example #14
Source File: FileModuleIndexService.java From reasonml-idea-plugin with MIT License | 6 votes |
@NotNull Collection<IndexedFileModule> getFilesForNamespace(@NotNull String namespace, @NotNull GlobalSearchScope scope) { Collection<IndexedFileModule> result = new ArrayList<>(); FileBasedIndex fileIndex = FileBasedIndex.getInstance(); if (scope.getProject() != null) { for (String key : fileIndex.getAllKeys(m_index.getName(), scope.getProject())) { List<FileModuleData> values = fileIndex.getValues(m_index.getName(), key, scope); int valuesSize = values.size(); if (valuesSize > 2) { System.out.println("ERROR, size of " + key + " is " + valuesSize); } else { for (FileModuleData value : values) { if (valuesSize == 1 || value.isInterface()) { if (namespace.equals(value.getNamespace())) { result.add(value); } } } } } } return result; }
Example #15
Source File: SymfonyLightCodeInsightFixtureTestCase.java From idea-php-symfony2-plugin with MIT License | 6 votes |
public void assertIndex(@NotNull ID<String, ?> id, boolean notCondition, @NotNull String... keys) { for (String key : keys) { final Collection<VirtualFile> virtualFiles = new ArrayList<VirtualFile>(); FileBasedIndex.getInstance().getFilesWithKey(id, new HashSet<String>(Collections.singletonList(key)), new Processor<VirtualFile>() { @Override public boolean process(VirtualFile virtualFile) { virtualFiles.add(virtualFile); return true; } }, GlobalSearchScope.allScope(getProject())); if(notCondition && virtualFiles.size() > 0) { fail(String.format("Fail that ID '%s' not contains '%s'", id.toString(), key)); } else if(!notCondition && virtualFiles.size() == 0) { fail(String.format("Fail that ID '%s' contains '%s'", id.toString(), key)); } } }
Example #16
Source File: TYPO3DetectionListener.java From idea-php-typo3-plugin with MIT License | 6 votes |
@Override public void projectOpened(@NotNull Project project) { this.checkProject(project); TYPO3CMSSettings instance = TYPO3CMSSettings.getInstance(project); IdeaPluginDescriptor plugin = PluginManager.getPlugin(PluginId.getId("com.cedricziel.idea.typo3")); if (plugin == null) { return; } String version = instance.getVersion(); if (version == null || !plugin.getVersion().equals(version)) { instance.setVersion(plugin.getVersion()); FileBasedIndex index = FileBasedIndex.getInstance(); index.scheduleRebuild(CoreServiceMapStubIndex.KEY, new Throwable()); index.scheduleRebuild(ExtensionNameStubIndex.KEY, new Throwable()); index.scheduleRebuild(IconIndex.KEY, new Throwable()); index.scheduleRebuild(ResourcePathIndex.KEY, new Throwable()); index.scheduleRebuild(RouteIndex.KEY, new Throwable()); index.scheduleRebuild(TablenameFileIndex.KEY, new Throwable()); index.scheduleRebuild(LegacyClassesForIDEIndex.KEY, new Throwable()); index.scheduleRebuild(MethodArgumentDroppedIndex.KEY, new Throwable()); index.scheduleRebuild(ControllerActionIndex.KEY, new Throwable()); } }
Example #17
Source File: HaxeUtil.java From intellij-haxe with Apache License 2.0 | 6 votes |
public static void reparseProjectFiles(@NotNull final Project project) { Task.Backgroundable task = new Task.Backgroundable(project, HaxeBundle.message("haxe.project.reparsing"), false) { public void run(@NotNull ProgressIndicator indicator) { final Collection<VirtualFile> haxeFiles = new ArrayList<VirtualFile>(); final VirtualFile baseDir = project.getBaseDir(); if (baseDir != null) { FileBasedIndex.getInstance().iterateIndexableFiles(new ContentIterator() { public boolean processFile(VirtualFile file) { if (HaxeFileType.HAXE_FILE_TYPE == file.getFileType()) { haxeFiles.add(file); } return true; } }, project, indicator); } ApplicationManager.getApplication().invokeAndWait(new Runnable() { public void run() { FileContentUtil.reparseFiles(project, haxeFiles, !project.isDefault()); } }, ModalityState.NON_MODAL); } }; ProgressManager.getInstance().run(task); }
Example #18
Source File: TranslationUtil.java From idea-php-typo3-plugin with MIT License | 6 votes |
@NotNull private synchronized static Collection<String> getAllKeys(@NotNull Project project) { CachedValue<Collection<String>> cachedValue = project.getUserData(TRANSLATION_KEYS); if (cachedValue != null && cachedValue.hasUpToDateValue()) { return TRANSLATION_KEYS_LOCAL_CACHE.getOrDefault(project, new ArrayList<>()); } cachedValue = CachedValuesManager.getManager(project).createCachedValue(() -> { Collection<String> allKeys = FileBasedIndex.getInstance().getAllKeys(TranslationIndex.KEY, project); if (TRANSLATION_KEYS_LOCAL_CACHE.containsKey(project)) { TRANSLATION_KEYS_LOCAL_CACHE.replace(project, allKeys); } else { TRANSLATION_KEYS_LOCAL_CACHE.put(project, allKeys); } return CachedValueProvider.Result.create(new ArrayList<>(), MODIFICATION_COUNT); }, false); project.putUserData(TRANSLATION_KEYS, cachedValue); return TRANSLATION_KEYS_LOCAL_CACHE.getOrDefault(project, cachedValue.getValue()); }
Example #19
Source File: BladeTemplateUtil.java From idea-php-laravel-plugin with MIT License | 6 votes |
private static void getExtendsImplementations(@NotNull Project project, @NotNull String templateName, @NotNull Set<VirtualFile> virtualFiles, int depth) { if(depth-- <= 0) { return; } int finalDepth = depth; FileBasedIndex.getInstance().getFilesWithKey(BladeExtendsStubIndex.KEY, Collections.singleton(templateName), virtualFile -> { if (!virtualFiles.contains(virtualFile)) { virtualFiles.add(virtualFile); for (String nextTpl : BladeTemplateUtil.resolveTemplateName(project, virtualFile)) { getExtendsImplementations(project, nextTpl, virtualFiles, finalDepth); } } return true; }, GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.allScope(project), BladeFileType.INSTANCE)); }
Example #20
Source File: TableUtil.java From idea-php-typo3-plugin with MIT License | 6 votes |
public static PsiElement[] getTableDefinitionElements(@NotNull String tableName, @NotNull Project project) { PsiFile[] extTablesSqlFilesInProjectContainingTable = getExtTablesSqlFilesInProjectContainingTable(tableName, project); Set<PsiElement> elements = new HashSet<>(); PsiManager psiManager = PsiManager.getInstance(project); for (PsiFile virtualFile : extTablesSqlFilesInProjectContainingTable) { FileBasedIndex.getInstance().processValues(TablenameFileIndex.KEY, tableName, virtualFile.getVirtualFile(), (file, value) -> { PsiFile file1 = psiManager.findFile(file); if (file1 != null) { PsiElement elementAt = file1.findElementAt(value.getEndOffset() - 2); if (elementAt != null) { elements.add(elementAt); } } return true; }, GlobalSearchScope.allScope(project)); } return elements.toArray(new PsiElement[0]); }
Example #21
Source File: GraphQLJavascriptInjectionSearchHelper.java From js-graphql-intellij-plugin with MIT License | 5 votes |
/** * Uses the {@link GraphQLInjectionIndex} to process injected GraphQL PsiFiles * * @param scopedElement the starting point of the enumeration settings the scopedElement of the processing * @param schemaScope the search scope to use for limiting the schema definitions * @param consumer a consumer that will be invoked for each injected GraphQL PsiFile */ public void processInjectedGraphQLPsiFiles(PsiElement scopedElement, GlobalSearchScope schemaScope, Consumer<PsiFile> consumer) { try { final PsiManager psiManager = PsiManager.getInstance(scopedElement.getProject()); final InjectedLanguageManager injectedLanguageManager = InjectedLanguageManager.getInstance(scopedElement.getProject()); FileBasedIndex.getInstance().getFilesWithKey(GraphQLInjectionIndex.NAME, Collections.singleton(GraphQLInjectionIndex.DATA_KEY), virtualFile -> { final PsiFile fileWithInjection = psiManager.findFile(virtualFile); if (fileWithInjection != null) { fileWithInjection.accept(new PsiRecursiveElementVisitor() { @Override public void visitElement(PsiElement element) { if (GraphQLLanguageInjectionUtil.isJSGraphQLLanguageInjectionTarget(element)) { injectedLanguageManager.enumerate(element, (injectedPsi, places) -> { consumer.accept(injectedPsi); }); } else { // visit deeper until injection found super.visitElement(element); } } }); } return true; }, schemaScope); } catch (IndexNotReadyException e) { // can't search yet (e.g. during project startup) } }
Example #22
Source File: PsiSearchHelperImpl.java From consulo with Apache License 2.0 | 5 votes |
private static boolean processFilesContainingAllKeys(@Nonnull Project project, @Nonnull final GlobalSearchScope scope, @Nullable final Condition<Integer> checker, @Nonnull final Collection<IdIndexEntry> keys, @Nonnull final Processor<VirtualFile> processor) { final FileIndexFacade index = FileIndexFacade.getInstance(project); return DumbService.getInstance(project).runReadActionInSmartMode( () -> FileBasedIndex.getInstance().processFilesContainingAllKeys(IdIndex.NAME, keys, scope, checker, file -> !index.shouldBeFound(scope, file) || processor.process(file))); }
Example #23
Source File: IndexService.java From intellij-swagger with MIT License | 5 votes |
public boolean isPartialSpecFile(final VirtualFile virtualFile, final Project project) { return FileBasedIndex.getInstance() .getValues( getIndexId(), SpecIndexer.PARTIAL_SPEC_FILES, GlobalSearchScope.allScope(project)) .stream() .flatMap(Set::stream) .anyMatch(value -> value.startsWith(virtualFile.getPath())); }
Example #24
Source File: IndexService.java From intellij-swagger with MIT License | 5 votes |
private T getPartialSpecFileType(final VirtualFile virtualFile, final Project project) { Optional<String> indexValue = FileBasedIndex.getInstance() .getValues( getIndexId(), SpecIndexer.PARTIAL_SPEC_FILES, GlobalSearchScope.allScope(project)) .stream() .flatMap(Set::stream) .filter(value -> value.startsWith(virtualFile.getPath())) .findFirst(); return indexValue .map(value -> substringAfterLast(value, SpecIndexer.DELIMITER)) .map(this::toSpecType) .orElse(getUndefinedSpecType()); }
Example #25
Source File: TwigUtil.java From idea-php-symfony2-plugin with MIT License | 5 votes |
@NotNull public static Map<VirtualFile, Collection<String>> getBlockNamesForFiles(@NotNull Project project, @NotNull Collection<VirtualFile> virtualFiles) { Map<VirtualFile, Collection<String>> blocks = new HashMap<>(); for (VirtualFile virtualFile : virtualFiles) { FileBasedIndex.getInstance().getValues(TwigBlockIndexExtension.KEY, "block", GlobalSearchScope.fileScope(project, virtualFile)) .forEach(strings -> { blocks.putIfAbsent(virtualFile, new HashSet<>()); blocks.get(virtualFile).addAll(strings); }); } return blocks; }
Example #26
Source File: IgnoreFilesIndex.java From idea-gitignore with MIT License | 5 votes |
/** * Returns collection of indexed {@link IgnoreEntryOccurrence} for given {@link Project} and {@link IgnoreFileType}. * * @param project current project * @param fileType filetype * @return {@link IgnoreEntryOccurrence} collection */ @NotNull public static List<IgnoreEntryOccurrence> getEntries(@NotNull Project project, @NotNull IgnoreFileType fileType) { try { if (ApplicationManager.getApplication().isReadAccessAllowed()) { final GlobalSearchScope scope = IgnoreSearchScope.get(project); return FileBasedIndex.getInstance() .getValues(IgnoreFilesIndex.KEY, new IgnoreFileTypeKey(fileType), scope); } } catch (RuntimeException ignored) { } return ContainerUtil.emptyList(); }
Example #27
Source File: AppConfigReferences.java From idea-php-laravel-plugin with MIT License | 5 votes |
@NotNull @Override public Collection<LookupElement> getLookupElements() { final Collection<LookupElement> lookupElements = new ArrayList<>(); CollectProjectUniqueKeys ymlProjectProcessor = new CollectProjectUniqueKeys(getProject(), ConfigKeyStubIndex.KEY); FileBasedIndex.getInstance().processAllKeys(ConfigKeyStubIndex.KEY, ymlProjectProcessor, getProject()); for(String key: ymlProjectProcessor.getResult()) { lookupElements.add(LookupElementBuilder.create(key).withIcon(LaravelIcons.CONFIG)); } return lookupElements; }
Example #28
Source File: AnnotationLightCodeInsightFixtureTestCase.java From idea-php-annotation-plugin with MIT License | 5 votes |
public <T> void assertIndexContainsKeyWithValue(@NotNull ID<String, T> id, @NotNull String key, @NotNull IndexValue.Assert<T> tAssert) { List<T> values = FileBasedIndex.getInstance().getValues(id, key, GlobalSearchScope.allScope(getProject())); for (T t : values) { if(tAssert.match(t)) { return; } } fail(String.format("Fail that Key '%s' matches on of '%s' values", key, values.size())); }
Example #29
Source File: ResolveEngine.java From intellij-neos with GNU General Public License v3.0 | 5 votes |
public static List<PsiElement> getEelHelperMethods(Project project, String helperName, String methodName) { List<String> helpers = FileBasedIndex.getInstance().getValues(DefaultContextFileIndex.KEY, helperName, GlobalSearchScope.allScope(project)); List<PsiElement> methods = new ArrayList<>(); for (String helper : helpers) { Method method = PhpElementsUtil.getClassMethod(project, helper, methodName); if (method != null) { methods.add(method); } } return methods; }
Example #30
Source File: IdeaUtils.java From netbeans-mmd-plugin with Apache License 2.0 | 5 votes |
public static List<PsiExtraFile> findPsiFileLinksForProjectScope(final Project project) { List<PsiExtraFile> result = new ArrayList<PsiExtraFile>(); Collection<VirtualFile> virtualFiles = FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, MindMapFileType.INSTANCE, GlobalSearchScope.allScope(project)); for (VirtualFile virtualFile : virtualFiles) { final MMDFile simpleFile = (MMDFile) PsiManager.getInstance(project).findFile(virtualFile); if (simpleFile != null) { final PsiExtraFile[] fileLinks = PsiTreeUtil.getChildrenOfType(simpleFile, PsiExtraFile.class); if (fileLinks != null) { Collections.addAll(result, fileLinks); } } } return result; }