com.intellij.util.indexing.ID Java Examples
The following examples show how to use
com.intellij.util.indexing.ID.
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: DrupalLightCodeInsightFixtureTestCase.java From idea-php-drupal-symfony2-bridge 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>(); FileBasedIndexImpl.getInstance().getFilesWithKey(id, new HashSet<String>(Arrays.asList(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 #2
Source File: TemplateLineMarker.java From idea-php-laravel-plugin with MIT License | 6 votes |
@NotNull @Override protected Collection<? extends PsiElement> compute() { Collection<VirtualFile> virtualFiles = new ArrayList<>(); for(ID<String, Void> key : Arrays.asList(BladeExtendsStubIndex.KEY, BladeSectionStubIndex.KEY, BladeIncludeStubIndex.KEY, BladeEachStubIndex.KEY)) { for(String templateName: templateNames) { FileBasedIndex.getInstance().getFilesWithKey(key, Collections.singleton(templateName), virtualFile -> { virtualFiles.add(virtualFile); return true; }, GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.allScope(project), BladeFileType.INSTANCE)); } } return PsiElementUtils.convertVirtualFilesToPsiFiles(project, virtualFiles); }
Example #3
Source File: DotEnvLightCodeInsightFixtureTestCase.java From idea-php-dotenv-plugin with MIT License | 6 votes |
private void assertIndex(@NotNull ID<String, ?> id, boolean notCondition, @NotNull String... keys) { for (String key : keys) { final Collection<VirtualFile> virtualFiles = new ArrayList<>(); FileBasedIndexImpl.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 #4
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 #5
Source File: IndexUtil.java From idea-php-symfony2-plugin with MIT License | 6 votes |
public static void forceReindex() { ID<?,?>[] indexIds = new ID<?,?>[] { ContainerBuilderStubIndex.KEY, ContainerParameterStubIndex.KEY, DoctrineMetadataFileStubIndex.KEY, EventAnnotationStubIndex.KEY, FileResourcesIndex.KEY, PhpTwigTemplateUsageStubIndex.KEY, RoutesStubIndex.KEY, ServicesDefinitionStubIndex.KEY, ServicesTagStubIndex.KEY, TwigExtendsStubIndex.KEY, TwigIncludeStubIndex.KEY, TwigMacroFunctionStubIndex.KEY, TranslationStubIndex.KEY, TwigBlockIndexExtension.KEY }; for(ID<?,?> id: indexIds) { FileBasedIndex.getInstance().requestRebuild(id); FileBasedIndex.getInstance().scheduleRebuild(id, new Throwable()); } }
Example #6
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 #7
Source File: LaravelLightCodeInsightFixtureTestCase.java From idea-php-laravel-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>(); FileBasedIndexImpl.getInstance().getFilesWithKey(id, new HashSet<String>(Arrays.asList(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 #8
Source File: FileIndexCaches.java From idea-php-symfony2-plugin with MIT License | 6 votes |
/** * @param dataHolderKey Main data to cache * @param dataHolderNames Cache extracted name Set */ static public synchronized Map<String, List<String>> getStringDataCache(@NotNull final Project project, @NotNull Key<CachedValue<Map<String, List<String>>>> dataHolderKey, final @NotNull Key<CachedValue<Set<String>>> dataHolderNames, @NotNull final ID<String, String> ID, @NotNull final GlobalSearchScope scope) { return CachedValuesManager.getManager(project).getCachedValue( project, dataHolderKey, () -> { Map<String, List<String>> strings = new HashMap<>(); final FileBasedIndex fileBasedIndex = FileBasedIndex.getInstance(); getIndexKeysCache(project, dataHolderNames, ID).forEach(parameterName -> { // just for secure if(parameterName == null) { return; } strings.put(parameterName, fileBasedIndex.getValues(ID, parameterName, scope)); }); return CachedValueProvider.Result.create(strings, getModificationTrackerForIndexId(project, ID)); }, false ); }
Example #9
Source File: FileModuleIndexService.java From reasonml-idea-plugin with MIT License | 6 votes |
@NotNull public List<FileBase> getFiles(@NotNull Project project, @NotNull GlobalSearchScope scope) { List<FileBase> result = new ArrayList<>(); FileBasedIndex fileIndex = FileBasedIndex.getInstance(); ID<String, FileModuleData> indexId = m_index.getName(); Collection<String> allKeys = fileIndex.getAllKeys(indexId, project); LOG.debug("all keys (" + allKeys.size() + "): " + Joiner.join(", ", allKeys)); for (String key : allKeys) { if (!"Pervasives".equals(key)) { Collection<PsiModule> psiModules = ModuleIndex.getInstance().get(key, project, scope); for (PsiModule psiModule : psiModules) { result.add((FileBase) psiModule.getContainingFile()); } } } return result; }
Example #10
Source File: FileIndexCaches.java From idea-php-symfony2-plugin with MIT License | 6 votes |
/** * @param dataHolderKey Main data to cache * @param dataHolderNames Cache extracted name Set */ static public synchronized <T> Map<String, List<T>> getSetDataCache(@NotNull final Project project, @NotNull Key<CachedValue<Map<String, List<T>>>> dataHolderKey, final @NotNull Key<CachedValue<Set<String>>> dataHolderNames, @NotNull final ID<String, T> ID, @NotNull final GlobalSearchScope scope) { return CachedValuesManager.getManager(project).getCachedValue( project, dataHolderKey, () -> { Map<String, List<T>> items = new HashMap<>(); final FileBasedIndex fileBasedIndex = FileBasedIndex.getInstance(); getIndexKeysCache(project, dataHolderNames, ID).forEach(service -> items.put(service, fileBasedIndex.getValues(ID, service, scope)) ); return CachedValueProvider.Result.create(items, getModificationTrackerForIndexId(project, ID)); }, false ); }
Example #11
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 #12
Source File: ShopwareLightCodeInsightFixtureTestCase.java From idea-php-shopware-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>(); FileBasedIndexImpl.getInstance().getFilesWithKey(id, new HashSet<String>(Arrays.asList(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 #13
Source File: AnnotationLightCodeInsightFixtureTestCase.java From idea-php-generics-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 #14
Source File: StubForwardIndexExternalizer.java From consulo with Apache License 2.0 | 5 votes |
<K> Map<StubIndexKey, Map<Object, StubIdList>> doRead(@Nonnull DataInput in, @Nullable StubIndexKey<K, ?> requestedIndex, @Nullable K requestedKey) throws IOException { if (!myEnsuredStubElementTypesLoaded) { ProgressManager.getInstance().executeNonCancelableSection(() -> { SerializationManager.getInstance().initSerializers(); StubIndexImpl.initExtensions(); }); myEnsuredStubElementTypesLoaded = true; } int stubIndicesValueMapSize = DataInputOutputUtil.readINT(in); if (stubIndicesValueMapSize > 0) { THashMap<StubIndexKey, Map<Object, StubIdList>> stubIndicesValueMap = requestedIndex != null ? null : new THashMap<>(stubIndicesValueMapSize); StubIndexImpl stubIndex = (StubIndexImpl)StubIndex.getInstance(); StubKeySerializationState stubKeySerializationState = createStubIndexKeySerializationState(in, stubIndicesValueMapSize); for (int i = 0; i < stubIndicesValueMapSize; ++i) { ID<Object, ?> indexKey = (ID<Object, ?>)readStubIndexKey(in, stubKeySerializationState); if (indexKey instanceof StubIndexKey) { // indexKey can be ID in case of removed index StubIndexKey<Object, ?> stubIndexKey = (StubIndexKey<Object, ?>)indexKey; boolean deserialize = requestedIndex == null || requestedIndex.equals(stubIndexKey); if (deserialize) { Map<Object, StubIdList> value = stubIndex.deserializeIndexValue(in, stubIndexKey, requestedKey); if (requestedIndex != null) { return Collections.singletonMap(requestedIndex, value); } stubIndicesValueMap.put(stubIndexKey, value); } else { stubIndex.skipIndexValue(in); } } } return stubIndicesValueMap; } return Collections.emptyMap(); }
Example #15
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 #16
Source File: ORProjectManagerTest.java From reasonml-idea-plugin with MIT License | 5 votes |
@Before public void setUp() { initMocks(this); mockStatic(ID.class); when(ID.create(any())).thenReturn(null); mockStatic(EsyPackageJson.class); mockStatic(FilenameIndex.class); mockStatic(GlobalSearchScope.class); when(GlobalSearchScope.allScope(mockProject)).thenReturn(mockScope); }
Example #17
Source File: ORFileUtilsTest.java From reasonml-idea-plugin with MIT License | 5 votes |
@Before public void setUp() { initMocks(this); mockStatic(ID.class); mockStatic(EsyPackageJson.class); mockStatic(FilenameIndex.class); mockStatic(GlobalSearchScope.class); when(GlobalSearchScope.allScope(mockProject)).thenReturn(mockScope); }
Example #18
Source File: PluginUtil.java From idea-php-annotation-plugin with MIT License | 5 votes |
/** * Force reindex of all internal file indexes */ public static void forceReindex() { ID<?,?>[] indexIds = new ID<?,?>[] { AnnotationStubIndex.KEY, AnnotationUsageIndex.KEY, }; for(ID<?,?> id: indexIds) { FileBasedIndex.getInstance().requestRebuild(id); FileBasedIndex.getInstance().scheduleRebuild(id, new Throwable()); } }
Example #19
Source File: StubProvidedIndexExtension.java From consulo with Apache License 2.0 | 5 votes |
@Nullable public <K> ProvidedIndexExtension<K, Void> findProvidedStubIndex(@Nonnull StubIndexExtension<K, ?> extension) { String name = extension.getKey().getName(); File path = getIndexPath(); File indexPath = new File(path, StringUtil.toLowerCase(name)); if (!indexPath.exists()) return null; return new ProvidedIndexExtension<K, Void>() { @Nonnull @Override public File getIndexPath() { return myIndexFile; } @Nonnull @Override public ID<K, Void> getIndexId() { return (ID)extension.getKey(); } @Nonnull @Override public KeyDescriptor<K> createKeyDescriptor() { return extension.getKeyDescriptor(); } @Nonnull @Override public DataExternalizer<Void> createValueExternalizer() { return VoidDataExternalizer.INSTANCE; } }; }
Example #20
Source File: SymfonyLightCodeInsightFixtureTestCase.java From idea-php-symfony2-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 #21
Source File: DrupalLightCodeInsightFixtureTestCase.java From idea-php-drupal-symfony2-bridge 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 = FileBasedIndexImpl.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 #22
Source File: IndexUtil.java From idea-php-drupal-symfony2-bridge with MIT License | 5 votes |
@NotNull public static Collection<LookupElement> getIndexedKeyLookup(@NotNull Project project, @NotNull ID<String, ?> var1) { Collection<LookupElement> lookupElements = new ArrayList<>(); lookupElements.addAll(SymfonyProcessors.createResult(project, var1).stream().map( s -> LookupElementBuilder.create(s).withIcon(DrupalIcons.DRUPAL)).collect(Collectors.toList()) ); return lookupElements; }
Example #23
Source File: SymfonyProcessors.java From idea-php-symfony2-plugin with MIT License | 5 votes |
@Deprecated public CollectProjectUniqueKeysStrong(@NotNull Project project, @NotNull ID<String, ?> id, @NotNull Collection<String> strongKeys) { this.project = project; this.id = id; this.strongKeys = strongKeys; this.stringSet = new HashSet<>(); }
Example #24
Source File: ShopwareLightCodeInsightFixtureTestCase.java From idea-php-shopware-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 = FileBasedIndexImpl.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 #25
Source File: LaravelLightCodeInsightFixtureTestCase.java From idea-php-laravel-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 = FileBasedIndexImpl.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 #26
Source File: FileIndexCaches.java From idea-php-symfony2-plugin with MIT License | 5 votes |
/** * There several methods that just need to check for names, as they also needed for value extraction, so cache them also */ static public synchronized Set<String> getIndexKeysCache(@NotNull final Project project, @NotNull Key<CachedValue<Set<String>>> dataHolderKey, @NotNull final ID<String, ?> id) { return CachedValuesManager.getManager(project).getCachedValue( project, dataHolderKey, () -> CachedValueProvider.Result.create(SymfonyProcessors.createResult(project, id), getModificationTrackerForIndexId(project, id)), false ); }
Example #27
Source File: SymfonyProcessors.java From idea-php-symfony2-plugin with MIT License | 4 votes |
@NotNull public static Set<String> createResult(@NotNull Project project, @NotNull ID<String, ?> id, @NotNull Collection<String> strongKeys) { CollectProjectUniqueKeysStrong collector = new CollectProjectUniqueKeysStrong(project, id, strongKeys); FileBasedIndex.getInstance().processAllKeys(id, collector, project); return collector.getResult(); }
Example #28
Source File: IgnoreFilesIndex.java From idea-gitignore with MIT License | 4 votes |
/** * Returns indexer's name. * * @return {@link #KEY} */ @NotNull @Override public ID<IgnoreFileTypeKey, IgnoreEntryOccurrence> getName() { return KEY; }
Example #29
Source File: LombokConfigIndex.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 4 votes |
@NotNull @Override public ID<ConfigIndexKey, ConfigValue> getName() { return NAME; }
Example #30
Source File: Unity3dMetaIndexExtension.java From consulo-unity3d with Apache License 2.0 | 4 votes |
@Nonnull @Override public ID<String, Integer> getName() { return KEY; }