/** * Invoke content assist on the given viewer at the given offset, for the given number of pages * and return the results of each page * * @param viewer * @param offset * @param pageCount * @return * @throws Exception */ private static ICompletionProposal[][] getProposals( StructuredTextViewer viewer, int offset, int pageCount) throws Exception { // setup the viewer StructuredTextViewerConfigurationHTML configuration = new StructuredTextViewerConfigurationHTML(); ContentAssistant contentAssistant = (ContentAssistant) configuration.getContentAssistant(viewer); viewer.configure(configuration); viewer.setSelectedRange(offset, 0); // get the processor String partitionTypeID = viewer.getDocument().getPartition(offset).getType(); IContentAssistProcessor processor = contentAssistant.getContentAssistProcessor(partitionTypeID); // fire content assist session about to start Method privateFireSessionBeginEventMethod = ContentAssistant.class.getDeclaredMethod( "fireSessionBeginEvent", new Class[] {boolean.class}); privateFireSessionBeginEventMethod.setAccessible(true); privateFireSessionBeginEventMethod.invoke(contentAssistant, new Object[] {Boolean.TRUE}); // get content assist suggestions ICompletionProposal[][] pages = new ICompletionProposal[pageCount][]; for (int p = 0; p < pageCount; ++p) { pages[p] = processor.computeCompletionProposals(viewer, offset); } // fire content assist session ending Method privateFireSessionEndEventMethod = ContentAssistant.class.getDeclaredMethod("fireSessionEndEvent", null); privateFireSessionEndEventMethod.setAccessible(true); privateFireSessionEndEventMethod.invoke(contentAssistant, null); return pages; }
/* * (non-Javadoc) * * @see * org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets * .Composite) */ @Override public void createPartControl(Composite parent) { int styles = SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.FULL_SELECTION; fSourceViewer = new StructuredTextViewer(parent, null, null, false, styles); fSourceViewer.setEditable(false); fSourceViewer.configure(new StructuredTextViewerConfigurationHTML()); getSite() .getWorkbenchWindow() .getSelectionService() .addSelectionListener(IDebugUIConstants.ID_DEBUG_VIEW, this); getSite().setSelectionProvider(fSourceViewer.getSelectionProvider()); setBackgroundColor(); fTerminateListener = new IDebugEventSetListener() { public void handleDebugEvents(DebugEvent[] events) { if (events != null) { int size = events.length; for (int i = 0; i < size; i++) { Object obj = events[i].getSource(); if (!(obj instanceof IPHPDebugTarget || obj instanceof PHPThread)) continue; if (events[i].getKind() == DebugEvent.TERMINATE || events[i].getKind() == DebugEvent.SUSPEND) { final IPHPDebugTarget target; if (obj instanceof IPHPDebugTarget) { target = (IPHPDebugTarget) obj; } else { target = (IPHPDebugTarget) ((PHPThread) obj).getDebugTarget(); } Job job = new UIJob(PHPDebugUIMessages.PHPDebugUIPlugin_1) { public IStatus runInUIThread(IProgressMonitor monitor) { update(target); return Status.OK_STATUS; } }; job.schedule(); } } } } }; DebugPlugin.getDefault().addDebugEventListener(fTerminateListener); if (fPartListener == null) { fPartListener = new DebugViewPartListener(); getSite().getPage().addPartListener(fPartListener); } }