/** * Safely computes context information objects through the described extension. If the extension * is disabled, throws an exception or otherwise does not adhere to the contract described in * {@link IRubyCompletionProposalComputer}, an empty list is returned. * * @param context the invocation context passed on to the extension * @param monitor the progress monitor passed on to the extension * @return the list of computed context information objects (element type: {@link * org.eclipse.jface.text.contentassist.IContextInformation}) */ public List computeContextInformation( ContentAssistInvocationContext context, IProgressMonitor monitor) { if (!isEnabled()) return Collections.EMPTY_LIST; IStatus status; try { IRubyCompletionProposalComputer computer = getComputer(); if (computer == null) // not active yet return Collections.EMPTY_LIST; PerformanceStats stats = startMeter(context, computer); List proposals = computer.computeContextInformation(context, monitor); stopMeter(stats, COMPUTE_CONTEXT_INFORMATION); if (proposals != null) { fLastError = computer.getErrorMessage(); return proposals; } status = createAPIViolationStatus(COMPUTE_CONTEXT_INFORMATION); } catch (InvalidRegistryObjectException x) { status = createExceptionStatus(x); } catch (CoreException x) { status = createExceptionStatus(x); } catch (RuntimeException x) { status = createExceptionStatus(x); } finally { monitor.done(); } fRegistry.informUser(this, status); return Collections.EMPTY_LIST; }
/** * Notifies the described extension of a proposal computation session end. * * <p><em> Note: This method is called every time code assist is invoked and is * <strong>not</strong> filtered by partition type. </em> */ public void sessionEnded() { if (!isEnabled()) return; IStatus status; try { IRubyCompletionProposalComputer computer = getComputer(); if (computer == null) // not active yet return; PerformanceStats stats = startMeter(SESSION_ENDED, computer); computer.sessionEnded(); stopMeter(stats, SESSION_ENDED); return; } catch (InvalidRegistryObjectException x) { status = createExceptionStatus(x); } catch (CoreException x) { status = createExceptionStatus(x); } catch (RuntimeException x) { status = createExceptionStatus(x); } fRegistry.informUser(this, status); }