public void doOperation(int operation) { if (getTextWidget() == null) return; switch (operation) { case CONTENTASSIST_PROPOSALS: long time= CODE_ASSIST_DEBUG ? System.currentTimeMillis() : 0; String msg= fContentAssistant.showPossibleCompletions(); if (CODE_ASSIST_DEBUG) { long delta= System.currentTimeMillis() - time; System.err.println("Code Assist (total): " + delta); //$NON-NLS-1$ } setStatusLineErrorMessage(msg); return; case QUICK_ASSIST: /* * XXX: We can get rid of this once the SourceViewer has a way to update the status line * https://bugs.eclipse.org/bugs/show_bug.cgi?id=133787 */ msg= fQuickAssistAssistant.showPossibleQuickAssists(); setStatusLineErrorMessage(msg); return; } super.doOperation(operation); }
protected ICompletionProposal[] computeCompletionProposals(final IXtextDocument xtextDocument, int cursorPosition, XtextSourceViewerConfiguration configuration, ISourceViewer sourceViewer) throws BadLocationException { IContentAssistant contentAssistant = configuration.getContentAssistant(sourceViewer); String contentType = xtextDocument.getContentType(cursorPosition); IContentAssistProcessor processor = contentAssistant.getContentAssistProcessor(contentType); if (processor != null) { return processor.computeCompletionProposals(sourceViewer, cursorPosition); } return new ICompletionProposal[0]; }
fContentAssistant.showPossibleCompletions(); return; case CONTENTASSIST_CONTEXT_INFORMATION: fContentAssistant.showContextInformation(); return; case QUICK_ASSIST:
fContentAssistant.uninstall(); fContentAssistantInstalled= false; fContentAssistant= null;
fContentAssistant.install(this); if (fContentAssistant instanceof IContentAssistantExtension2 && fContentAssistant instanceof IContentAssistantExtension4) fContentAssistantFacade= new ContentAssistantFacade(fContentAssistant);
fContentAssistant.showPossibleCompletions(); return; case CONTENTASSIST_CONTEXT_INFORMATION: fContentAssistant.showContextInformation(); return; case QUICK_ASSIST:
fContentAssistant.uninstall(); fContentAssistantInstalled= false; fContentAssistant= null;
fContentAssistant.install(this); if (fContentAssistant instanceof IContentAssistantExtension2 && fContentAssistant instanceof IContentAssistantExtension4) fContentAssistantFacade= new ContentAssistantFacade(fContentAssistant);
@Override public void doOperation(int operation) { if (getTextWidget() == null) return; switch (operation) { case CONTENTASSIST_PROPOSALS: long time= JavaPlugin.DEBUG_RESULT_COLLECTOR ? System.currentTimeMillis() : 0; String msg= fContentAssistant.showPossibleCompletions(); if (JavaPlugin.DEBUG_RESULT_COLLECTOR) { long delta= System.currentTimeMillis() - time; System.err.println("Code Assist (total): " + delta); //$NON-NLS-1$ } setStatusLineErrorMessage(msg); return; case QUICK_ASSIST: /* * XXX: We can get rid of this once the SourceViewer has a way to update the status line * https://bugs.eclipse.org/bugs/show_bug.cgi?id=133787 */ msg= fQuickAssistAssistant.showPossibleQuickAssists(); setStatusLineErrorMessage(msg); return; } super.doOperation(operation); }
public ContentAssistProcessorTestBuilder assertMatchString(String matchString) throws Exception { String currentModelToParse = getModel(); final XtextResource xtextResource = loadHelper.getResourceFor(new StringInputStream(currentModelToParse)); final IXtextDocument xtextDocument = getDocument(xtextResource, currentModelToParse); XtextSourceViewerConfiguration configuration = get(XtextSourceViewerConfiguration.class); Shell shell = new Shell(); try { ISourceViewer sourceViewer = getSourceViewer(shell, xtextDocument, configuration); IContentAssistant contentAssistant = configuration.getContentAssistant(sourceViewer); String contentType = xtextDocument.getContentType(currentModelToParse.length()); if (contentAssistant.getContentAssistProcessor(contentType) != null) { ContentAssistContext.Factory factory = get(ContentAssistContext.Factory.class); ContentAssistContext[] contexts = factory.create(sourceViewer, currentModelToParse.length(), xtextResource); for(ContentAssistContext context: contexts) { Assert.assertTrue("matchString = '" + matchString + "', actual: '" + context.getPrefix() + "'", "".equals(context.getPrefix()) || matchString.equals(context.getPrefix())); } } else { Assert.fail("No content assistant for content type " + contentType); } return this; } finally { shell.dispose(); } }
@Override public void doOperation(int operation) { if (getTextWidget() == null) return; switch (operation) { case CONTENTASSIST_PROPOSALS: long time= JavaPlugin.DEBUG_RESULT_COLLECTOR ? System.currentTimeMillis() : 0; String msg= fContentAssistant.showPossibleCompletions(); if (JavaPlugin.DEBUG_RESULT_COLLECTOR) { long delta= System.currentTimeMillis() - time; System.err.println("Code Assist (total): " + delta); //$NON-NLS-1$ } setStatusLineErrorMessage(msg); return; case QUICK_ASSIST: /* * XXX: We can get rid of this once the SourceViewer has a way to update the status line * https://bugs.eclipse.org/bugs/show_bug.cgi?id=133787 */ msg= fQuickAssistAssistant.showPossibleQuickAssists(); setStatusLineErrorMessage(msg); return; } super.doOperation(operation); }
public ContentAssistProcessorTestBuilder assertMatchString(String matchString) throws Exception { String currentModelToParse = getModel(); final XtextResource xtextResource = loadHelper.getResourceFor(new StringInputStream(currentModelToParse)); final IXtextDocument xtextDocument = getDocument(xtextResource, currentModelToParse); XtextSourceViewerConfiguration configuration = get(XtextSourceViewerConfiguration.class); Shell shell = new Shell(); try { ISourceViewer sourceViewer = getSourceViewer(shell, xtextDocument, configuration); IContentAssistant contentAssistant = configuration.getContentAssistant(sourceViewer); String contentType = xtextDocument.getContentType(currentModelToParse.length()); if (contentAssistant.getContentAssistProcessor(contentType) != null) { ContentAssistContext.Factory factory = get(ContentAssistContext.Factory.class); ContentAssistContext[] contexts = factory.create(sourceViewer, currentModelToParse.length(), xtextResource); for(ContentAssistContext context: contexts) { Assert.assertTrue("matchString = '" + matchString + "', actual: '" + context.getPrefix() + "'", "".equals(context.getPrefix()) || matchString.equals(context.getPrefix())); } } else { Assert.fail("No content assistant for content type " + contentType); } return this; } finally { shell.dispose(); } }
@Override public void doOperation(int operation) { if (getTextWidget() == null || !redraws()) { return; } switch (operation) { case CONTENTASSIST_PROPOSALS: String msg = fContentAssistant.showPossibleCompletions(); setStatusLineErrorMessage(msg); return; default: break; } super.doOperation(operation); } }
.getContentAssistProcessor( LdifPartitionScanner.LDIF_RECORD );
public ICompletionProposal[] computeCompletionProposals(final String currentModelToParse, int cursorPosition) throws Exception { final XtextResource xtextResource = loadHelper.getResourceFor(new StringInputStream(currentModelToParse)); final IXtextDocument xtextDocument = getDocument(xtextResource, currentModelToParse); XtextSourceViewerConfiguration configuration = get(XtextSourceViewerConfiguration.class); Shell shell = new Shell(); try { ISourceViewer sourceViewer = getSourceViewer(shell, xtextDocument, configuration); IContentAssistant contentAssistant = configuration.getContentAssistant(sourceViewer); String contentType = xtextDocument.getContentType(cursorPosition); IContentAssistProcessor processor = contentAssistant.getContentAssistProcessor(contentType); if (processor != null) { return processor.computeCompletionProposals(sourceViewer, cursorPosition); } return new ICompletionProposal[0]; } finally { shell.dispose(); } }