Java 类org.eclipse.xtext.ui.editor.XtextSourceViewerConfiguration 实例源码

项目:dsl-devkit    文件:AcfContentAssistProcessorTestBuilder.java   
/**
 * Internally compute completion proposals.
 *
 * @param cursorPosition
 *          the position of the cursor in the {@link IXtextDocument}
 * @param xtextDocument
 *          the {@link IXtextDocument}
 * @return a pair of {@link ICompletionProposal}[] and {@link BadLocationException}. If the tail argument is not {@code null}, an exception occurred in the UI
 *         thread.
 */
private Pair<ICompletionProposal[], BadLocationException> internalComputeCompletionProposals(final int cursorPosition, final IXtextDocument xtextDocument) {
  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 Tuples.create(processor.computeCompletionProposals(sourceViewer, cursorPosition), null);
    }
    return Tuples.create(new ICompletionProposal[0], null);
  } catch (BadLocationException e) {
    return Tuples.create(new ICompletionProposal[0], e);
  } finally {
    shell.dispose();
  }
}
项目:dsl-devkit    文件:AcfContentAssistProcessorTestBuilder.java   
/**
 * {@inheritDoc} Code copied from parent. Override required to run in UI because of getSourceViewer, which creates a new Shell.
 */
@Override
public ContentAssistProcessorTestBuilder assertMatchString(final String matchString) throws Exception {
  BadLocationException exception = UiThreadDispatcher.dispatchAndWait(new Function<BadLocationException>() {
    @Override
    public BadLocationException run() {
      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);
        }
      } catch (BadLocationException e) {
        return e;
      } finally {
        shell.dispose();
      }
      return null;
    }
  });
  if (exception != null) {
    throw exception;
  }
  return this;
}
项目:dsl-devkit    文件:AbstractContentAssistUiTest.java   
/**
 * Helper function to find the correct CompletionProposalComputer for the given offset.
 *
 * @param offset
 *          offset in test file
 * @return language and offset specific content assist proposal computer
 */
private CompletionProposalComputer createCompletionProposalComputer(final int offset) {
  XtextSourceViewerConfiguration configuration = getEditor().getXtextSourceViewerConfiguration();
  IContentAssistant contentAssistant = configuration.getContentAssistant(getViewer());
  IContentAssistProcessor contentAssistProcessor;
  try {
    contentAssistProcessor = contentAssistant.getContentAssistProcessor(getDocument().getContentType(offset));
  } catch (BadLocationException e) {
    contentAssistProcessor = getTestUtil().get(IContentAssistProcessor.class);
  }
  if (contentAssistProcessor == null) {
    contentAssistProcessor = getTestUtil().get(IContentAssistProcessor.class);
  }
  return new CompletionProposalComputer((State) contentAssistProcessor, (ITextViewer) getViewer(), offset);
}
项目:bts    文件:DefaultMergeViewer.java   
public DefaultMergeViewer(Composite parent, int styles, CompareConfiguration compareConfiguration,
        StreamContentDocumentProvider documentProvider,
        Provider<XtextSourceViewerConfiguration> sourceViewerConfigurationProvider) {
    super(parent, styles | SWT.LEFT_TO_RIGHT, compareConfiguration);
    this.documentProvider = documentProvider;
    this.sourceViewerConfigurationProvider = sourceViewerConfigurationProvider;
}
项目:bts    文件:EmbeddedEditor.java   
public EmbeddedEditor(XtextDocument document, XtextSourceViewer viewer, XtextSourceViewerConfiguration configuration, IEditedResourceProvider resourceProvider, Runnable afterSetDocumet) {
    this.document = document;
    this.viewer = viewer;
    this.configuration = configuration;
    this.resourceProvider = resourceProvider;
    this.afterSetDocument = afterSetDocumet;
}
项目:bts    文件:HighlightingHelper.java   
/**
 * @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();
}
项目:bts    文件:EmbeddedEditor.java   
public XtextSourceViewerConfiguration getConfiguration() {
    return this.configuration;
}
项目:statecharts    文件:StyledTextXtextAdapter.java   
protected XtextSourceViewerConfiguration getXtextSourceViewerConfiguration() {
    return this.configuration;
}
项目:PDFReporter-Studio    文件:StyledTextXtextAdapter.java   
protected XtextSourceViewerConfiguration getXtextSourceViewerConfiguration() {
    return configuration;
}
项目:gama    文件:GamlUiModule.java   
public Class<? extends XtextSourceViewerConfiguration> bindXtextSourceViewerConfiguration() {
    return GamaSourceViewerConfiguration.class;
}
项目:sadlos2    文件:SadlUiModule.java   
public Class<? extends XtextSourceViewerConfiguration> bindXtextSourceViewerConfiguration() {
    return SadlSourceViewerConfiguration.class;
}