Java 类com.intellij.util.indexing.DataIndexer 实例源码

项目:intellij-ce-playground    文件:PlatformIdTableBuilding.java   
@NotNull
@Override
public Map<TodoIndexEntry, Integer> map(@NotNull FileContent inputData) {
  Map<TodoIndexEntry, Integer> result = ContainerUtil.newTroveMap();
  for (DataIndexer<TodoIndexEntry, Integer, FileContent> indexer : indexers) {
    for (Map.Entry<TodoIndexEntry, Integer> entry : indexer.map(inputData).entrySet()) {
      TodoIndexEntry key = entry.getKey();
      if (result.containsKey(key)) {
        result.put(key, result.get(key) + entry.getValue());
      } else {
        result.put(key, entry.getValue());
      }
    }
  }
  return result;
}
项目:tools-idea    文件:PlatformIdTableBuilding.java   
@NotNull
@Override
public Map<TodoIndexEntry, Integer> map(FileContent inputData) {
  Map<TodoIndexEntry, Integer> result = ContainerUtil.newTroveMap();
  for (DataIndexer<TodoIndexEntry, Integer, FileContent> indexer : indexers) {
    for (Map.Entry<TodoIndexEntry, Integer> entry : indexer.map(inputData).entrySet()) {
      TodoIndexEntry key = entry.getKey();
      if (result.containsKey(key)) {
        result.put(key, result.get(key) + entry.getValue());
      } else {
        result.put(key, entry.getValue());
      }
    }
  }
  return result;
}
项目:consulo    文件:PlatformIdTableBuilding.java   
@Nonnull
@Override
public Map<TodoIndexEntry, Integer> map(FileContent inputData) {
  Map<TodoIndexEntry, Integer> result = ContainerUtil.newTroveMap();
  for (DataIndexer<TodoIndexEntry, Integer, FileContent> indexer : indexers) {
    for (Map.Entry<TodoIndexEntry, Integer> entry : indexer.map(inputData).entrySet()) {
      TodoIndexEntry key = entry.getKey();
      if (result.containsKey(key)) {
        result.put(key, result.get(key) + entry.getValue());
      }
      else {
        result.put(key, entry.getValue());
      }
    }
  }
  return result;
}
项目:intellij-ce-playground    文件:PlatformIdTableBuilding.java   
@Nullable
public static DataIndexer<TodoIndexEntry, Integer, FileContent> getTodoIndexer(FileType fileType, final VirtualFile virtualFile) {
  final DataIndexer<TodoIndexEntry, Integer, FileContent> indexer = ourTodoIndexers.get(fileType);

  if (indexer != null) {
    return indexer;
  }

  final DataIndexer<TodoIndexEntry, Integer, FileContent> extIndexer;
  if (fileType instanceof SubstitutedFileType && !((SubstitutedFileType)fileType).isSameFileType()) {
    SubstitutedFileType sft = (SubstitutedFileType)fileType;
    extIndexer =
      new CompositeTodoIndexer(getTodoIndexer(sft.getOriginalFileType(), virtualFile), getTodoIndexer(sft.getFileType(), virtualFile));
  }
  else {
    extIndexer = TodoIndexers.INSTANCE.forFileType(fileType);
  }
  if (extIndexer != null) {
    return extIndexer;
  }

  if (fileType instanceof LanguageFileType) {
    final Language lang = ((LanguageFileType)fileType).getLanguage();
    final ParserDefinition parserDef = LanguageParserDefinitions.INSTANCE.forLanguage(lang);
    final TokenSet commentTokens = parserDef != null ? parserDef.getCommentTokens() : null;
    if (commentTokens != null) {
      return new TokenSetTodoIndexer(commentTokens, virtualFile);
    }
  }

  if (fileType instanceof CustomSyntaxTableFileType) {
    return new TokenSetTodoIndexer(ABSTRACT_FILE_COMMENT_TOKENS, virtualFile);
  }

  return null;
}
项目:intellij-ce-playground    文件:PlatformIdTableBuilding.java   
@Override
public int getVersion() {
  int version = super.getVersion();
  for(DataIndexer dataIndexer:indexers) {
    version += dataIndexer instanceof VersionedTodoIndexer ? ((VersionedTodoIndexer)dataIndexer).getVersion() : 0xFF;
  }
  return version;
}
项目:tools-idea    文件:MethodCallingLocationIndex.java   
@Override
protected DataIndexer<MethodNameAndQualifier, List<CallingLocation>, ClassReader> getIndexer() {
  return new DataIndexer<MethodNameAndQualifier, List<CallingLocation>, ClassReader>() {
    @NotNull
    @Override
    public Map<MethodNameAndQualifier, List<CallingLocation>> map(final ClassReader inputData) {
      return MethodCallingLocationExtractor.extract(inputData);
    }
  };
}
项目:tools-idea    文件:PlatformIdTableBuilding.java   
@Nullable
public static DataIndexer<TodoIndexEntry, Integer, FileContent> getTodoIndexer(FileType fileType, final VirtualFile virtualFile) {
  final DataIndexer<TodoIndexEntry, Integer, FileContent> indexer = ourTodoIndexers.get(fileType);

  if (indexer != null) {
    return indexer;
  }

  final DataIndexer<TodoIndexEntry, Integer, FileContent> extIndexer;
  if (fileType instanceof SubstitutedFileType) {
    SubstitutedFileType sft = (SubstitutedFileType)fileType;
    extIndexer =
      new CompositeTodoIndexer(getTodoIndexer(sft.getOriginalFileType(), virtualFile), getTodoIndexer(sft.getFileType(), virtualFile));
  }
  else {
    extIndexer = TodoIndexers.INSTANCE.forFileType(fileType);
  }
  if (extIndexer != null) {
    return extIndexer;
  }

  if (fileType instanceof LanguageFileType) {
    final Language lang = ((LanguageFileType)fileType).getLanguage();
    final ParserDefinition parserDef = LanguageParserDefinitions.INSTANCE.forLanguage(lang);
    final TokenSet commentTokens = parserDef != null ? parserDef.getCommentTokens() : null;
    if (commentTokens != null) {
      return new TokenSetTodoIndexer(commentTokens, virtualFile);
    }
  }

  if (fileType instanceof CustomSyntaxTableFileType) {
    return new TokenSetTodoIndexer(ABSTRACT_FILE_COMMENT_TOKENS, virtualFile);
  }

  return null;
}
项目:consulo    文件:PlatformIdTableBuilding.java   
@javax.annotation.Nullable
public static DataIndexer<TodoIndexEntry, Integer, FileContent> getTodoIndexer(FileType fileType, Project project, final VirtualFile virtualFile) {
  final DataIndexer<TodoIndexEntry, Integer, FileContent> extIndexer;
  if (fileType instanceof SubstitutedFileType && !((SubstitutedFileType)fileType).isSameFileType()) {
    SubstitutedFileType sft = (SubstitutedFileType)fileType;
    extIndexer = new CompositeTodoIndexer(getTodoIndexer(sft.getOriginalFileType(), project, virtualFile), getTodoIndexer(sft.getFileType(), project, virtualFile));
  }
  else {
    extIndexer = TodoIndexers.INSTANCE.forFileType(fileType);
  }
  if (extIndexer != null) {
    return extIndexer;
  }

  if (fileType instanceof LanguageFileType) {
    final Language lang = ((LanguageFileType)fileType).getLanguage();
    final ParserDefinition parserDef = LanguageParserDefinitions.INSTANCE.forLanguage(lang);
    LanguageVersion languageVersion = LanguageVersionUtil.findLanguageVersion(lang, project, virtualFile);
    final TokenSet commentTokens = parserDef != null ? parserDef.getCommentTokens(languageVersion) : null;
    if (commentTokens != null) {
      return new TokenSetTodoIndexer(commentTokens, languageVersion, virtualFile, project);
    }
  }

  if (fileType instanceof CustomSyntaxTableFileType) {
    return new TokenSetTodoIndexer(ABSTRACT_FILE_COMMENT_TOKENS, null, virtualFile, project);
  }

  return null;
}
项目:consulo    文件:PlatformIdTableBuilding.java   
@Override
public int getVersion() {
  int version = VersionedTodoIndexer.super.getVersion();
  for (DataIndexer dataIndexer : indexers) {
    version += dataIndexer instanceof VersionedTodoIndexer ? ((VersionedTodoIndexer)dataIndexer).getVersion() : 0xFF;
  }
  return version;
}
项目:consulo-xml    文件:DomFileIndex.java   
public DomFileIndex()
{
    myDataIndexer = new DataIndexer<String, Void, FileContent>()
    {
        @Override
        @NotNull
        public Map<String, Void> map(final FileContent inputData)
        {
            final Set<String> namespaces = new THashSet<String>();
            final XmlFileHeader header = NanoXmlUtil.parseHeader(CharArrayUtil.readerFromCharSequence(inputData.getContentAsText()));
            ContainerUtil.addIfNotNull(namespaces, header.getPublicId());
            ContainerUtil.addIfNotNull(namespaces, header.getSystemId());
            ContainerUtil.addIfNotNull(namespaces, header.getRootTagNamespace());
            final String tagName = header.getRootTagLocalName();
            if(StringUtil.isNotEmpty(tagName))
            {
                final THashMap<String, Void> result = new THashMap<String, Void>();
                final DomApplicationComponent component = DomApplicationComponent.getInstance();
                for(final DomFileDescription description : component.getFileDescriptions(tagName))
                {
                    final String[] strings = description.getAllPossibleRootTagNamespaces();
                    if(strings.length == 0 || ContainerUtil.intersects(Arrays.asList(strings), namespaces))
                    {
                        result.put(description.getRootElementClass().getName(), null);
                    }
                }
                for(final DomFileDescription description : component.getAcceptingOtherRootTagNameDescriptions())
                {
                    final String[] strings = description.getAllPossibleRootTagNamespaces();
                    if(strings.length == 0 || ContainerUtil.intersects(Arrays.asList(strings), namespaces))
                    {
                        result.put(description.getRootElementClass().getName(), null);
                    }
                }
                return result;
            }
            return Collections.emptyMap();
        }
    };
}
项目:idea-php-typo3-plugin    文件:MethodArgumentDroppedIndex.java   
@NotNull
@Override
public DataIndexer<String, Integer, FileContent> getIndexer() {
    return inputData -> {
        Set<PsiElement> elements = new HashSet<>();

        Collections.addAll(
                elements,
                PsiTreeUtil.collectElements(inputData.getPsiFile(), el -> PlatformPatterns
                        .psiElement(StringLiteralExpression.class)
                        .withParent(
                                PlatformPatterns.psiElement(PhpElementTypes.ARRAY_KEY)
                                        .withAncestor(
                                                4,
                                                PlatformPatterns.psiElement(PhpElementTypes.RETURN)
                                        )
                        )
                        .accepts(el)
                )
        );

        Map<String, Integer> methodMap = new HashMap<>();

        for (PsiElement gatheredElement : elements) {
            PsiElement parent = gatheredElement.getParent().getParent();
            if (parent instanceof ArrayHashElement) {
                ArrayHashElement arr = (ArrayHashElement) parent;
                PhpPsiElement value = arr.getValue();
                if (value != null && value instanceof ArrayCreationExpression) {
                    ArrayCreationExpression creationExpression = (ArrayCreationExpression) value;
                    creationExpression.getHashElements().forEach(x -> {
                        PhpPsiElement key = x.getKey();
                        if (key != null && key.getText().contains("maximumNumberOfArguments")) {
                            methodMap.put("\\" + ((StringLiteralExpression) gatheredElement).getContents(), Integer.parseInt(x.getValue().getText()));
                        }
                    });
                }
            }
        }

        return methodMap;
    };
}
项目:magento2-phpstorm-plugin    文件:ContainerNameIndex.java   
@NotNull
@Override
public DataIndexer<String, Void, FileContent> getIndexer() {
    return new LayoutDataIndexer("container", "name");
}
项目:magento2-phpstorm-plugin    文件:BlockNameIndex.java   
@NotNull
@Override
public DataIndexer<String, Void, FileContent> getIndexer() {
    return new LayoutDataIndexer("block", "name");
}
项目:magento2-phpstorm-plugin    文件:BlockClassNameIndex.java   
@NotNull
@Override
public DataIndexer<String, Void, FileContent> getIndexer() {
    return new LayoutDataIndexer("block", "class", PhpLangUtil::toPresentableFQN);
}
项目:intellij-neos    文件:NodeTypesYamlFileIndex.java   
@NotNull
@Override
public DataIndexer<String, Void, FileContent> getIndexer() {
    return new NodeTypesYamlIndexer();
}
项目:intellij-ce-playground    文件:PlatformIdTableBuilding.java   
@Deprecated
public static void registerTodoIndexer(@NotNull FileType fileType, DataIndexer<TodoIndexEntry, Integer, FileContent> indexer) {
  ourTodoIndexers.put(fileType, indexer);
}
项目:intellij-ce-playground    文件:PlatformIdTableBuilding.java   
public CompositeTodoIndexer(@NotNull DataIndexer<TodoIndexEntry, Integer, FileContent>... indexers) {
  this.indexers = indexers;
}
项目:magento2plugin    文件:BlockClassFileBasedIndex.java   
@NotNull
@Override
public DataIndexer<String, Void, FileContent> getIndexer() {
    return new LayoutDataIndexer("block", "class");
}
项目:intellij-pants-plugin    文件:PantsBuildFileIndex.java   
@NotNull
@Override
public DataIndexer<String, Void, FileContent> getIndexer() {
  return indexer;
}
项目:consulo-unity3d    文件:Unity3dYMLAssetIndexExtension.java   
@NotNull
@Override
public DataIndexer<Integer, List<Unity3dYMLAsset>, FileContent> getIndexer()
{
    return myIndexer;
}
项目:consulo-unity3d    文件:Unity3dMetaIndexExtension.java   
@NotNull
@Override
public DataIndexer<String, Integer, FileContent> getIndexer()
{
    return myIndexer;
}
项目:tools-idea    文件:PlatformIdTableBuilding.java   
@Deprecated
public static void registerTodoIndexer(FileType fileType, DataIndexer<TodoIndexEntry, Integer, FileContent> indexer) {
  ourTodoIndexers.put(fileType, indexer);
}
项目:tools-idea    文件:PlatformIdTableBuilding.java   
public CompositeTodoIndexer(DataIndexer<TodoIndexEntry, Integer, FileContent>... indexers) {
  this.indexers = indexers;
}
项目:consulo-javafx    文件:JavaFxControllerClassIndex.java   
@Override
@NotNull
public DataIndexer<String, Void, FileContent> getIndexer() {
  return myDataIndexer;
}
项目:consulo-apache-thrift    文件:ThriftDeclarationIndex.java   
@NotNull
@Override
public DataIndexer<String, Void, FileContent> getIndexer() {
  return myIndexer;
}
项目:consulo-apache-thrift    文件:ThriftSubDeclarationIndex.java   
@NotNull
@Override
public DataIndexer<String, String, FileContent> getIndexer() {
  return myIndexer;
}
项目:consulo-ui-designer    文件:FormClassIndex.java   
@Override
@NotNull
public DataIndexer<String, Void, FileContent> getIndexer() {
  return myDataIndexer;
}
项目:consulo-apache-ant    文件:AntImportsIndex.java   
@Override
@NotNull
public DataIndexer<Integer, Void, FileContent> getIndexer() {
  return DATA_INDEXER;
}
项目:consulo    文件:PlatformIdTableBuilding.java   
@SafeVarargs
public CompositeTodoIndexer(@Nonnull DataIndexer<TodoIndexEntry, Integer, FileContent>... indexers) {
  this.indexers = indexers;
}
项目:consulo-xml    文件:DomFileIndex.java   
@Override
@NotNull
public DataIndexer<String, Void, FileContent> getIndexer()
{
    return myDataIndexer;
}
项目:consulo-xml    文件:Html5CustomAttributesIndex.java   
@NotNull
@Override
public DataIndexer<String, Void, FileContent> getIndexer() {
  return myIndexer;
}
项目:consulo-java    文件:JavaAutoModuleNameIndex.java   
@NotNull
@Override
public DataIndexer<String, Void, FileContent> getIndexer()
{
    return myIndexer;
}
项目:consulo-java    文件:BytecodeAnalysisIndex.java   
@NotNull
@Override
public DataIndexer<Bytes, HEquations, FileContent> getIndexer() {
  return INDEXER;
}
项目:consulo-java    文件:JavaNullMethodArgumentIndex.java   
@NotNull
@Override
public DataIndexer<MethodCallData, Void, FileContent> getIndexer()
{
    return inputData ->
    {
        if(myOfflineMode)
        {
            return Collections.emptyMap();
        }

        int[] nullOffsets = new StringSearcher(PsiKeyword.NULL, true, true).findAllOccurrences(inputData.getContentAsText());
        if(nullOffsets.length == 0)
        {
            return Collections.emptyMap();
        }

        LighterAST lighterAst = ((FileContentImpl) inputData).getLighterASTForPsiDependentIndex();
        Set<LighterASTNode> calls = findCallsWithNulls(lighterAst, nullOffsets);
        if(calls.isEmpty())
        {
            return Collections.emptyMap();
        }

        Map<MethodCallData, Void> result = new THashMap<>();
        for(LighterASTNode element : calls)
        {
            final IntArrayList indices = getNullParameterIndices(lighterAst, element);
            if(indices != null)
            {
                final String name = getMethodName(lighterAst, element, element.getTokenType());
                if(name != null)
                {
                    for(int i = 0; i < indices.size(); i++)
                    {
                        result.put(new MethodCallData(name, indices.get(i)), null);
                    }
                }
            }
        }
        return result;
    };
}