Package org.eclipse.xtext.ui.editor.model

Examples of org.eclipse.xtext.ui.editor.model.XtextDocument


    }
    return null;
  }

  private IDocument createDocument(DocumentContentsFactory contentsFactory, Object element) throws CoreException {
    XtextDocument document = createEmptyDocument();
    contentsFactory.createContents(document, element);
    return document;
  }
View Full Code Here


      try {
        workbench.getProgressService().run(true, true, new IRunnableWithProgress() {

          @Override
          public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            XtextDocument doc = ((ModelQueryLanguageView) view).getEmbeddedEditor().getDocument();
            String result = doc.readOnly(new IUnitOfWork<String, XtextResource>() {
              @Override
              public String exec(XtextResource r) throws Exception {
                Model m = (Model) r.getContents().get(0);
                return interpret(m, monitor);
              }
            });
            ref.set(result);
          }
        });
        mqlv.getEmbeddedEditorResult().getDocument().set(ref.get());
      } catch (InvocationTargetException e) {
        e.printStackTrace();
      } catch (InterruptedException e) {
        e.printStackTrace();
      }

    } else if (activeEditor != null && activeEditor instanceof XtextEditor) {
      final XtextEditor editor = (XtextEditor) activeEditor;
      final Holder<String> ref = new Holder<String>();
      try {
        workbench.getProgressService().run(true, true, new IRunnableWithProgress() {

          @Override
          public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            XtextDocument doc = (XtextDocument) editor.getDocument();
            String result = doc.readOnly(new IUnitOfWork<String, XtextResource>() {
              @Override
              public String exec(XtextResource r) throws Exception {
                Model m = (Model) r.getContents().get(0);
                return interpret(m, monitor);
              }
View Full Code Here

    return sourceViewer;
  }

  public IXtextDocument getDocument(final XtextResource xtextResource,
      final String model) {
    XtextDocument document = documentProvider.get();
    document.set(model);
    document.setInput(xtextResource);
    DocumentPartitioner partitioner = partitionerProvider.get();
    partitioner.connect(document);
    document.setDocumentPartitioner(partitioner);
    return document;
  }
View Full Code Here

    return null;
  }
 
  @Override
  protected IRegion findWord(IDocument document, final int offset) {
    XtextDocument xdoc = (XtextDocument) document;

    IRegion result = xdoc.readOnly(new IUnitOfWork<IRegion, XtextResource>() {

      @Override
      public IRegion exec(XtextResource state) throws Exception {
        // resource can be null e.g. read only zip/jar entry
        if (state == null) {
View Full Code Here

TOP

Related Classes of org.eclipse.xtext.ui.editor.model.XtextDocument

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.