private void addSymbol(BLangNode node, BSymbol balSymbol, SymbolKind kind) { String symbolName = balSymbol.getName().getValue(); if (query != null && !query.isEmpty() && !symbolName.startsWith(query)) { return; } SymbolInformation lspSymbol = new SymbolInformation(); lspSymbol.setName(symbolName); lspSymbol.setKind(kind); lspSymbol.setLocation(new Location(this.uri, getRange(node))); this.symbols.add(lspSymbol); }
public SymbolInformationDto(org.eclipse.lsp4j.SymbolInformation o) { if (o.getLocation() == null) { setLocation((org.eclipse.lsp4j.Location)null); } else { org.eclipse.lsp4j.Location locationVal = new LocationDto(o.getLocation()); setLocation((org.eclipse.lsp4j.Location)locationVal); if (o.getDeprecated() == null) { setDeprecated((java.lang.Boolean)null); } else { java.lang.Boolean deprecatedVal = (java.lang.Boolean)makeDto(o.getDeprecated());; setDeprecated((java.lang.Boolean)deprecatedVal); if (o.getKind() == null) { setKind((org.eclipse.lsp4j.SymbolKind)null); } else { org.eclipse.lsp4j.SymbolKind kindVal = (org.eclipse.lsp4j.SymbolKind)makeDto(o.getKind());; setKind((org.eclipse.lsp4j.SymbolKind)kindVal); if (o.getContainerName() == null) { setContainerName((java.lang.String)null); } else { java.lang.String containerNameVal = (java.lang.String)makeDto(o.getContainerName());; setContainerName((java.lang.String)containerNameVal); if (o.getName() == null) { setName((java.lang.String)null); } else { java.lang.String nameVal = (java.lang.String)makeDto(o.getName());; setName((java.lang.String)nameVal);
protected SymbolInformation createSymbol(final IEObjectDescription description) { final String symbolName = this.getSymbolName(description); if ((symbolName == null)) { return null; } final SymbolKind symbolKind = this.getSymbolKind(description); if ((symbolKind == null)) { return null; } final SymbolInformation symbol = new SymbolInformation(); symbol.setName(symbolName); symbol.setKind(symbolKind); return symbol; }
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 static SymbolInformation createSymbolInformation(String name, SymbolKind kind, Location location, Optional<String> parentName) { return new SymbolInformation(name, kind, location, parentName.orNull()); }
public void openOneImplementation(final SymbolInformation symbolInformation) { this.openHelper.openLocation(symbolInformation.getLocation()); }
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)); }
.filter(symbol -> Ranges.isValid(symbol.getLocation().getRange())).collect(Collectors.toSet()); new SymbolInformation( "Coordinates", SymbolKind.Class, new Location(fileUri, Ranges.createRange(0, 0, 1, 0))), new SymbolInformation( "getAt", SymbolKind.Method, new Location(fileUri, Ranges.createRange(4, 3, 10, 4)), "Coordinates"), new SymbolInformation( "latitude", SymbolKind.Field, new Location(fileUri, Ranges.createRange(1, 3, 1, 18)), "Coordinates"), new SymbolInformation( "longitude", SymbolKind.Field, new Location(fileUri, Ranges.createRange(2, 3, 2, 19)), "Coordinates"), new SymbolInformation( "name", SymbolKind.Field, new Location(fileUri, Ranges.createRange(3, 3, 3, 23)), "Coordinates"), new SymbolInformation( "idx1", SymbolKind.Variable, new Location(fileUri, Ranges.createRange(4, 16, 4, 24)), "getAt"),
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; }
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())); }
@Override public String getName() { return symbol.getInfo().getName(); }
public SVGResource get(ExtendedSymbolInformation symbol) { Visibility visiblity = symbol.getVisiblity(); return resources .get(visiblity == null ? Visibility.PACKAGE : visiblity) .get(symbol.getInfo().getKind()); } }
private Collection<? extends SymbolInformationDto> convertDocumentSymbol( DocumentSymbol symbol, String uri) { ArrayList<SymbolInformationDto> result = new ArrayList<>(); result.add( new SymbolInformationDto( new SymbolInformation( symbol.getName(), symbol.getKind(), new Location(uri, symbol.getRange())))); for (DocumentSymbol child : symbol.getChildren()) { result.addAll(convertDocumentSymbol(child, uri)); } return result; } },
@Override public boolean handleResult( ExtendedLanguageServer server, List<? extends SymbolInformation> locations) { locations.forEach( location -> { String uri = location.getLocation().getUri(); String wsPath = languageServerPathTransformer.toWsPath(server.getId(), uri); location.getLocation().setUri(wsPath); result.add(new SymbolInformationDto(location)); }); return true; } },
@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()); }
@Override public Element createItem(final SymbolInformation itemModel) { final Element element = Elements.createLiElement(popupResources.popupStyle().item()); final Element iconElement = Elements.createDivElement(popupResources.popupStyle().icon()); SVGImage svgImage = getSvgImage(itemModel.getKind()); iconElement.appendChild((Node) svgImage.getElement()); element.appendChild(iconElement); element.appendChild(createTitleOfElement(itemModel)); final EventListener validateListener = evt -> { openImplementationPresenter.openOneImplementation(itemModel); hide(); }; element.addEventListener(Event.DBLCLICK, validateListener, false); element.addEventListener(CUSTOM_EVT_TYPE_VALIDATE, validateListener, false); return element; }
protected SymbolInformation createSymbol(final EObject object) { final String name = this.getSymbolName(object); if ((name == null)) { return null; } final SymbolKind kind = this.getSymbolKind(object); if ((kind == null)) { return null; } final Location location = this.getSymbolLocation(object); if ((location == null)) { return null; } final SymbolInformation symbol = new SymbolInformation(); symbol.setName(name); symbol.setKind(kind); symbol.setLocation(location); return symbol; }
protected void createSymbol(final IEObjectDescription description, final IReferenceFinder.IResourceAccess resourceAccess, final Procedure1<? super SymbolInformation> acceptor) { final String name = this.getSymbolName(description); if ((name == null)) { return; } final SymbolKind kind = this.getSymbolKind(description); if ((kind == null)) { return; } final Procedure1<Location> _function = (Location location) -> { final SymbolInformation symbol = new SymbolInformation(name, kind, location); acceptor.apply(symbol); }; this.getSymbolLocation(description, resourceAccess, _function); }
@Override public final CompletableFuture<List<? extends SymbolInformation>> symbol(WorkspaceSymbolParams params) { return CompletableFuture.completedFuture(getState().getCompilerWrapper().getFilteredSymbols(params.getQuery()) .stream() .filter(symbol -> Ranges.isValid(symbol.getLocation().getRange())) .collect(Collectors.toList())); }
@Override public NewNodePresentation getPresentation() { String name = symbol.getInfo().getName(); return new NewNodePresentation.Builder() .withIcon(symbolIcons.get(symbol)) .withNodeText(name) .build(); }