private static SymbolInformation createSymbolInformation(String name, SymbolKind kind, Location location, Optional<String> parentName) { return new SymbolInformation(name, kind, location, parentName.orNull()); }
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; } },
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); }
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; }
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); }
private SymbolInformation getVariableSymbolInformation(String parentName, URI sourceUri, Variable variable) { final SymbolKind kind; final Location location; if (variable instanceof DynamicVariable) { kind = SymbolKind.Field; location = GroovyLocations.createLocation(sourceUri); } else if (variable instanceof FieldNode) { kind = SymbolKind.Field; location = GroovyLocations.createLocation(sourceUri, (FieldNode) variable); } else if (variable instanceof Parameter) { kind = SymbolKind.Variable; location = GroovyLocations.createLocation(sourceUri, (Parameter) variable); } else if (variable instanceof PropertyNode) { kind = SymbolKind.Field; location = GroovyLocations.createLocation(sourceUri, (PropertyNode) variable); } else if (variable instanceof VariableExpression) { kind = SymbolKind.Variable; location = GroovyLocations.createLocation(sourceUri, (VariableExpression) variable); } else { throw new IllegalArgumentException(String.format("Unknown type of variable: %s", variable)); } return new SymbolInformation(variable.getName(), kind, location, parentName); }
private SymbolInformation getVariableSymbolInformation(Variable variable) { final String containerName; final SymbolKind kind; final Location location; if (methodNode.isPresent()) { containerName = methodNode.get().getName(); } else { containerName = clazz.getName(); } if (variable instanceof DynamicVariable) { kind = SymbolKind.Field; location = GroovyLocations.createLocation(workspaceUriSupplier.get(uri)); } else if (variable instanceof FieldNode) { kind = SymbolKind.Field; location = createLocation(uri, (FieldNode) variable); } else if (variable instanceof Parameter) { kind = SymbolKind.Variable; location = createLocation(uri, (Parameter) variable); } else if (variable instanceof PropertyNode) { kind = SymbolKind.Field; location = createLocation(uri, (PropertyNode) variable); } else if (variable instanceof VariableExpression) { kind = SymbolKind.Variable; location = createLocation(uri, (VariableExpression) variable); } else { throw new IllegalArgumentException(String.format("Unknown type of variable: %s", variable)); } return new SymbolInformation(variable.getName(), kind, location, containerName); }
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; }
@Before public void setup() throws IOException { MockitoAnnotations.initMocks(this); Diagnostic d1 = new Diagnostic(); d1.setMessage("Some message"); d1.setSeverity(DiagnosticSeverity.Error); Diagnostic d2 = new Diagnostic(); d2.setMessage("Some other message"); d2.setSeverity(DiagnosticSeverity.Warning); expectedDiagnostics = Sets.newHashSet(new PublishDiagnosticsParams("uri", ImmutableList.of(d1, d2))); expectedReferences.add(new SymbolInformation( "MyClassName", SymbolKind.Class, new Location("uri", Ranges.createRange(1, 1, 9, 9)), "Something")); expectedReferences.add(new SymbolInformation( "MyClassName2", SymbolKind.Class, new Location("uri", Ranges.createRange(1, 1, 9, 9)), "SomethingElse")); Set<SymbolInformation> allReferencesReturned = Sets.newHashSet(expectedReferences); // The reference that will be filtered out allReferencesReturned.add(new SymbolInformation( "MyClassName3", SymbolKind.Class, new Location("uri", Ranges.UNDEFINED_RANGE), "SomethingElse")); when(compilerWrapper.getWorkspaceRoot()).thenReturn(workspace.getRoot().toPath().toUri()); when(compilerWrapper.compile(any())).thenReturn(expectedDiagnostics); when(compilerWrapper.getFilteredSymbols(any())).thenReturn(allReferencesReturned); when(state.getCompilerWrapper()).thenReturn(compilerWrapper); service = new TestWorkspaceService(state); }
))); SymbolInformation symbol1 = new SymbolInformation("ThisIsASymbol", SymbolKind.Field, new Location()); SymbolInformation symbol2 = new SymbolInformation("methodA", SymbolKind.Method, new Location()); symbolsMap.put(filePath.toUri(), Sets.newHashSet(symbol1, symbol2));
SymbolInformation si = new SymbolInformation(); String name = JavaElementLabels.getElementLabel(element, JavaElementLabels.ALL_DEFAULT); si.setName(name == null ? element.getElementName() : name);
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"), new SymbolInformation( "idx2",
protected SymbolInformation createSymbol(TextDocument doc, Node node, YType type) throws BadLocationException { DocumentRegion region = NodeUtil.region(doc, node); Location location = new Location(doc.getUri(), doc.toRange(region.getStart(), region.getLength())); SymbolInformation symbol = new SymbolInformation(); symbol.setName(region.toString()); symbol.setKind(symbolKind(type)); symbol.setLocation(location); symbol.setContainerName(containerName(type)); return symbol; }
@Override public void acceptTypeNameMatch(TypeNameMatch match) { SymbolInformation symbolInformation = new SymbolInformation(); symbolInformation.setContainerName(match.getTypeContainerName()); symbolInformation.setName(match.getSimpleTypeName()); symbolInformation.setKind(mapKind(match)); Location location; try { if (match.getType().isBinary()) { location = JDTUtils.toLocation(match.getType().getClassFile()); } else { location = JDTUtils.toLocation(match.getType()); } } catch (Exception e) { JavaLanguageServerPlugin.logException("Unable to determine location for " + match.getSimpleTypeName(), e); return; } symbolInformation.setLocation(location); symbols.add(symbolInformation); }
assertEquals(Sets.newHashSet(new SymbolInformation( "Coordinates", SymbolKind.Class, new SymbolInformation( "Coordinates", SymbolKind.Class, createLocation(coordinatesFiles.toPath(), Ranges.createRange(0, 0, 1, 0))), new SymbolInformation( "CoordinatesVar", SymbolKind.Field, new SymbolInformation( "Coordinates", SymbolKind.Class, createLocation(coordinatesFiles.toPath(), Ranges.createRange(0, 0, 1, 0))), new SymbolInformation( "ICoordinates", SymbolKind.Interface, createLocation(icoordinatesFiles.toPath(), Ranges.createRange(0, 0, 1, 0))), new SymbolInformation( "CoordinatesVar", SymbolKind.Field, new SymbolInformation( "CoordinatesVar", SymbolKind.Field,
/** * @since 2.16 */ protected SymbolInformation createSymbol(final String uri, final DocumentSymbol symbol, final Function1<? super DocumentSymbol, ? extends String> containerNameProvider) { SymbolInformation _symbolInformation = new SymbolInformation(); final Procedure1<SymbolInformation> _function = (SymbolInformation it) -> { it.setName(symbol.getName()); it.setKind(symbol.getKind()); it.setDeprecated(symbol.getDeprecated()); Location _location = new Location(); final Procedure1<Location> _function_1 = (Location it_1) -> { it_1.setUri(uri); it_1.setRange(symbol.getSelectionRange()); }; Location _doubleArrow = ObjectExtensions.<Location>operator_doubleArrow(_location, _function_1); it.setLocation(_doubleArrow); it.setContainerName(containerNameProvider.apply(symbol)); }; return ObjectExtensions.<SymbolInformation>operator_doubleArrow(_symbolInformation, _function); }
it.setJsonrpc("2.0"); it.setId("12"); SymbolInformation _symbolInformation = new SymbolInformation(); final Procedure1<SymbolInformation> _function_2 = (SymbolInformation it_1) -> { it_1.setName("foobar");