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


Java FileBasedIndex.getInstance方法代码示例

本文整理汇总了Java中com.intellij.util.indexing.FileBasedIndex.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java FileBasedIndex.getInstance方法的具体用法?Java FileBasedIndex.getInstance怎么用?Java FileBasedIndex.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.util.indexing.FileBasedIndex的用法示例。


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

示例1: 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

示例2: 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

示例3: getAllKeyValues

import com.intellij.util.indexing.FileBasedIndex; //导入方法依赖的package包/类
@NotNull
public static Map<String, String> getAllKeyValues(Project project) {
    FileBasedIndex fileBasedIndex = FileBasedIndex.getInstance();
    Map<String, String> keyValues = new HashMap<>();

    fileBasedIndex.processAllKeys(DotEnvKeyValuesIndex.KEY, s -> {
        if(fileBasedIndex.getContainingFiles(DotEnvKeyValuesIndex.KEY, s, GlobalSearchScope.allScope(project)).size() > 0) {

            EnvironmentKeyValue keyValue = EnvironmentVariablesUtil.getKeyValueFromString(s);

            if(keyValues.containsKey(keyValue.getKey())) return true;

            keyValues.put(keyValue.getKey(), keyValue.getValue());
        }

        return true;
    }, project);

    return keyValues;
}
 
开发者ID:adelf,项目名称:idea-php-dotenv-plugin,代码行数:21,代码来源:EnvironmentVariablesApi.java

示例4: collectSingleEquation

import com.intellij.util.indexing.FileBasedIndex; //导入方法依赖的package包/类
private void collectSingleEquation(HKey hKey, Solver solver, @NotNull Map<Bytes, List<HEquations>> cache) throws EquationsLimitException {
  GlobalSearchScope librariesScope = ProjectScope.getLibrariesScope(myProject);

  FileBasedIndex index = FileBasedIndex.getInstance();

  ProgressManager.checkCanceled();
  Bytes bytes = new Bytes(hKey.key);

  List<HEquations> hEquationss = cache.get(bytes);
  if (hEquationss == null) {
    hEquationss = index.getValues(BytecodeAnalysisIndex.NAME, bytes, librariesScope);
    cache.put(bytes, hEquationss);
  }

  for (HEquations hEquations : hEquationss) {
    boolean stable = hEquations.stable;
    for (DirectionResultPair pair : hEquations.results) {
      int dirKey = pair.directionKey;
      if (dirKey == hKey.dirKey) {
        HResult result = pair.hResult;
        solver.addEquation(new HEquation(new HKey(bytes.bytes, dirKey, stable, false), result));
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:ProjectBytecodeAnalysis.java

示例5: canRun

import com.intellij.util.indexing.FileBasedIndex; //导入方法依赖的package包/类
@Override
protected void canRun() throws ConfigurationException {
    String newName = getNewName();
    if (Comparing.strEqual(newName, key)) {
        throw new ConfigurationException(null);
    }
    if (StringUtils.isBlank(newName) || newName.endsWith(".")) {
        throw new ConfigurationException("\'" + getNewName() + "\' is not a valid key");
    }

    FileBasedIndex index = FileBasedIndex.getInstance();
    Collection<VirtualFile> files = index.getContainingFiles(TranslationCallIndex.KEY, newName, GlobalSearchScope.allScope(getProject()));
    if (!files.isEmpty()) {
        throw new ConfigurationException("\'" + getNewName() + "\' already exists");
    }
}
 
开发者ID:letsdrink,项目名称:ouzo-phpstorm-plugin,代码行数:17,代码来源:RenameTranslationKeyDialog.java

示例6: collectInformation

import com.intellij.util.indexing.FileBasedIndex; //导入方法依赖的package包/类
@Nullable
@Override
public List<PsiElement> collectInformation(@NotNull PsiFile file) {
    final List<PsiElement> unusedKeys = new ArrayList<>();

    if (!TranslationUtils.isTranslationFile(file) || !Settings.getInstance(file.getProject()).annotateUnusedTranslation) {
        return unusedKeys;
    }

    final Project project = file.getProject();
    final FileBasedIndex index = FileBasedIndex.getInstance();

    TranslationParser translationParser = new TranslationParser();
    translationParser.parse(file, new TranslationParser.Handler() {
        @Override
        public void handle(String key, String text, ArrayHashElement element) {
            if (!isUsed(project, index, key)) {
                unusedKeys.add(element.getKey());
            }
        }
    });
    return unusedKeys;
}
 
开发者ID:letsdrink,项目名称:ouzo-phpstorm-plugin,代码行数:24,代码来源:UnusedTranslationAnnotator.java

示例7: resolveInner

import com.intellij.util.indexing.FileBasedIndex; //导入方法依赖的package包/类
@Override
@Nullable
public PsiElement resolveInner() {
    final FileBasedIndex instance = FileBasedIndex.getInstance();
    final Project project = getElement().getProject();
    final String id = getCanonicalText();
    final Collection<VirtualFile> files = instance.getContainingFiles(EmberTemplateCacheIndex.TEMPLATE_CACHE_INDEX, id,
            GlobalSearchScope.allScope(project));
    final Ref<PsiElement> result = new Ref<PsiElement>();
    for (VirtualFile file : files) {
        final PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
        EmberTemplateCacheIndex.processTemplates(psiFile, new Processor<XmlAttribute>() {
            @Override
            public boolean process(XmlAttribute attribute) {
                if (id.equals(attribute.getValue())) {
                    result.set(attribute.getValueElement());
                }
                return result.isNull();
            }
        });
    }
    return result.get();
}
 
开发者ID:kristianmandrup,项目名称:emberjs-plugin,代码行数:24,代码来源:EmberJSTemplateCacheReference.java

示例8: getMacros

import com.intellij.util.indexing.FileBasedIndex; //导入方法依赖的package包/类
/**
 * Get all macros inside file
 *
 * {% macro foobar %}{% endmacro %}
 * {% macro input(name, value, type, size) %}{% endmacro %}
 */
@NotNull
public static Collection<TwigMacroTagInterface> getMacros(@NotNull PsiFile file) {
    Collection<TwigMacroTagInterface> macros = new ArrayList<>();

    Collection<String> keys = new ArrayList<>();

    FileBasedIndex fileBasedIndex = FileBasedIndex.getInstance();
    fileBasedIndex.processAllKeys(TwigMacroFunctionStubIndex.KEY, s -> {
        keys.add(s);
        return true;
    }, GlobalSearchScope.fileScope(file), null);

    for (String key : keys) {
        macros.addAll(fileBasedIndex.getValues(TwigMacroFunctionStubIndex.KEY, key, GlobalSearchScope.fileScope(file)));
    }

    return macros;
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:25,代码来源:TwigUtil.java

示例9: getFilesWithTodoItems

import com.intellij.util.indexing.FileBasedIndex; //导入方法依赖的package包/类
@Override
@Nonnull
public PsiFile[] getFilesWithTodoItems() {
  if (myProject.isDefault()) {
    return PsiFile.EMPTY_ARRAY;
  }
  final FileBasedIndex fileBasedIndex = FileBasedIndex.getInstance();
  final Set<PsiFile> allFiles = new HashSet<>();
  final ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
  for (IndexPattern indexPattern : IndexPatternUtil.getIndexPatterns()) {
    final Collection<VirtualFile> files = fileBasedIndex.getContainingFiles(
            TodoIndex.NAME,
            new TodoIndexEntry(indexPattern.getPatternString(), indexPattern.isCaseSensitive()), GlobalSearchScope.allScope(myProject));
    ApplicationManager.getApplication().runReadAction(() -> {
      for (VirtualFile file : files) {
        if (projectFileIndex.isInContent(file)) {
          final PsiFile psiFile = myPsiManager.findFile(file);
          if (psiFile != null) {
            allFiles.add(psiFile);
          }
        }
      }
    });
  }
  return allFiles.isEmpty() ? PsiFile.EMPTY_ARRAY : PsiUtilCore.toPsiFileArray(allFiles);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:27,代码来源:IndexTodoCacheManagerImpl.java

示例10: isMainOpenApiFile

import com.intellij.util.indexing.FileBasedIndex; //导入方法依赖的package包/类
public boolean isMainOpenApiFile(final VirtualFile virtualFile, final Project project) {
    final FileBasedIndex index = FileBasedIndex.getInstance();
    final Collection<VirtualFile> openApiFiles =
            index.getContainingFiles(OpenApiFileIndex.OPEN_API_INDEX_ID,
                    OpenApiFileIndex.MAIN_OPEN_API_FILE, GlobalSearchScope.allScope(project));

    return openApiFiles.contains(virtualFile);
}
 
开发者ID:zalando,项目名称:intellij-swagger,代码行数:9,代码来源:OpenApiIndexService.java

示例11: getPartialOpenApiFilesWithTypeInfo

import com.intellij.util.indexing.FileBasedIndex; //导入方法依赖的package包/类
private Set<String> getPartialOpenApiFilesWithTypeInfo(final Project project) {
    final FileBasedIndex index = FileBasedIndex.getInstance();
    return index.getValues(OpenApiFileIndex.OPEN_API_INDEX_ID,
            OpenApiFileIndex.PARTIAL_OPEN_API_FILES, GlobalSearchScope.allScope(project))
            .stream()
            .flatMap(Set::stream)
            .collect(Collectors.toSet());
}
 
开发者ID:zalando,项目名称:intellij-swagger,代码行数:9,代码来源:OpenApiIndexService.java

示例12: isMainSwaggerFile

import com.intellij.util.indexing.FileBasedIndex; //导入方法依赖的package包/类
public boolean isMainSwaggerFile(final VirtualFile virtualFile, final Project project) {
    final FileBasedIndex index = FileBasedIndex.getInstance();
    final Collection<VirtualFile> swaggerFiles =
            index.getContainingFiles(SwaggerFileIndex.SWAGGER_INDEX_ID,
                    SwaggerFileIndex.MAIN_SWAGGER_FILE, GlobalSearchScope.allScope(project));
    return swaggerFiles.contains(virtualFile);
}
 
开发者ID:zalando,项目名称:intellij-swagger,代码行数:8,代码来源:SwaggerIndexService.java

示例13: getPartialSwaggerFilesWithTypeInfo

import com.intellij.util.indexing.FileBasedIndex; //导入方法依赖的package包/类
private Set<String> getPartialSwaggerFilesWithTypeInfo(final Project project) {
    final FileBasedIndex index = FileBasedIndex.getInstance();
    return index.getValues(SwaggerFileIndex.SWAGGER_INDEX_ID,
            SwaggerFileIndex.PARTIAL_SWAGGER_FILES, GlobalSearchScope.allScope(project))
            .stream()
            .flatMap(Set::stream)
            .collect(Collectors.toSet());
}
 
开发者ID:zalando,项目名称:intellij-swagger,代码行数:9,代码来源:SwaggerIndexService.java

示例14: getFilesWithTodoItems

import com.intellij.util.indexing.FileBasedIndex; //导入方法依赖的package包/类
@Override
@NotNull
public PsiFile[] getFilesWithTodoItems() {
  if (myProject.isDefault()) {
    return PsiFile.EMPTY_ARRAY;
  }
  final FileBasedIndex fileBasedIndex = FileBasedIndex.getInstance();
  final Set<PsiFile> allFiles = new HashSet<PsiFile>();
  final ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
  for (IndexPattern indexPattern : IndexPatternUtil.getIndexPatterns()) {
    final Collection<VirtualFile> files = fileBasedIndex.getContainingFiles(
      TodoIndex.NAME,
      new TodoIndexEntry(indexPattern.getPatternString(), indexPattern.isCaseSensitive()), GlobalSearchScope.allScope(myProject));
    ApplicationManager.getApplication().runReadAction(new Runnable() {
      @Override
      public void run() {
        for (VirtualFile file : files) {
          if (projectFileIndex.isInContent(file)) {
            final PsiFile psiFile = myPsiManager.findFile(file);
            if (psiFile != null) {
              allFiles.add(psiFile);
            }
          }
        }
      }
    });
  }
  return allFiles.isEmpty() ? PsiFile.EMPTY_ARRAY : PsiUtilCore.toPsiFileArray(allFiles);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:IndexTodoCacheManagerImpl.java

示例15: getTodoCount

import com.intellij.util.indexing.FileBasedIndex; //导入方法依赖的package包/类
@Override
public int getTodoCount(@NotNull final VirtualFile file, @NotNull final IndexPatternProvider patternProvider) {
  if (myProject.isDefault()) {
    return 0;
  }
  if (file instanceof VirtualFileWindow) return -1;
  final FileBasedIndex fileBasedIndex = FileBasedIndex.getInstance();
  int count = 0;
  for (IndexPattern indexPattern : patternProvider.getIndexPatterns()) {
    count += fetchCount(fileBasedIndex, file, indexPattern);
  }
  return count;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:IndexTodoCacheManagerImpl.java


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