Java Code Examples for org.eclipse.jdt.core.ITypeRoot#getChildren()
The following examples show how to use
org.eclipse.jdt.core.ITypeRoot#getChildren() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DocumentSymbolHandler.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private SymbolInformation[] getOutline(ITypeRoot unit, IProgressMonitor monitor) { try { IJavaElement[] elements = unit.getChildren(); ArrayList<SymbolInformation> symbols = new ArrayList<>(elements.length); collectChildren(unit, elements, symbols, monitor); return symbols.toArray(new SymbolInformation[symbols.size()]); } catch (JavaModelException e) { JavaLanguageServerPlugin.logException("Problem getting outline for" + unit.getElementName(), e); } return new SymbolInformation[0]; }
Example 2
Source File: CodeLensHandler.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
public List<CodeLens> getCodeLensSymbols(String uri, IProgressMonitor monitor) { if (!preferenceManager.getPreferences().isCodeLensEnabled()) { return Collections.emptyList(); } final ICompilationUnit unit = JDTUtils.resolveCompilationUnit(uri); IClassFile classFile = null; if (unit == null) { classFile = JDTUtils.resolveClassFile(uri); if (classFile == null) { return Collections.emptyList(); } } else { if (!unit.getResource().exists() || monitor.isCanceled()) { return Collections.emptyList(); } } try { ITypeRoot typeRoot = unit != null ? unit : classFile; IJavaElement[] elements = typeRoot.getChildren(); LinkedHashSet<CodeLens> lenses = new LinkedHashSet<>(elements.length); collectCodeLenses(typeRoot, elements, lenses, monitor); if (monitor.isCanceled()) { lenses.clear(); } return new ArrayList<>(lenses); } catch (JavaModelException e) { JavaLanguageServerPlugin.logException("Problem getting code lenses for" + unit.getElementName(), e); } return Collections.emptyList(); }
Example 3
Source File: FoldingRangeHandler.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private void computeTypeRootRanges(List<FoldingRange> foldingRanges, ITypeRoot unit, IScanner scanner) throws CoreException { if (unit.hasChildren()) { for (IJavaElement child : unit.getChildren()) { if (child instanceof IImportContainer) { ISourceRange importRange = ((IImportContainer) child).getSourceRange(); FoldingRange importFoldingRange = new FoldingRange(scanner.getLineNumber(importRange.getOffset()) - 1, scanner.getLineNumber(importRange.getOffset() + importRange.getLength()) - 1); importFoldingRange.setKind(FoldingRangeKind.Imports); foldingRanges.add(importFoldingRange); } else if (child instanceof IType) { computeTypeRanges(foldingRanges, (IType) child, scanner); } } } }