本文整理汇总了Java中com.intellij.util.indexing.FileBasedIndex类的典型用法代码示例。如果您正苦于以下问题:Java FileBasedIndex类的具体用法?Java FileBasedIndex怎么用?Java FileBasedIndex使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileBasedIndex类属于com.intellij.util.indexing包,在下文中一共展示了FileBasedIndex类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generate
import com.intellij.util.indexing.FileBasedIndex; //导入依赖的package包/类
@Override
public Set<TSVarExpr> generate(Project project) {
Set<TSVarExpr> items = new HashSet<>();
//Search every file in the project
Collection<VirtualFile> virtualFiles = FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, TSFileType.INSTANCE, GlobalSearchScope.projectScope(project));
for (VirtualFile virtualFile : virtualFiles) {
TSFile tsFile = (TSFile) PsiManager.getInstance(project).findFile(virtualFile);
if (tsFile != null) {
Collection<TSAssignExpr> assignments = PsiTreeUtil.findChildrenOfType(tsFile, TSAssignExpr.class);
for (TSAssignExpr assignment : assignments) {
PsiElement first = assignment.getFirstChild();
if (!(first instanceof TSVarExpr))
continue;
if (((TSVarExpr)first).isLocal())
continue;
items.add((TSVarExpr) first);
}
}
ProgressManager.progress("Loading Symbols");
}
return items;
}
示例2: getTargetMethods
import com.intellij.util.indexing.FileBasedIndex; //导入依赖的package包/类
@NotNull
private static PsiElement[] getTargetMethods(@NotNull Project project, @NotNull String routeName) {
List<PsiElement> result = new ArrayList<>();
List<RouteStub> values = FileBasedIndex.getInstance().getValues(RouteIndex.KEY, routeName, GlobalSearchScope.allScope(project));
PhpIndex phpIndex = PhpIndex.getInstance(project);
for (RouteStub routeStub : values) {
String fqn = routeStub.getController();
Collection<PhpClass> classesByFQN = phpIndex.getClassesByFQN(fqn);
classesByFQN.forEach(c -> {
if (c.findMethodByName(routeStub.getMethod()) != null) {
result.add(c.findMethodByName(routeStub.getMethod()));
}
});
}
return result.toArray(new PsiElement[result.size()]);
}
示例3: projectOpened
import com.intellij.util.indexing.FileBasedIndex; //导入依赖的package包/类
@Override
public void projectOpened() {
TYPO3CMSSettings instance = TYPO3CMSSettings.getInstance(project);
IdeaPluginDescriptor plugin = PluginManager.getPlugin(PluginId.getId("com.cedricziel.idea.typo3"));
if (plugin == null) {
return;
}
String version = instance.getVersion();
if (version == null || !plugin.getVersion().equals(version)) {
instance.setVersion(plugin.getVersion());
FileBasedIndex index = FileBasedIndex.getInstance();
index.scheduleRebuild(CoreServiceMapStubIndex.KEY, new Throwable());
index.scheduleRebuild(ExtensionNameStubIndex.KEY, new Throwable());
index.scheduleRebuild(IconIndex.KEY, new Throwable());
index.scheduleRebuild(ResourcePathIndex.KEY, new Throwable());
index.scheduleRebuild(RouteIndex.KEY, new Throwable());
index.scheduleRebuild(TablenameFileIndex.KEY, new Throwable());
index.scheduleRebuild(LegacyClassesForIDEIndex.KEY, new Throwable());
index.scheduleRebuild(MethodArgumentDroppedIndex.KEY, new Throwable());
index.scheduleRebuild(ControllerActionIndex.KEY, new Throwable());
}
}
示例4: findDefinitionElements
import com.intellij.util.indexing.FileBasedIndex; //导入依赖的package包/类
public static PsiElement[] findDefinitionElements(@NotNull Project project, @NotNull String translationId) {
Set<String> keys = new HashSet<>();
keys.add(translationId);
List<PsiElement> elements = new ArrayList<>();
FileBasedIndex.getInstance().getFilesWithKey(TranslationIndex.KEY, keys, virtualFile -> {
FileBasedIndex.getInstance().processValues(TranslationIndex.KEY, translationId, virtualFile, (file, value) -> {
PsiFile file1 = PsiManager.getInstance(project).findFile(file);
if (file1 != null) {
PsiElement elementAt = file1.findElementAt(value.getTextRange().getStartOffset());
if (elementAt != null) {
elements.add(elementAt.getParent());
}
}
return true;
}, GlobalSearchScope.allScope(project));
return true;
}, GlobalSearchScope.allScope(project));
return elements.toArray(new PsiElement[elements.size()]);
}
示例5: getTableDefinitionElements
import com.intellij.util.indexing.FileBasedIndex; //导入依赖的package包/类
public static PsiElement[] getTableDefinitionElements(@NotNull String tableName, @NotNull Project project) {
PsiFile[] extTablesSqlFilesInProjectContainingTable = getExtTablesSqlFilesInProjectContainingTable(tableName, project);
Set<PsiElement> elements = new HashSet<>();
PsiManager psiManager = PsiManager.getInstance(project);
for (PsiFile virtualFile : extTablesSqlFilesInProjectContainingTable) {
FileBasedIndex.getInstance().processValues(TablenameFileIndex.KEY, tableName, virtualFile.getVirtualFile(), (file, value) -> {
PsiFile file1 = psiManager.findFile(file);
if (file1 != null) {
PsiElement elementAt = file1.findElementAt(value.getEndOffset() - 2);
if (elementAt != null) {
elements.add(elementAt);
}
}
return true;
}, GlobalSearchScope.allScope(project));
}
return elements.toArray(new PsiElement[elements.size()]);
}
示例6: getDefinitionElements
import com.intellij.util.indexing.FileBasedIndex; //导入依赖的package包/类
public static PsiElement[] getDefinitionElements(@NotNull Project project, @NotNull String actionName) {
Set<String> keys = new HashSet<>();
keys.add(actionName);
List<PsiElement> elements = new ArrayList<>();
FileBasedIndex.getInstance().getFilesWithKey(ControllerActionIndex.KEY, keys, virtualFile -> {
FileBasedIndex.getInstance().processValues(ControllerActionIndex.KEY, actionName, virtualFile, (file, value) -> {
PsiFile file1 = PsiManager.getInstance(project).findFile(file);
if (file1 != null) {
PsiElement elementAt = file1.findElementAt(value.getTextRange().getStartOffset());
if (elementAt != null) {
elements.add(elementAt.getParent().getParent());
}
}
return true;
}, GlobalSearchScope.allScope(project));
return true;
}, GlobalSearchScope.allScope(project));
return elements.toArray(new PsiElement[elements.size()]);
}
示例7: collectServices
import com.intellij.util.indexing.FileBasedIndex; //导入依赖的package包/类
private void collectServices(Project project) {
FileBasedIndex index = FileBasedIndex.getInstance();
Collection<VirtualFile> containingFiles = index.getContainingFiles(
FileTypeIndex.NAME,
PhpFileType.INSTANCE,
GlobalSearchScope.allScope(project)
);
containingFiles.removeIf(virtualFile -> !(virtualFile.getName().contains("ext_localconf.php")));
for (VirtualFile projectFile : containingFiles) {
PsiFile psiFile = PsiManager.getInstance(project).findFile(projectFile);
if (psiFile != null) {
psiFile.accept(new CoreServiceDefinitionParserVisitor(serviceMap));
}
}
}
示例8: findProperties
import com.intellij.util.indexing.FileBasedIndex; //导入依赖的package包/类
public static List<GCMTypeDeclaration> findProperties(Project project) {
final List<GCMTypeDeclaration> result = new ArrayList<GCMTypeDeclaration>();
Collection<VirtualFile> virtualFiles = FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, GCMLanguageType.INSTANCE,
GlobalSearchScope.allScope(project));
for (VirtualFile virtualFile : virtualFiles) {
GCMFile simpleFile = (GCMFile) PsiManager.getInstance(project).findFile(virtualFile);
if (simpleFile != null) {
simpleFile.acceptChildren(new PsiElementVisitor() {
@Override
public void visitElement(PsiElement element) {
if (element instanceof GCMDeclaration) {
GCMDeclaration declaration = (GCMDeclaration) element;
if (declaration.getClassDeclaration() != null) {
result.add(declaration.getClassDeclaration().getTypeDeclaration());
}
if (declaration.getCustomTypeDeclaration() != null) {
//result.add(declaration.getCustomTypeDeclaration().getTypeDeclaration());
}
}
super.visitElement(element);
}
});
}
}
return result;
}
示例9: getVirtualTypeElements
import com.intellij.util.indexing.FileBasedIndex; //导入依赖的package包/类
public Collection<PsiElement> getVirtualTypeElements(final String name, final GlobalSearchScope scope) {
Collection<PsiElement> result = new ArrayList<>();
Collection<VirtualFile> virtualFiles =
FileBasedIndex.getInstance().getContainingFiles(VirtualTypeIndex.KEY, name, scope);
for (VirtualFile virtualFile : virtualFiles) {
XmlFile xmlFile = (XmlFile) PsiManager.getInstance(project).findFile(virtualFile);
if (xmlFile != null) {
Collection<XmlAttributeValue> valueElements = XmlPsiTreeUtil
.findAttributeValueElements(xmlFile, "virtualType", "name", name);
result.addAll(valueElements);
}
}
return result;
}
示例10: getTopTypeOfVirtualType
import com.intellij.util.indexing.FileBasedIndex; //导入依赖的package包/类
@NotNull
private String getTopTypeOfVirtualType(@NonNull String name) {
List<String> values;
int parentNestingLevel = 0;
int maxNestingLevel = 5;
do {
values = FileBasedIndex.getInstance()
.getValues(VirtualTypeIndex.KEY, name, GlobalSearchScope.allScope(project));
if (values.size() > 0 && values.get(0) != null) {
name = values.get(0);
}
} while (values.size() > 0 || maxNestingLevel > parentNestingLevel++);
return name;
}
示例11: getComponentDeclarations
import com.intellij.util.indexing.FileBasedIndex; //导入依赖的package包/类
private static List<XmlTag> getComponentDeclarations(String componentValue, String componentType, ID<String, Void> id, Project project, ComponentMatcher componentMatcher) {
List<XmlTag> results = new ArrayList<XmlTag>();
Collection<VirtualFile> containingFiles = FileBasedIndex.getInstance()
.getContainingFiles(
id,
componentValue,
GlobalSearchScope.allScope(project)
);
PsiManager psiManager = PsiManager.getInstance(project);
for (VirtualFile virtualFile: containingFiles) {
XmlFile xmlFile = (XmlFile)psiManager.findFile(virtualFile);
if (xmlFile == null) {
continue;
}
XmlTag rootTag = xmlFile.getRootTag();
if (rootTag == null) {
continue;
}
collectComponentDeclarations(rootTag, results, componentValue, componentType, componentMatcher);
}
return results;
}
示例12: addCompletions
import com.intellij.util.indexing.FileBasedIndex; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters,
ProcessingContext context,
@NotNull CompletionResultSet result) {
PsiElement position = parameters.getPosition().getOriginalElement();
if (position == null) {
return;
}
String prefix = result.getPrefixMatcher().getPrefix();
Collection<String> moduleNames
= FileBasedIndex.getInstance().getAllKeys(ModuleNameIndex.KEY, position.getProject());
moduleNames.removeIf(m -> !m.startsWith(prefix));
for (String moduleName : moduleNames) {
result.addElement(
LookupElementBuilder
.create(moduleName)
.withIcon(AllIcons.Modules.ModulesNode)
);
}
}
示例13: findViewVfsByModuleName
import com.intellij.util.indexing.FileBasedIndex; //导入依赖的package包/类
public static Collection<VirtualFile> findViewVfsByModuleName(String moduleName, Project project)
{
Collection<VirtualFile> viewVfs = new ArrayList<>();
Pattern pattern = Pattern.compile(RegExUtil.Magento.MODULE_NAME);
Matcher matcher = pattern.matcher(moduleName);
if (!matcher.find()) {
return viewVfs;
}
Collection<VirtualFile> moduleVfs =
FileBasedIndex.getInstance().getContainingFiles(ModuleNameIndex.KEY, moduleName,
GlobalSearchScope.getScopeRestrictedByFileTypes(
GlobalSearchScope.allScope(project),
PhpFileType.INSTANCE
)
);
for (VirtualFile moduleVf : moduleVfs) {
viewVfs.addAll(getValues(moduleName, moduleVf, project));
}
return viewVfs;
}
示例14: getValues
import com.intellij.util.indexing.FileBasedIndex; //导入依赖的package包/类
private static Collection<VirtualFile> getValues(String moduleName, VirtualFile moduleVf, Project project)
{
Collection<VirtualFile> viewVfs = new ArrayList<>();
FileBasedIndex.getInstance()
.processValues(
ModuleNameIndex.KEY, moduleName, moduleVf,
(file, value) -> {
VirtualFile viewVf = file.getParent().findFileByRelativePath(value.concat("/view"));
if (viewVf != null) {
viewVfs.add(viewVf);
}
return false;
},
GlobalSearchScope.fileScope(project, moduleVf)
);
return viewVfs;
}
示例15: getPluginsForClass
import com.intellij.util.indexing.FileBasedIndex; //导入依赖的package包/类
List<PhpClass> getPluginsForClass(@NotNull PhpClass phpClass, @NotNull String classFQN) {
List<PhpClass> results = new ArrayList<>();
if (classPluginsMap.containsKey(classFQN)) {
return classPluginsMap.get(classFQN);
}
List<Set<String>> plugins = FileBasedIndex.getInstance()
.getValues(PluginIndex.KEY, classFQN, GlobalSearchScope.allScope(phpClass.getProject()));
if (plugins.size() == 0) {
classPluginsMap.put(classFQN, results);
return results;
}
PhpIndex phpIndex = PhpIndex.getInstance(phpClass.getProject());
for (Set<String> pluginClassNames: plugins) {
for (String pluginClassName: pluginClassNames) {
results.addAll(phpIndex.getClassesByFQN(pluginClassName));
}
}
classPluginsMap.put(classFQN, results);
return results;
}