@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; }
@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; }
@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; }
@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; }
@Override public int getVersion() { int version = super.getVersion(); for(DataIndexer dataIndexer:indexers) { version += dataIndexer instanceof VersionedTodoIndexer ? ((VersionedTodoIndexer)dataIndexer).getVersion() : 0xFF; } return version; }
@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); } }; }
@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; }
@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; }
@Override public int getVersion() { int version = VersionedTodoIndexer.super.getVersion(); for (DataIndexer dataIndexer : indexers) { version += dataIndexer instanceof VersionedTodoIndexer ? ((VersionedTodoIndexer)dataIndexer).getVersion() : 0xFF; } return version; }
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(); } }; }
@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; }; }
@NotNull @Override public DataIndexer<String, Void, FileContent> getIndexer() { return new LayoutDataIndexer("container", "name"); }
@NotNull @Override public DataIndexer<String, Void, FileContent> getIndexer() { return new LayoutDataIndexer("block", "name"); }
@NotNull @Override public DataIndexer<String, Void, FileContent> getIndexer() { return new LayoutDataIndexer("block", "class", PhpLangUtil::toPresentableFQN); }
@NotNull @Override public DataIndexer<String, Void, FileContent> getIndexer() { return new NodeTypesYamlIndexer(); }
@Deprecated public static void registerTodoIndexer(@NotNull FileType fileType, DataIndexer<TodoIndexEntry, Integer, FileContent> indexer) { ourTodoIndexers.put(fileType, indexer); }
public CompositeTodoIndexer(@NotNull DataIndexer<TodoIndexEntry, Integer, FileContent>... indexers) { this.indexers = indexers; }
@NotNull @Override public DataIndexer<String, Void, FileContent> getIndexer() { return new LayoutDataIndexer("block", "class"); }
@NotNull @Override public DataIndexer<String, Void, FileContent> getIndexer() { return indexer; }
@NotNull @Override public DataIndexer<Integer, List<Unity3dYMLAsset>, FileContent> getIndexer() { return myIndexer; }
@NotNull @Override public DataIndexer<String, Integer, FileContent> getIndexer() { return myIndexer; }
@Deprecated public static void registerTodoIndexer(FileType fileType, DataIndexer<TodoIndexEntry, Integer, FileContent> indexer) { ourTodoIndexers.put(fileType, indexer); }
public CompositeTodoIndexer(DataIndexer<TodoIndexEntry, Integer, FileContent>... indexers) { this.indexers = indexers; }
@Override @NotNull public DataIndexer<String, Void, FileContent> getIndexer() { return myDataIndexer; }
@NotNull @Override public DataIndexer<String, Void, FileContent> getIndexer() { return myIndexer; }
@NotNull @Override public DataIndexer<String, String, FileContent> getIndexer() { return myIndexer; }
@Override @NotNull public DataIndexer<Integer, Void, FileContent> getIndexer() { return DATA_INDEXER; }
@SafeVarargs public CompositeTodoIndexer(@Nonnull DataIndexer<TodoIndexEntry, Integer, FileContent>... indexers) { this.indexers = indexers; }
@NotNull @Override public DataIndexer<Bytes, HEquations, FileContent> getIndexer() { return INDEXER; }
@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; }; }