本文整理汇总了Java中com.intellij.psi.stubs.StubIndex.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java StubIndex.getInstance方法的具体用法?Java StubIndex.getInstance怎么用?Java StubIndex.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.stubs.StubIndex
的用法示例。
在下文中一共展示了StubIndex.getInstance方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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);
}
示例3: findMatchingKeywordDefsByName
import com.intellij.psi.stubs.StubIndex; //导入方法依赖的package包/类
public static List<RobotKeywordTitle> findMatchingKeywordDefsByName(String name, Project project, boolean isSearchTextFromRobotFile) {
final StubIndex STUB_INDEX = StubIndex.getInstance();
final String normalizedName = normalizeRobotDefinedKeywordForIndex(name);
List<PsiElement> results = Lists.newArrayList();
RobotKeywordDefProcessor processor = new RobotKeywordDefProcessor(results, SearchType.FIND_ALL_EXACT_MATCHES, name);
STUB_INDEX.processElements(RobotKeywordTitleNormalizedNameIndex.KEY, normalizedName, project,
GlobalSearchScope.allScope(project), RobotKeywordTitle.class, processor);
if (isSearchTextFromRobotFile) {
Optional<RobotKeywordTitle> embeddedKeywordTitle = findFirstMatchInEmbeddedArgsIndex(name, project);
if (embeddedKeywordTitle.isPresent()) {
results.add(embeddedKeywordTitle.get());
}
}
List<RobotKeywordTitle> keywordTitleResults = Lists.newArrayList();
for (PsiElement result: results) {
if (result instanceof RobotKeywordTitle) {
keywordTitleResults.add((RobotKeywordTitle)result);
}
}
return keywordTitleResults;
}
示例4: findFirstMatchInEmbeddedArgsIndex
import com.intellij.psi.stubs.StubIndex; //导入方法依赖的package包/类
private static Optional<RobotKeywordTitle> findFirstMatchInEmbeddedArgsIndex(String name, Project project) {
final String normalizedKeyword = normalizeEmbeddedArgKeyword(name);
final StubIndex STUB_INDEX = StubIndex.getInstance();
final Collection<String> KEYS = STUB_INDEX.getAllKeys(RobotKeywordTitleEmbeddedArgsIndex.KEY, project);
for (String key: KEYS) {
Collection<RobotKeywordTitle> keywordsWithEmbeddedArgs = StubIndex.getElements(RobotKeywordTitleEmbeddedArgsIndex.KEY, key, project, GlobalSearchScope.allScope(project), RobotKeywordTitle.class);
for (RobotKeywordTitle keyword: keywordsWithEmbeddedArgs) {
String regex = keyword.getRegex();
Pattern pattern = Pattern.compile(regex);
if (pattern.matcher(normalizedKeyword).matches()) {
return Optional.of(keyword);
}
}
}
return Optional.absent();
}
示例5: findTestCasesByName
import com.intellij.psi.stubs.StubIndex; //导入方法依赖的package包/类
public static List<RobotTestCase> findTestCasesByName(String name, Project project) {
final StubIndex STUB_INDEX = StubIndex.getInstance();
final String normalizedName = normalizeKeywordForIndex(name);
List<RobotTestCase> results = Lists.newArrayList();
RobotTestCaseProcessor processor = new RobotTestCaseProcessor(results, SearchType.FIND_ALL, name);
STUB_INDEX.processElements(RobotTestCaseNormalizedNameIndex.KEY, normalizedName, project,
GlobalSearchScope.allScope(project), RobotTestCase.class, processor);
return results;
}
示例6: findAllRobotKeywordDefsInRobotFiles
import com.intellij.psi.stubs.StubIndex; //导入方法依赖的package包/类
public static void findAllRobotKeywordDefsInRobotFiles(Project project, List<PsiElement> results) {
final StubIndex STUB_INDEX = StubIndex.getInstance();
Collection<String> keys = STUB_INDEX.getAllKeys(RobotKeywordTitleNormalizedNameIndex.KEY, project);
for (String key : keys) {
Collection<RobotKeywordTitle> defsForKey = StubIndex.getElements(RobotKeywordTitleNormalizedNameIndex.KEY, key,
project, GlobalSearchScope.allScope(project), RobotKeywordTitle.class);
results.addAll(defsForKey);
}
}
示例7: findKeywordDefsByName
import com.intellij.psi.stubs.StubIndex; //导入方法依赖的package包/类
public static void findKeywordDefsByName(String name, Project project, List<PsiElement> results) {
final StubIndex STUB_INDEX = StubIndex.getInstance();
final String normalizedName = normalizeRobotDefinedKeywordForIndex(name);
RobotKeywordDefProcessor processor = new RobotKeywordDefProcessor(results, SearchType.FIRST_EXACT_MATCH, name);
STUB_INDEX.processElements(RobotKeywordTitleNormalizedNameIndex.KEY, normalizedName, project,
GlobalSearchScope.allScope(project), RobotKeywordTitle.class, processor);
}
示例8: findUniqueKeywordDefByName
import com.intellij.psi.stubs.StubIndex; //导入方法依赖的package包/类
public static Optional<RobotKeywordTitle> findUniqueKeywordDefByName(String name, Project project, boolean isSearchTextFromRobotFile) {
final StubIndex STUB_INDEX = StubIndex.getInstance();
final String normalizedName = normalizeRobotDefinedKeywordForIndex(name);
List<PsiElement> results = Lists.newArrayList();
RobotKeywordDefProcessor processor = new RobotKeywordDefProcessor(results, SearchType.FIRST_EXACT_MATCH, name);
STUB_INDEX.processElements(RobotKeywordTitleNormalizedNameIndex.KEY, normalizedName, project,
GlobalSearchScope.allScope(project), RobotKeywordTitle.class, processor);
if (results.size() > 0) {
return Optional.of((RobotKeywordTitle) results.get(0));
}
if (!isSearchTextFromRobotFile) {
return Optional.absent();
}
return findFirstMatchInEmbeddedArgsIndex(name, project);
}
示例9: findKeywordUsagesByNormalizedName
import com.intellij.psi.stubs.StubIndex; //导入方法依赖的package包/类
private static List<RobotKeyword> findKeywordUsagesByNormalizedName(String normalizedKeywordName, Project project, boolean findAll) {
final StubIndex STUB_INDEX = StubIndex.getInstance();
GlobalSearchScope robotFileScope = GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.projectScope(project), RobotFileType.INSTANCE);
RobotKeywordProcessor processor = new RobotKeywordProcessor(normalizedKeywordName, findAll);
STUB_INDEX.processElements(RobotKeywordNormalizedNameIndex.KEY, normalizedKeywordName, project, robotFileScope,
RobotKeyword.class, processor);
return processor.getResults();
}
示例10: findKeywordUsagesInKeywordArgs
import com.intellij.psi.stubs.StubIndex; //导入方法依赖的package包/类
public static List<RobotKeywordArg> findKeywordUsagesInKeywordArgs(String normalizedKeywordName, Project project, boolean findAll) {
final StubIndex STUB_INDEX = StubIndex.getInstance();
GlobalSearchScope robotFileScope = GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.projectScope(project), RobotFileType.INSTANCE);
// Find usages of Robot Keywords in Robot Keyword Args
RobotKeywordArgProcessor keywordArgProcessor = new RobotKeywordArgProcessor(normalizedKeywordName, findAll);
STUB_INDEX.processElements(RobotKeywordArgNormalizedNameIndex.KEY, normalizedKeywordName, project, robotFileScope,
RobotKeywordArg.class, keywordArgProcessor);
return keywordArgProcessor.getResults();
}
示例11: findKeywordUsagesOfKeywordWithEmbeddedArgs
import com.intellij.psi.stubs.StubIndex; //导入方法依赖的package包/类
public static List<RobotKeyword> findKeywordUsagesOfKeywordWithEmbeddedArgs(RobotKeywordTitle robotKeywordTitle) {
final StubIndex STUB_INDEX = StubIndex.getInstance();
final Project project = robotKeywordTitle.getProject();
final Pattern REGEX = Pattern.compile(robotKeywordTitle.getRegex());
final Collection<String> allKeywords = STUB_INDEX.getAllKeys(RobotKeywordNormalizedNameIndex.KEY, project);
final GlobalSearchScope PROJECT_ROBOT_FILES = GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.projectScope(project), RobotFileType.INSTANCE);
final RobotKeywordEmbeddedArgsProcessor processor = new RobotKeywordEmbeddedArgsProcessor(REGEX, true);
for (String keyword: allKeywords) {
STUB_INDEX.processElements(RobotKeywordNormalizedNameIndex.KEY,
keyword, project, PROJECT_ROBOT_FILES, RobotKeyword.class, processor);
}
return processor.getResults();
}
示例12: findAllJavaKeywordsStartingWithUsingWordIndex
import com.intellij.psi.stubs.StubIndex; //导入方法依赖的package包/类
public static void findAllJavaKeywordsStartingWithUsingWordIndex(Project project, List<PsiElement> results, String startsWith, boolean wrapPsiMethods) {
// First process the stub index that has all Java files in the current project
final StubIndex STUB_INDEX = StubIndex.getInstance();
GlobalSearchScope javaFiles = GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.projectScope(project), JavaFileType.INSTANCE);
RobotKeywordPsiAnnotationProcessor processor = new RobotKeywordPsiAnnotationProcessor(results, SearchType.STARTS_WITH, Optional.of(startsWith), wrapPsiMethods);
STUB_INDEX.processElements(JavaStubIndexKeys.ANNOTATIONS, ROBOT_KEYWORD_ANNOTATION_SHORT, project, javaFiles, PsiAnnotation.class, processor);
// Next, attempt to find Keywords from external sources using the Word Index on the word "RobotKeyword".
PsiSearchHelper PSI_SEARCH_HELPER = PsiSearchHelper.SERVICE.getInstance(project);
GlobalSearchScope outsideProjectScope = GlobalSearchScope.allScope(project).intersectWith(GlobalSearchScope.notScope(GlobalSearchScope.projectScope(project)));
GlobalSearchScope javaOutsideProjectScope = GlobalSearchScope.getScopeRestrictedByFileTypes(outsideProjectScope, JavaFileType.INSTANCE);
TextOccurenceProcessor textOccurenceProcessor = new RobotAnnotationTextOccurrenceProcessor(results, SearchType.FIND_ALL, Optional.of(startsWith), wrapPsiMethods);
PSI_SEARCH_HELPER.processElementsWithWord(textOccurenceProcessor, javaOutsideProjectScope, ROBOT_KEYWORD_ANNOTATION_SHORT, UsageSearchContext.IN_CODE, true);
}