當前位置: 首頁>>代碼示例>>Java>>正文


Java FileBasedIndex類代碼示例

本文整理匯總了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;
}
 
開發者ID:CouleeApps,項目名稱:TS-IJ,代碼行數:26,代碼來源:TSGlobalCachedListGenerator.java

示例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()]);
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:20,代碼來源:RouteHelper.java

示例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());
    }
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:25,代碼來源:TYPO3CMSProjectComponent.java

示例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()]);
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:24,代碼來源:TranslationUtil.java

示例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()]);
    }
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:25,代碼來源:TableUtil.java

示例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()]);
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:24,代碼來源:ControllerActionUtil.java

示例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));
        }
    }
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:17,代碼來源:CoreServiceParser.java

示例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;
}
 
開發者ID:datathings,項目名稱:greycat-idea-plugin,代碼行數:27,代碼來源:GCMUtil.java

示例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;
}
 
開發者ID:magento,項目名稱:magento2-phpstorm-plugin,代碼行數:17,代碼來源:DiIndex.java

示例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;
}
 
開發者ID:magento,項目名稱:magento2-phpstorm-plugin,代碼行數:17,代碼來源:DiIndex.java

示例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;
}
 
開發者ID:magento,項目名稱:magento2-phpstorm-plugin,代碼行數:26,代碼來源:LayoutIndex.java

示例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)
        );
    }
}
 
開發者ID:magento,項目名稱:magento2-phpstorm-plugin,代碼行數:24,代碼來源:ModuleNameCompletionProvider.java

示例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;
}
 
開發者ID:magento,項目名稱:magento2-phpstorm-plugin,代碼行數:24,代碼來源:FileBasedIndexUtil.java

示例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;
}
 
開發者ID:magento,項目名稱:magento2-phpstorm-plugin,代碼行數:18,代碼來源:FileBasedIndexUtil.java

示例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;
}
 
開發者ID:magento,項目名稱:magento2-phpstorm-plugin,代碼行數:26,代碼來源:PluginLineMarkerProvider.java


注:本文中的com.intellij.util.indexing.FileBasedIndex類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。