use of org.eclipse.jdt.internal.core.manipulation.search.OccurrencesFinder in project eclipse.jdt.ls by eclipse.
the class DocumentHighlightHandler method computeOccurrences.
private List<DocumentHighlight> computeOccurrences(ITypeRoot unit, int line, int column, IProgressMonitor monitor) {
if (unit != null) {
try {
int offset = JsonRpcHelpers.toOffset(unit.getBuffer(), line, column);
OccurrencesFinder finder = new OccurrencesFinder();
CompilationUnit ast = CoreASTProvider.getInstance().getAST(unit, CoreASTProvider.WAIT_YES, monitor);
if (ast != null) {
String error = finder.initialize(ast, offset, 0);
if (error == null) {
List<DocumentHighlight> result = new ArrayList<>();
OccurrenceLocation[] occurrences = finder.getOccurrences();
if (occurrences != null) {
for (OccurrenceLocation loc : occurrences) {
if (monitor.isCanceled()) {
return Collections.emptyList();
}
result.add(convertToHighlight(unit, loc));
}
}
return result;
}
}
} catch (JavaModelException e) {
JavaLanguageServerPlugin.logException("Problem with compute occurrences for" + unit.getElementName(), e);
}
}
return Collections.emptyList();
}
Aggregations