Java 类com.intellij.psi.stubs.StubIndexKey 实例源码

项目:intellij-ce-playground    文件:IndexInfrastructure.java   
@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;
}
项目:intellij-ce-playground    文件:PyClassNameCompletionContributor.java   
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));
      }
    }
  }
}
项目:robot-intellij-plugin    文件:RobotPsiUtil.java   
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);
}
项目:consulo-dotnet    文件:DotNetNamespaceStubUtil.java   
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);
    }
}
项目:consulo    文件:CompilerServerStubIndexImpl.java   
@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;
    }
  };
}
项目:consulo    文件:IndexInfrastructure.java   
@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;
}
项目:intellij-ce-playground    文件:JavaFunctionalExpressionSearcher.java   
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;
      }
    });
}
项目:intellij-ocaml    文件:BaseOCamlChooseByNameContributor.java   
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);
}
项目:intellij-ocaml    文件:BaseOCamlChooseByNameContributor.java   
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()]);
}
项目:tools-idea    文件:IndexInfrastructure.java   
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;
}
项目:tools-idea    文件:IndexInfrastructure.java   
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;
  }
}
项目:consulo-dotnet    文件:IndexBasedDotNetPsiSearcher.java   
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));
}
项目:consulo    文件:CompilerServerStubIndexImpl.java   
@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;
}
项目:consulo-javascript    文件:JSReferenceListElementType.java   
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));
        }
    }
}
项目:reasonml-idea-plugin    文件:LetIndex.java   
@NotNull
@Override
public StubIndexKey<String, PsiLet> getKey() {
    return IndexKeys.LETS;
}
项目:reasonml-idea-plugin    文件:TypeIndex.java   
@NotNull
@Override
public StubIndexKey<String, PsiType> getKey() {
    return IndexKeys.TYPES;
}
项目:reasonml-idea-plugin    文件:ModuleIndex.java   
@NotNull
@Override
public StubIndexKey<String, PsiModule> getKey() {
    return IndexKeys.MODULES;
}
项目:bamboo-soy    文件:TemplateBlockIndex.java   
@NotNull
@Override
public StubIndexKey<String, SoyTemplateBlock> getKey() {
  return KEY;
}
项目:bamboo-soy    文件:NamespaceDeclarationIndex.java   
@NotNull
@Override
public StubIndexKey<String, SoyNamespaceDeclarationIdentifier> getKey() {
  return KEY;
}
项目:weex-language-support    文件:WeexAttrDescriptor.java   
public WeexAttrDescriptor(String attributeName, List<String> enumValue, final StubIndexKey<String, JSImplicitElementProvider> index) {
    this.enumValue = enumValue;
    this.attributeName = attributeName;
    this.index = index;
}
项目:lua-for-idea    文件:LuaGlobalDeclarationIndex.java   
@NotNull
public StubIndexKey<String, LuaDeclarationExpression> getKey() {
    return KEY;
}
项目:intellij-neos    文件:FusionNamespaceDeclarationIndex.java   
@NotNull
@Override
public StubIndexKey<String, FusionNamespaceDeclaration> getKey() {
    return KEY;
}
项目:intellij-neos    文件:FusionPrototypeDeclarationIndex.java   
@NotNull
@Override
public StubIndexKey<String, FusionPrototypeSignature> getKey() {
    return KEY;
}
项目:protobuf-jetbrains-plugin    文件:DataTypeNameIndex.java   
@NotNull
@Override
public StubIndexKey<String, DataType> getKey() {
    return KEY;
}
项目:protobuf-jetbrains-plugin    文件:DataTypeFullNameIndex.java   
@NotNull
@Override
public StubIndexKey<String, DataType> getKey() {
    return KEY;
}
项目:intellij-ce-playground    文件:JavaSuperClassNameOccurenceIndex.java   
@NotNull
@Override
public StubIndexKey<String, PsiReferenceList> getKey() {
  return JavaStubIndexKeys.SUPER_CLASSES;
}
项目:intellij-ce-playground    文件:JavaFieldNameIndex.java   
@NotNull
@Override
public StubIndexKey<String, PsiField> getKey() {
  return JavaStubIndexKeys.FIELDS;
}
项目:intellij-ce-playground    文件:JavaFullClassNameIndex.java   
@NotNull
@Override
public StubIndexKey<Integer, PsiClass> getKey() {
  return JavaStubIndexKeys.CLASS_FQN;
}
项目:intellij-ce-playground    文件:JavaStaticMemberNameIndex.java   
@NotNull
@Override
public StubIndexKey<String, PsiMember> getKey() {
  return JavaStubIndexKeys.JVM_STATIC_MEMBERS_NAMES;
}
项目:intellij-ce-playground    文件:JavaMethodNameIndex.java   
@NotNull
@Override
public StubIndexKey<String, PsiMethod> getKey() {
  return JavaStubIndexKeys.METHODS;
}
项目:intellij-ce-playground    文件:JavaAnnotationIndex.java   
@NotNull
@Override
public StubIndexKey<String, PsiAnnotation> getKey() {
  return JavaStubIndexKeys.ANNOTATIONS;
}
项目:intellij-ce-playground    文件:JavaStaticMemberTypeIndex.java   
@NotNull
@Override
public StubIndexKey<String, PsiMember> getKey() {
  return JavaStubIndexKeys.JVM_STATIC_MEMBERS_TYPES;
}
项目:intellij-ce-playground    文件:JavaMethodParameterTypesIndex.java   
@NotNull
@Override
public StubIndexKey<String, PsiMethod> getKey() {
  return JavaStubIndexKeys.METHOD_TYPES;
}
项目:intellij-ce-playground    文件:JavaShortClassNameIndex.java   
@NotNull
@Override
public StubIndexKey<String, PsiClass> getKey() {
  return JavaStubIndexKeys.CLASS_SHORT_NAMES;
}
项目:intellij-ce-playground    文件:JavaAnonymousClassBaseRefOccurenceIndex.java   
@NotNull
@Override
public StubIndexKey<String, PsiAnonymousClass> getKey() {
  return JavaStubIndexKeys.ANONYMOUS_BASEREF;
}
项目:intellij-ce-playground    文件:PyFunctionNameIndex.java   
@NotNull
public StubIndexKey<String, PyFunction> getKey() {
  return KEY;
}
项目:intellij-ce-playground    文件:PyClassAttributesIndex.java   
@NotNull
@Override
public StubIndexKey<String, PyClass> getKey() {
  return KEY;
}
项目:intellij-ce-playground    文件:PyClassNameIndexInsensitive.java   
@NotNull
@Override
public StubIndexKey<String, PyClass> getKey() {
  return KEY;
}
项目:intellij-ce-playground    文件:PySuperClassIndex.java   
@NotNull
public StubIndexKey<String, PyClass> getKey() {
  return KEY;
}
项目:intellij-ce-playground    文件:PyDecoratorStubIndex.java   
@NotNull
@Override
public StubIndexKey<String, PyDecorator> getKey() {
  return KEY;
}