@Override public boolean handleResult( ExtendedLanguageServer element, List<? extends Location> locations) { locations.forEach( o -> { o.setUri(removePrefixUri(o.getUri())); result.add(new LocationDto(o)); }); return true; } },
@Override public boolean handleResult( ExtendedLanguageServer element, List<? extends Location> locations) { locations.forEach( o -> { o.setUri(removePrefixUri(o.getUri())); result.add(new LocationDto(o)); }); return true; } },
public static Location fixLocation(Location o) { o.setUri(removePrefixUri(o.getUri())); return o; }
@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; } },
Location clone(Location location) { if (location == null) { return null; } Range range = location.getRange(); String uri = location.getUri(); Location cloned = new Location(); cloned.setRange(clone(range)); cloned.setUri(uri); return cloned; }
private static Location fixLocation(IJavaElement element, Location location, IJavaProject javaProject) { if (!javaProject.equals(element.getJavaProject()) && element.getJavaProject().getProject().getName().equals(ProjectsManager.DEFAULT_PROJECT_NAME)) { // see issue at: https://github.com/eclipse/eclipse.jdt.ls/issues/842 and https://bugs.eclipse.org/bugs/show_bug.cgi?id=541573 // for jdk classes, jdt will reuse the java model by altering project to share the model between projects // so that sometimes the project for `element` is default project and the project is different from the project for `unit` // this fix is to replace the project name with non-default ones since default project should be transparent to users. if (location.getUri().contains(ProjectsManager.DEFAULT_PROJECT_NAME)) { String patched = StringUtils.replaceOnce(location.getUri(), ProjectsManager.DEFAULT_PROJECT_NAME, javaProject.getProject().getName()); try { IClassFile cf = (IClassFile) JavaCore.create(JDTUtils.toURI(patched).getQuery()); if (cf != null && cf.exists()) { location.setUri(patched); } } catch (Exception ex) { } } } return location; }
@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; }
.name.getValue(), parentPath, definitionContext .get(NodeContextKeys.PACKAGE_OF_NODE_KEY).name.getValue()), fileName); l.setUri(filePath.toUri().toString()); Range r = new Range();
si.setContainerName(element.getParent().getElementName()); location.setUri(ResourceUtils.toClientUri(location.getUri())); si.setLocation(location); if (!symbols.contains(si)) {
/** * Get the physical source location of the given package. * * @param bLangNode ballerina language node references are requested for * @param ownerPackageName list of name compositions of the node's package name * @param currentPackageName list of name compositions of the current package * @return location of the package of the given node */ private Location getLocation(BLangNode bLangNode, String ownerPackageName, String currentPackageName) { Location l = new Location(); Range r = new Range(); TextDocumentPositionParams position = this.context.get(DocumentServiceKeys.POSITION_KEY); String parentPath = new LSDocument(position.getTextDocument().getUri()).getSourceRoot(); if (parentPath != null) { String fileName = bLangNode.getPosition().getSource().getCompilationUnitName(); Path filePath = Paths.get(CommonUtil.getPackageURI(currentPackageName, parentPath, ownerPackageName), fileName); l.setUri(filePath.toUri().toString()); // Subtract 1 to convert the token lines and char positions to zero based indexing r.setStart(new Position(bLangNode.getPosition().getStartLine() - 1, bLangNode.getPosition().getStartColumn() - 1)); r.setEnd(new Position(bLangNode.getPosition().getEndLine() - 1, bLangNode.getPosition().getEndColumn() - 1)); l.setRange(r); } return l; }
/** * @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); }
Location _location = new Location(); final Procedure1<Location> _function_3 = (Location it_2) -> { it_2.setUri("file:/baz.txt"); Range _range = new Range(); final Procedure1<Range> _function_4 = (Range it_3) -> {