public void openOneImplementation(final SymbolInformation symbolInformation) { this.openHelper.openLocation(symbolInformation.getLocation()); }
@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 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())); }
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()); }
@Override public void onSelect(ExtendedSymbolInformation element) { showInheritedMembers = false; view.hide(); showInheritedMembers = false; openHelper.openLocation(element.getInfo().getLocation()); }
@Override public boolean handleResult( ExtendedLanguageServer element, List<Either<SymbolInformation, DocumentSymbol>> locations) { locations.forEach( o -> { // minimal fix for https://github.com/eclipse/che/issues/11139 when updating // lsp4j if (o.isLeft()) { SymbolInformation si = o.getLeft(); si.getLocation().setUri(removePrefixUri(si.getLocation().getUri())); result.add(new SymbolInformationDto(si)); } else { URI uri = languageServerPathTransformer.toFsURI(element.getId(), wsPath); result.addAll(convertDocumentSymbol(o.getRight(), uri.toString())); } }); return true; }
.map(symbol -> symbol.getLocation()) .filter(loc -> Ranges.isValid(loc.getRange()) && Ranges.contains(loc.getRange(), params.getPosition()))
@Override public void visitVariableExpression(VariableExpression expression) { if (expression.getAccessedVariable() != null) { SymbolInformation symbol = getVariableSymbolInformation(expression.getAccessedVariable()); if (Ranges.isValid(symbol.getLocation().getRange())) { indexer.addReference(symbol.getLocation(), createLocation(expression)); } else if (classFields.containsKey(expression.getAccessedVariable().getName())) { Location location = createLocation(classFields.get(expression.getAccessedVariable().getName())); indexer.addReference(location, createLocation(expression)); } } super.visitVariableExpression(expression); }
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; }
private void parseMethod(Indexer newIndexer, URI sourceUri, ClassNode parent, Map<String, Location> classes, Map<String, FieldNode> classFields, MethodNode method) { SymbolInformation methodSymbol = createSymbolInformation(method.getName(), SymbolKind.Method, GroovyLocations.createLocation(sourceUri, method), Optional.of(parent.getName())); newIndexer.addSymbol(sourceUri, methodSymbol); // Method parameters method.getVariableScope().getDeclaredVariables().values().forEach(variable -> { SymbolInformation variableSymbol = getVariableSymbolInformation(method.getName(), sourceUri, variable); newIndexer.addSymbol(sourceUri, variableSymbol); if (classes.containsKey(variable.getType().getName())) { newIndexer.addReference(classes.get(variable.getType().getName()), GroovyLocations.createLocation(sourceUri, variable.getType())); } }); // Return type if (classes.containsKey(method.getReturnType().getName())) { newIndexer.addReference(classes.get(method.getReturnType().getName()), GroovyLocations.createLocation(sourceUri, method.getReturnType())); } // We only want to visit the method if its not generated if (Ranges.isValid(methodSymbol.getLocation().getRange())) { // Visit the method if (method.getCode() instanceof BlockStatement) { BlockStatement blockStatement = (BlockStatement) method.getCode(); blockStatement.visit(new MethodVisitor(newIndexer, sourceUri, parent, classes, classFields, Optional.of(method), workspaceUriSupplier)); } } }
&& classes.containsKey(clazz.getSuperClass().getName())) { newIndexer.addReference(classes.get(clazz.getSuperClass().getName()), classSymbol.getLocation());
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);
.filter(symbol -> Ranges.isValid(symbol.getLocation().getRange())).collect(Collectors.toSet());