@Override public String getName() { return symbol.getInfo().getName(); }
@Override public Set<SymbolInformation> getFilteredSymbols(String query) { checkNotNull(query, "query must not be null"); Pattern pattern = getQueryPattern(query); return indexer.getFileSymbols().values().stream().flatMap(Collection::stream) .filter(symbol -> pattern.matcher(symbol.getName()).matches()) .collect(Collectors.toSet()); }
public static CompletionList createCompletionListFromSymbols(Set<SymbolInformation> symbols) { if (symbols == null) { return new CompletionList(); } return new CompletionList( false, symbols.stream() .map(symbol -> { CompletionItem item = new CompletionItem(symbol.getName()); item.setKind(symbolKindToCompletionItemKind(symbol.getKind())); return item; }) .collect(Collectors.toList())); }
public void assertDocumentSymbols(String... symbolsAndContainers) throws Exception { Arrays.sort(symbolsAndContainers); StringBuilder expected = new StringBuilder(); for (String string : symbolsAndContainers) { expected.append(string+"\n"); } List<? extends SymbolInformation> actualSymbols = getDocumentSymbols(); List<String> actuals = new ArrayList<>(); for (SymbolInformation actualSymbol : actualSymbols) { assertEquals(doc.getUri(), actualSymbol.getLocation().getUri()); String coveredText = getText(actualSymbol.getLocation().getRange()); assertEquals(actualSymbol.getName(), coveredText); actuals.add(coveredText + "|" + actualSymbol.getContainerName()); } Collections.sort(actuals); StringBuilder actual = new StringBuilder(); for (String string : actuals) { actual.append(string+"\n"); } assertEquals(expected.toString(), actual.toString()); }
private boolean mapHasSymbol(Map<URI, Set<SymbolInformation>> map, Optional<String> container, String fieldName, SymbolKind kind) { return map.values().stream().flatMap(Collection::stream) .anyMatch(symbol -> symbol.getKind() == kind && container.transform(c -> c.equals(symbol.getContainerName())).or(true) && symbol.getName().equals(fieldName)); }
@Override public NewNodePresentation getPresentation() { String name = symbol.getInfo().getName(); return new NewNodePresentation.Builder() .withIcon(symbolIcons.get(symbol)) .withNodeText(name) .build(); }
private SpanElement createTitleOfElement(SymbolInformation symbolInformation) { String path = symbolInformation.getLocation().getUri(); SpanElement texElement = Elements.createSpanElement(); SpanElement highlightElement = Elements.createSpanElement(javaResources.css().presentableTextContainer()); highlightElement.setInnerText(" - (" + path + ')'); texElement.setInnerText(symbolInformation.getName()); texElement.appendChild(highlightElement); return texElement; }