protected String getDocumentPartitioning(ISourceViewer sourceViewer) { return getConfiguredDocumentPartitioning(sourceViewer); }
@Override public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) { XtextPresentationReconciler reconciler = getPresentationReconcilerProvider().get(); reconciler.setDocumentPartitioning(getDocumentPartitioning(sourceViewer)); IPresentationRepairer repairer = repairerProvider.get(); IPresentationDamager damager = damagerProvider.get(); String[] types = partitionTypesMapper.getSupportedPartitionTypes(); for (String partitionType : types) { reconciler.setRepairer(repairer, partitionType); reconciler.setDamager(damager, partitionType); } return reconciler; }
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]; }
@Override protected void configureSourceViewer(ISourceViewer sourceViewer) { sourceViewer.setEditable(false); sourceViewer.configure(sourceViewerConfiguration); if (sourceViewer instanceof ITextViewerExtension6) { ITextViewerExtension6 textViewerExtension6 = (ITextViewerExtension6) sourceViewer; textViewerExtension6.setHyperlinkDetectors(null, sourceViewerConfiguration.getHyperlinkStateMask(sourceViewer)); } if (sourceViewer instanceof ITextViewerExtension2) { ITextViewerExtension2 textViewerExtension2 = (ITextViewerExtension2) sourceViewer; String[] configuredContentTypes = sourceViewerConfiguration.getConfiguredContentTypes(sourceViewer); for (String contentType : configuredContentTypes) { textViewerExtension2.removeTextHovers(contentType); } } }
@Override public void init(IEditorSite site, IEditorInput input) throws PartInitException { if (log.isDebugEnabled()) log.debug("init:" + input); // do document provider setup setDocumentProvider(documentProvider.get()); // source viewer setup setSourceViewerConfiguration(sourceViewerConfiguration); sourceViewerConfiguration.setEditor(this); setPreferenceStore(preferenceStoreAccess.getContextPreferenceStore(input)); // NOTE: Outline CANNOT be initialized here, since we do not have access // to the source viewer yet (it will be created later). super.init(site, input); }
@Override protected void setPreferenceStore(IPreferenceStore preferenceStore) { super.setPreferenceStore(preferenceStore); if (getSourceViewerConfiguration() instanceof XtextSourceViewerConfiguration) { XtextSourceViewerConfiguration xtextSourceViewerConfiguration = (XtextSourceViewerConfiguration) getSourceViewerConfiguration(); xtextSourceViewerConfiguration.setPreferenceStore(preferenceStore); } }
/** * @since 2.3 */ public void install(XtextSourceViewerConfiguration configuration, XtextSourceViewer sourceViewer) { fSourceViewer= sourceViewer; fConfiguration= configuration; if(sourceViewer != null && configuration != null){ fPresentationReconciler= (XtextPresentationReconciler) fConfiguration.getPresentationReconciler(sourceViewer); } else { fPresentationReconciler = null; fConfiguration = null; } preferenceStore = getPreferenceStoreAccessor().getPreferenceStore(); preferenceStore.addPropertyChangeListener(this); enable(); }
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(); } }
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 ITextDoubleClickStrategy getDoubleClickStrategy(ISourceViewer sourceViewer, String contentType) { return doubleClickStrategyProvider.getStrategy(sourceViewer, contentType, getConfiguredDocumentPartitioning(sourceViewer)); }
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(); } }