@NotNull private static File getIndexDirectory(@NotNull ID<?, ?> indexName, boolean forVersion, String relativePath) { final String dirName = indexName.toString().toLowerCase(Locale.US); File indexDir; if (indexName instanceof StubIndexKey) { // store StubIndices under StubUpdating index' root to ensure they are deleted // when StubUpdatingIndex version is changed indexDir = new File(getIndexDirectory(StubUpdatingIndex.INDEX_ID, false, relativePath), forVersion ? STUB_VERSIONS : dirName); } else { if (relativePath.length() > 0) relativePath = File.separator + relativePath; indexDir = new File(PathManager.getIndexRoot() + relativePath, dirName); } indexDir.mkdirs(); return indexDir; }
private static <T extends PsiNamedElement> void addVariantsFromIndex(final CompletionResultSet resultSet, final PsiFile targetFile, final StubIndexKey<String, T> key, final InsertHandler<LookupElement> insertHandler, final Condition<? super T> condition, Class<T> elementClass) { final Project project = targetFile.getProject(); GlobalSearchScope scope = PyProjectScopeBuilder.excludeSdkTestsScope(targetFile); Collection<String> keys = StubIndex.getInstance().getAllKeys(key, project); for (final String elementName : CompletionUtil.sortMatching(resultSet.getPrefixMatcher(), keys)) { for (T element : StubIndex.getElements(key, elementName, project, scope, elementClass)) { if (condition.value(element)) { resultSet.addElement(LookupElementBuilder.createWithIcon(element) .withTailText(" " + ((NavigationItem)element).getPresentation().getLocationString(), true) .withInsertHandler(insertHandler)); } } } }
public static void findAllRobotKeywordDefsInRobotFilesStartingWith(Project project, List<PsiElement> results, String startsWith) { final StubIndex STUB_INDEX = StubIndex.getInstance(); final String normalizedStartsWith = RobotPsiUtil.normalizeRobotDefinedKeywordForIndex(startsWith); String keyValue; StubIndexKey<String, RobotKeywordTitle> indexKey; if (normalizedStartsWith.length() >= 3) { keyValue = normalizedStartsWith.substring(0, 3); indexKey = RobotKeywordDefFirstThreeCharsIndex.KEY; } else if (normalizedStartsWith.length() >= 2) { keyValue = normalizedStartsWith.substring(0, 2); indexKey = RobotKeywordTitleFirstTwoCharsIndex.KEY; } else if (normalizedStartsWith.length() >= 1) { keyValue = normalizedStartsWith.substring(0, 1); indexKey = RobotKeywordDefFirstCharIndex.KEY; } else { findAllRobotKeywordDefsInRobotFiles(project, results); return; } GlobalSearchScope robotFilesScope = GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.projectScope(project), RobotFileType.INSTANCE); RobotKeywordDefProcessor processor = new RobotKeywordDefProcessor(results, SearchType.STARTS_WITH, startsWith); STUB_INDEX.processElements(indexKey, keyValue, project, robotFilesScope, RobotKeywordTitle.class, processor); }
public static void indexStub(@NotNull IndexSink indexSink, @NotNull StubIndexKey<String, ? extends DotNetQualifiedElement> elementByQNameKey, @NotNull StubIndexKey<String, ? extends DotNetQualifiedElement> namespaceKey, @NotNull String namespace, @NotNull String name) { String indexableNamespace = getIndexableNamespace(namespace); name = consulo.internal.dotnet.msil.decompiler.util.MsilHelper.cutGenericMarker(name); indexSink.occurrence(elementByQNameKey, indexableNamespace + "." + name); if(!StringUtil.isEmpty(namespace)) { QualifiedName parent = QualifiedName.fromDottedString(namespace); do { indexSink.occurrence(namespaceKey, getIndexableNamespace(parent)); } while((parent = parent.getParent()) != null); } else { indexSink.occurrence(namespaceKey, indexableNamespace); } }
@Nonnull @Override public <Key> IdIterator getContainingIds(@Nonnull StubIndexKey<Key, ?> indexKey, @Nonnull Key dataKey, @Nonnull Project project, @Nonnull GlobalSearchScope scope) { return new IdIterator() { @Override public boolean hasNext() { return false; } @Override public int next() { return 0; } @Override public int size() { return 0; } }; }
@Nonnull private static File getIndexDirectory(@Nonnull ID<?, ?> indexName, boolean forVersion, String relativePath) { final String dirName = indexName.toString().toLowerCase(Locale.US); File indexDir; if (indexName instanceof StubIndexKey) { // store StubIndices under StubUpdating index' root to ensure they are deleted // when StubUpdatingIndex version is changed indexDir = new File(getIndexDirectory(StubUpdatingIndex.INDEX_ID, false, relativePath), forVersion ? STUB_VERSIONS : dirName); } else { if (relativePath.length() > 0) relativePath = File.separator + relativePath; indexDir = new File(PathManager.getIndexRoot() + relativePath, dirName); } indexDir.mkdirs(); return indexDir; }
private static Collection<PsiMethod> getCandidateMethodsWithSuitableParams(final PsiClass aClass, final Project project, final GlobalSearchScope useScope, final Set<VirtualFile> candidateFiles, final GlobalSearchScope candidateScope) { return ApplicationManager.getApplication().runReadAction(new Computable<Collection<PsiMethod>>() { @Override public Collection<PsiMethod> compute() { if (!aClass.isValid()) return Collections.emptyList(); GlobalSearchScope visibleFromCandidates = combineResolveScopes(project, candidateFiles); final Set<String> usedMethodNames = newHashSet(); FileBasedIndex.getInstance().processAllKeys(JavaFunctionalExpressionIndex.JAVA_FUNCTIONAL_EXPRESSION_INDEX_ID, new CommonProcessors.CollectProcessor<String>(usedMethodNames), candidateScope, null); final LinkedHashSet<PsiMethod> methods = newLinkedHashSet(); Processor<PsiMethod> methodProcessor = new Processor<PsiMethod>() { @Override public boolean process(PsiMethod method) { if (usedMethodNames.contains(method.getName())) { methods.add(method); } return true; } }; StubIndexKey<String, PsiMethod> key = JavaMethodParameterTypesIndex.getInstance().getKey(); StubIndex index = StubIndex.getInstance(); index.processElements(key, aClass.getName(), project, useScope.intersectWith(visibleFromCandidates), PsiMethod.class, methodProcessor); index.processElements(key, JavaMethodElementType.TYPE_PARAMETER_PSEUDO_NAME, project, visibleFromCandidates, PsiMethod.class, methodProcessor); LOG.info("#methods: " + methods.size()); return methods; } }); }
public String[] getNames(@NotNull final Project project, final boolean includeNonProjectItems) { final Collection<String> names = new HashSet<String>(); for (final StubIndexKey<String, ?> indexKey : myIndexKeys) { names.addAll(StubIndexHelper.getInstance(indexKey).getAllKeys(project, includeNonProjectItems)); } return ArrayUtil.toStringArray(names); }
public NavigationItem[] getItemsByName(@NotNull final String name, @NotNull final String pattern, @NotNull final Project project, final boolean includeNonProjectItems) { final GlobalSearchScope scope = StubIndexHelper.createScope(project, includeNonProjectItems); final Collection<NavigationItem> items = new ArrayList<NavigationItem>(); for (final StubIndexKey<String, ? extends OCamlNamedElement> indexKey : myIndexKeys) { items.addAll(StubIndex.getInstance().get(indexKey, name, project, scope)); } return items.toArray(new NavigationItem[items.size()]); }
private static File getIndexDirectory(ID<?, ?> indexName, boolean forVersion) { final String dirName = indexName.toString().toLowerCase(Locale.US); // store StubIndices under StubUpdating index' root to ensure they are deleted // when StubUpdatingIndex version is changed final File indexDir = indexName instanceof StubIndexKey ? new File(getIndexRootDir(StubUpdatingIndex.INDEX_ID), forVersion ? STUB_VERSIONS : dirName) : new File(PathManager.getIndexRoot(), dirName); indexDir.mkdirs(); return indexDir; }
public static ID getStubId(ID<?, ?> indexName, FileType fileType) { if (StubUpdatingIndex.INDEX_ID.equals(indexName)) { String name = fileType.getName(); ID id = ID.findByName(name); if (id != null) { return id; } else { return StubIndexKey.createIndexKey(name); } } else { return indexName; } }
private static boolean isFoundAnyOneElement(@NotNull Project project, @NotNull final String indexKey, @NotNull StubIndexKey<String, DotNetQualifiedElement> keyForIndex, @NotNull GlobalSearchScope scope) { return !StubIndex.getInstance().processAllKeys(keyForIndex, s -> { ProgressManager.checkCanceled(); return !indexKey.equals(s); }, scope, new GlobalSearchScopeFilter(scope)); }
@Override public <Key, Psi extends PsiElement> boolean processElements(@Nonnull StubIndexKey<Key, Psi> indexKey, @Nonnull Key key, @Nonnull Project project, GlobalSearchScope scope, Class<Psi> requiredClass, @Nonnull Processor<? super Psi> processor) { return true; }
private static void doIndex(IndexSink sink, JSReferenceListStub stub, StubIndexKey<String, JSReferenceList> indexKey) { for(String s : stub.getReferenceTexts()) { if(s != null) { sink.occurrence(indexKey, StringUtil.getShortName(s)); } } }
@NotNull @Override public StubIndexKey<String, PsiLet> getKey() { return IndexKeys.LETS; }
@NotNull @Override public StubIndexKey<String, PsiType> getKey() { return IndexKeys.TYPES; }
@NotNull @Override public StubIndexKey<String, PsiModule> getKey() { return IndexKeys.MODULES; }
@NotNull @Override public StubIndexKey<String, SoyTemplateBlock> getKey() { return KEY; }
@NotNull @Override public StubIndexKey<String, SoyNamespaceDeclarationIdentifier> getKey() { return KEY; }
public WeexAttrDescriptor(String attributeName, List<String> enumValue, final StubIndexKey<String, JSImplicitElementProvider> index) { this.enumValue = enumValue; this.attributeName = attributeName; this.index = index; }
@NotNull public StubIndexKey<String, LuaDeclarationExpression> getKey() { return KEY; }
@NotNull @Override public StubIndexKey<String, FusionNamespaceDeclaration> getKey() { return KEY; }
@NotNull @Override public StubIndexKey<String, FusionPrototypeSignature> getKey() { return KEY; }
@NotNull @Override public StubIndexKey<String, DataType> getKey() { return KEY; }
@NotNull @Override public StubIndexKey<String, PsiReferenceList> getKey() { return JavaStubIndexKeys.SUPER_CLASSES; }
@NotNull @Override public StubIndexKey<String, PsiField> getKey() { return JavaStubIndexKeys.FIELDS; }
@NotNull @Override public StubIndexKey<Integer, PsiClass> getKey() { return JavaStubIndexKeys.CLASS_FQN; }
@NotNull @Override public StubIndexKey<String, PsiMember> getKey() { return JavaStubIndexKeys.JVM_STATIC_MEMBERS_NAMES; }
@NotNull @Override public StubIndexKey<String, PsiMethod> getKey() { return JavaStubIndexKeys.METHODS; }
@NotNull @Override public StubIndexKey<String, PsiAnnotation> getKey() { return JavaStubIndexKeys.ANNOTATIONS; }
@NotNull @Override public StubIndexKey<String, PsiMember> getKey() { return JavaStubIndexKeys.JVM_STATIC_MEMBERS_TYPES; }
@NotNull @Override public StubIndexKey<String, PsiMethod> getKey() { return JavaStubIndexKeys.METHOD_TYPES; }
@NotNull @Override public StubIndexKey<String, PsiClass> getKey() { return JavaStubIndexKeys.CLASS_SHORT_NAMES; }
@NotNull @Override public StubIndexKey<String, PsiAnonymousClass> getKey() { return JavaStubIndexKeys.ANONYMOUS_BASEREF; }
@NotNull public StubIndexKey<String, PyFunction> getKey() { return KEY; }
@NotNull @Override public StubIndexKey<String, PyClass> getKey() { return KEY; }
@NotNull public StubIndexKey<String, PyClass> getKey() { return KEY; }
@NotNull @Override public StubIndexKey<String, PyDecorator> getKey() { return KEY; }