当前位置: 首页>>代码示例>>Java>>正文


Java StubIndex类代码示例

本文整理汇总了Java中com.intellij.psi.stubs.StubIndex的典型用法代码示例。如果您正苦于以下问题:Java StubIndex类的具体用法?Java StubIndex怎么用?Java StubIndex使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


StubIndex类属于com.intellij.psi.stubs包,在下文中一共展示了StubIndex类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resolve

import com.intellij.psi.stubs.StubIndex; //导入依赖的package包/类
@Nullable
@Override
public PsiElement resolve() {
    PsiElement parent = PsiTreeUtil.getParentOfType(myElement, PsiLet.class);

    // If name is used in a let definition, it's already the reference
    if (parent instanceof PsiLet && ((PsiLet) parent).getNameIdentifier() == myElement) {
        return myElement;
    }

    // Find the name in the index
    Collection<PsiLet> elements = StubIndex.getElements(IndexKeys.LETS, m_referenceName, myElement.getProject(), GlobalSearchScope.allScope(myElement.getProject()), PsiLet.class);
    if (!elements.isEmpty()) {
        // TODO: only let with correct QN
        PsiLet let = elements.iterator().next();
        return let.getNameIdentifier();
    }

    return null;
}
 
开发者ID:reasonml-editor,项目名称:reasonml-idea-plugin,代码行数:21,代码来源:PsiVarNameReference.java

示例2: complete

import com.intellij.psi.stubs.StubIndex; //导入依赖的package包/类
static void complete(Project project, PsiModuleName name, @NotNull CompletionResultSet resultSet) {
    // Get the correct module
    Collection<PsiModule> modules = StubIndex.getElements(IndexKeys.MODULES, name.getName(), project, GlobalSearchScope.allScope(project), PsiModule.class);

    if (!modules.isEmpty()) {
        for (PsiModule module : modules) {
            Collection<PsiNamedElement> expressions = module.getExpressions();

            for (PsiNamedElement expression : expressions) {
                resultSet.addElement(
                        LookupElementBuilder.create(expression).
                                withIcon(PsiIconUtil.getProvidersIcon(expression, 0)).
                                withTypeText(PsiInferredTypeUtil.getTypeInfo(expression))
                );
            }
        }
    }
}
 
开发者ID:reasonml-editor,项目名称:reasonml-idea-plugin,代码行数:19,代码来源:ModuleDotCompletionProvider.java

示例3: buildModel

import com.intellij.psi.stubs.StubIndex; //导入依赖的package包/类
@NotNull
public TSMetaModelImpl buildModel() {
    myResult = new TSMetaModelImpl();
    myFiles.clear();

    StubIndex.getInstance().processElements(
        DomElementClassIndex.KEY,
        Items.class.getName(),
        myProject,
        ProjectScope.getAllScope(myProject),
        PsiFile.class,
        this
    );
    final TSMetaModelImpl result = myResult;
    myResult = null;
    return result;
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:18,代码来源:TSMetaModelBuilder.java

示例4: getValueDeclaration

import com.intellij.psi.stubs.StubIndex; //导入依赖的package包/类
@Override
public PsiElement getValueDeclaration(XmlElement xmlElement, String value) {
  CatberryProjectConfigurationManager configurationManager = CatberryProjectConfigurationManager.getInstance(project);
  PsiDirectory directory = configurationManager.getStoresDirectory();
  if(directory == null)
    return super.getValueDeclaration(xmlElement, value);
  final String requiredPath = directory.getVirtualFile().getPath() + "/" + value+".js";

  int index = value.lastIndexOf('/');
  String className = index == -1 ? value : value.substring(index+1);
  Collection<JSElement> elements = StubIndex.getElements(JSClassIndex.KEY, className, project,
      GlobalSearchScope.allScope(project), JSElement.class);

  for(JSElement element : elements) {
    if (element instanceof JSClass &&  element.getContainingFile().getVirtualFile().getPath().equals(requiredPath))
      return element;
  }
  return super.getValueDeclaration(xmlElement, value);
}
 
开发者ID:catberry,项目名称:catberry-idea-plugin,代码行数:20,代码来源:CatberryAttributeDescriptor.java

示例5: findNamespaceByAlias

import com.intellij.psi.stubs.StubIndex; //导入依赖的package包/类
@Nullable
private static String findNamespaceByAlias(Project project, String alias) {
    Collection<FusionNamespaceDeclaration> namespaces = StubIndex.getElements(
            FusionNamespaceDeclarationIndex.KEY,
            alias,
            project,
            GlobalSearchScope.projectScope(project),
            FusionNamespaceDeclaration.class);

    if (!namespaces.isEmpty()) {
        FusionNamespace namespace = namespaces.iterator().next().getNamespace();
        if (namespace != null) {
            return namespace.getText();
        }
    }

    return null;
}
 
开发者ID:cvette,项目名称:intellij-neos,代码行数:19,代码来源:ResolveEngine.java

示例6: getMethodsByNameIfNotMoreThan

import com.intellij.psi.stubs.StubIndex; //导入依赖的package包/类
@Override
@NotNull
public PsiMethod[] getMethodsByNameIfNotMoreThan(@NonNls @NotNull final String name, @NotNull final GlobalSearchScope scope, final int maxCount) {
  final List<PsiMethod> methods = new SmartList<PsiMethod>();
  StubIndex.getInstance().processElements(JavaStubIndexKeys.METHODS, name, myManager.getProject(), scope, PsiMethod.class, new
                                          CommonProcessors.CollectProcessor < PsiMethod > (methods){
  @Override
    public boolean process(PsiMethod method) {
      return methods.size() != maxCount && super.process(method);
    }
  });
  if (methods.isEmpty()) return PsiMethod.EMPTY_ARRAY;

  List<PsiMethod> list = filterMembers(methods, scope);
  return list.toArray(new PsiMethod[list.size()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:PsiShortNamesCacheImpl.java

示例7: getFieldsByNameIfNotMoreThan

import com.intellij.psi.stubs.StubIndex; //导入依赖的package包/类
@Override
@NotNull
public PsiField[] getFieldsByNameIfNotMoreThan(@NotNull String name, @NotNull final GlobalSearchScope scope, final int maxCount) {
  final List<PsiField> methods = new SmartList<PsiField>();
  StubIndex.getInstance().processElements(JavaStubIndexKeys.FIELDS, name, myManager.getProject(), scope, PsiField.class, new
                                          CommonProcessors.CollectProcessor < PsiField > (methods){
  @Override
    public boolean process(PsiField method) {
      return methods.size() != maxCount && super.process(method);
    }
  });
  if (methods.isEmpty()) return PsiField.EMPTY_ARRAY;

  List<PsiField> list = filterMembers(methods, scope);
  return list.toArray(new PsiField[list.size()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:PsiShortNamesCacheImpl.java

示例8: addVariantsFromIndex

import com.intellij.psi.stubs.StubIndex; //导入依赖的package包/类
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));
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:PyClassNameCompletionContributor.java

示例9: hasStubElementsOfType

import com.intellij.psi.stubs.StubIndex; //导入依赖的package包/类
public boolean hasStubElementsOfType(final DomFileElement domFileElement,
                                     final Class<? extends DomElement> clazz) {
  final VirtualFile file = domFileElement.getFile().getVirtualFile();
  if (!(file instanceof VirtualFileWithId)) return false;

  final String clazzName = clazz.getName();
  final int virtualFileId = ((VirtualFileWithId)file).getId();

  CommonProcessors.FindFirstProcessor<? super PsiFile> processor =
    new CommonProcessors.FindFirstProcessor<PsiFile>();
  StubIndex.getInstance().processElements(KEY, clazzName,
                                          domFileElement.getFile().getProject(),
                                          GlobalSearchScope.fileScope(domFileElement.getFile()),
                                          new IdFilter() {
                                            @Override
                                            public boolean containsFileId(int id) {
                                              return id == virtualFileId;
                                            }
                                          },
                                          PsiFile.class, 
                                          processor
  );

  return processor.isFound();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:DomElementClassIndex.java

示例10: hasStubElementsWithNamespaceKey

import com.intellij.psi.stubs.StubIndex; //导入依赖的package包/类
public boolean hasStubElementsWithNamespaceKey(final DomFileElement domFileElement, final String namespaceKey) {
  final VirtualFile file = domFileElement.getFile().getVirtualFile();
  if (!(file instanceof VirtualFileWithId)) return false;

  final int virtualFileId = ((VirtualFileWithId)file).getId();
  CommonProcessors.FindFirstProcessor<PsiFile> processor = new CommonProcessors.FindFirstProcessor<PsiFile>();
  StubIndex.getInstance().processElements(
    KEY,
    namespaceKey,
    domFileElement.getFile().getProject(),
    GlobalSearchScope.fileScope(domFileElement.getFile()),
    new IdFilter() {
      @Override
      public boolean containsFileId(int id) {
        return id == virtualFileId;
      }
    },
    PsiFile.class, 
    processor
  );
  return processor.isFound();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:DomNamespaceKeyIndex.java

示例11: getScriptClassesByFQName

import com.intellij.psi.stubs.StubIndex; //导入依赖的package包/类
public List<PsiClass> getScriptClassesByFQName(final String name, final GlobalSearchScope scope, final boolean srcOnly) {
  GlobalSearchScope actualScope = srcOnly ? new GrSourceFilterScope(scope) : scope;
  final Collection<GroovyFile> files = StubIndex.getElements(GrFullScriptNameIndex.KEY, name.hashCode(), myProject, actualScope,
                                                             GroovyFile.class);
  if (files.isEmpty()) {
    return Collections.emptyList();
  }

  final ArrayList<PsiClass> result = new ArrayList<PsiClass>();
  for (GroovyFile file : files) {
    if (file.isScript()) {
      final PsiClass scriptClass = file.getScriptClass();
      if (scriptClass != null && name.equals(scriptClass.getQualifiedName())) {
        result.add(scriptClass);
      }
    }
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:GroovyShortNamesCache.java

示例12: getDerivingClassCandidates

import com.intellij.psi.stubs.StubIndex; //导入依赖的package包/类
@NotNull
private static List<PsiClass> getDerivingClassCandidates(PsiClass clazz, GlobalSearchScope scope, boolean includeAnonymous) {
  final String name = clazz.getName();
  if (name == null) return Collections.emptyList();
  final ArrayList<PsiClass> inheritors = new ArrayList<PsiClass>();
  for (GrReferenceList list : StubIndex.getElements(GrDirectInheritorsIndex.KEY, name, clazz.getProject(), scope,
                                                    GrReferenceList.class)) {
    final PsiElement parent = list.getParent();
    if (parent instanceof GrTypeDefinition) {
      inheritors.add((PsiClass)parent);
    }
  }
  if (includeAnonymous) {
    final Collection<GrAnonymousClassDefinition> classes =
      StubIndex.getElements(GrAnonymousClassIndex.KEY, name, clazz.getProject(), scope, GrAnonymousClassDefinition.class);
    for (GrAnonymousClassDefinition aClass : classes) {
      inheritors.add(aClass);
    }
  }
  return inheritors;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:GroovyDirectInheritorsSearcher.java

示例13: findTestFunction

import com.intellij.psi.stubs.StubIndex; //导入依赖的package包/类
/**
 * @param path for function "TestFoo" in target "//foo/bar:baz" would be "foo/bar/baz::TestFoo".
 *     See {@link BlazeGoTestEventsHandler#testLocationUrl}.
 */
@SuppressWarnings("rawtypes")
private static List<Location> findTestFunction(Project project, String path) {
  String[] parts = path.split(SmRunnerUtils.TEST_NAME_PARTS_SPLITTER);
  if (parts.length != 2) {
    return ImmutableList.of();
  }
  String functionName = parts[1];
  TargetIdeInfo target = getGoTestTarget(project, parts[0]);
  List<VirtualFile> goFiles = getGoFiles(project, target);
  if (goFiles.isEmpty()) {
    return ImmutableList.of();
  }
  GlobalSearchScope scope = FilesScope.filesScope(project, goFiles);
  Collection<GoFunctionDeclaration> functions =
      StubIndex.getElements(
          GoFunctionIndex.KEY, functionName, project, scope, GoFunctionDeclaration.class);
  return functions.stream().map(PsiLocation::new).collect(Collectors.toList());
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:23,代码来源:BlazeGoTestLocator.java

示例14: getAllKeysInScope

import com.intellij.psi.stubs.StubIndex; //导入依赖的package包/类
@NotNull
public Collection<Key> getAllKeysInScope(@NotNull final Project project, @NotNull final GlobalSearchScope scope) {
    final StubIndex stubIndex = StubIndex.getInstance();

    final Collection<Key> allKeys = new HashSet<Key>();
    allKeys.addAll(stubIndex.getAllKeys(myIndexKey, project));

    final Iterator<Key> iterator = allKeys.iterator();
    while (iterator.hasNext()) {
        final Key key = iterator.next();
        if (stubIndex.get(myIndexKey, key, project, scope).isEmpty()) {
            iterator.remove();
        }
    }

    return allKeys;
}
 
开发者ID:traff,项目名称:intellij-ocaml,代码行数:18,代码来源:StubIndexHelper.java

示例15: findAllRobotKeywordDefsInRobotFilesStartingWith

import com.intellij.psi.stubs.StubIndex; //导入依赖的package包/类
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);
}
 
开发者ID:charlescapps,项目名称:robot-intellij-plugin,代码行数:23,代码来源:RobotPsiUtil.java


注:本文中的com.intellij.psi.stubs.StubIndex类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。