public List<Either<SymbolInformation, DocumentSymbol>> documentSymbol(DocumentSymbolParams params, IProgressMonitor monitor) { ITypeRoot unit = JDTUtils.resolveTypeRoot(params.getTextDocument().getUri()); if (unit == null) { return Collections.emptyList(); } if (hierarchicalDocumentSymbolSupported) { List<DocumentSymbol> symbols = this.getHierarchicalOutline(unit, monitor); return symbols.stream().map(Either::<SymbolInformation, DocumentSymbol>forRight).collect(toList()); } else { SymbolInformation[] elements = this.getOutline(unit, monitor); return Arrays.asList(elements).stream().map(Either::<SymbolInformation, DocumentSymbol>forLeft).collect(toList()); } }
public List<? extends Location> definition(TextDocumentPositionParams position, IProgressMonitor monitor) { ITypeRoot unit = JDTUtils.resolveTypeRoot(position.getTextDocument().getUri()); Location location = null; if (unit != null && !monitor.isCanceled()) { location = computeDefinitionNavigation(unit, position.getPosition().getLine(), position.getPosition().getCharacter(), monitor); } return location == null ? null : Arrays.asList(location); }
public List<? extends Location> typeDefinition(TextDocumentPositionParams position, IProgressMonitor monitor) { ITypeRoot unit = JDTUtils.resolveTypeRoot(position.getTextDocument().getUri()); Location location = null; if (unit != null && !monitor.isCanceled()) { location = computeTypeDefinitionNavigation(unit, position.getPosition().getLine(), position.getPosition().getCharacter(), monitor); } return location == null ? null : Arrays.asList(location); }
public Hover hover(TextDocumentPositionParams position, IProgressMonitor monitor) { ITypeRoot unit = JDTUtils.resolveTypeRoot(position.getTextDocument().getUri()); List<Either<String, MarkedString>> content = null; if (unit != null && !monitor.isCanceled()) { content = computeHover(unit, position.getPosition().getLine(), position.getPosition().getCharacter(), monitor); } else { content = Collections.singletonList(Either.forLeft("")); } Hover $ = new Hover(); $.setContents(content); return $; }
public List<? extends DocumentHighlight> documentHighlight(TextDocumentPositionParams position, IProgressMonitor monitor) { ITypeRoot type = JDTUtils.resolveTypeRoot(position.getTextDocument().getUri()); return computeOccurrences(type, position.getPosition().getLine(), position.getPosition().getCharacter(), monitor); }
ITypeRoot typeRoot = JDTUtils.resolveTypeRoot(uri); if (typeRoot != null) { IJavaElement element = JDTUtils.findElementAtSelection(typeRoot, position.getLine(), position.getCharacter(), this.preferenceManager, monitor);
public List<? extends Location> findImplementations(TextDocumentPositionParams param, IProgressMonitor monitor) { List<Location> locations = null; IJavaElement elementToSearch = null; try { ITypeRoot typeRoot = JDTUtils.resolveTypeRoot(param.getTextDocument().getUri()); if (typeRoot != null) { elementToSearch = JDTUtils.findElementAtSelection(typeRoot, param.getPosition().getLine(), param.getPosition().getCharacter(), this.preferenceManager, monitor); } if (elementToSearch == null) { return Collections.emptyList(); } int offset = getOffset(param, typeRoot); IRegion region = new Region(offset, 0); IType primaryType = typeRoot.findPrimaryType(); //java.lang.Object is a special case. We need to minimize heavy cost of I/O, // by avoiding opening all files from the Object hierarchy boolean useDefaultLocation = primaryType == null ? false : "java.lang.Object".equals(primaryType.getFullyQualifiedName()); ImplementationToLocationMapper mapper = new ImplementationToLocationMapper(preferenceManager.isClientSupportsClassFileContent(), useDefaultLocation); ImplementationCollector<Location> collector = new ImplementationCollector<>(region, elementToSearch, mapper); locations = collector.findImplementations(monitor); } catch (CoreException e) { JavaLanguageServerPlugin.logException("Find implementations failure ", e); } return locations; }
IJavaElement elementToSearch = JDTUtils.findElementAtSelection(JDTUtils.resolveTypeRoot(param.getTextDocument().getUri()), param.getPosition().getLine(), param.getPosition().getCharacter(), this.preferenceManager, monitor);