Examples of IXtextDocument


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

    String _head_1 = IterableExtensions.<String>head(((Iterable<String>)Conversions.doWrapArray(_data_1)));
    _builder.append(_head_1, "");
    _builder.append(".");
    final IModification _function = new IModification() {
      public void apply(final IModificationContext it) throws Exception {
        IXtextDocument _xtextDocument = it.getXtextDocument();
        Integer _offset = issue.getOffset();
        Integer _length = issue.getLength();
        String[] _data = issue.getData();
        String _head = IterableExtensions.<String>head(((Iterable<String>)Conversions.doWrapArray(_data)));
        _xtextDocument.replace((_offset).intValue(), (_length).intValue(), _head);
      }
    };
    acceptor.accept(issue, _plus, _builder.toString(), null, _function);
  }
View Full Code Here

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

  @Override
  public void partActivated(final IWorkbenchPart part) {
    if (part instanceof XtextEditor) {
      XtextEditor xtextEditor = (XtextEditor) part;
      IXtextDocument xtextDocument = xtextEditor.getDocument();
      if (xtextDocument != lastActiveDocument) {
        selectionLinker.setXtextEditor(xtextEditor);
        final IFigure contents = xtextDocument.readOnly(new IUnitOfWork<IFigure, XtextResource>() {
          @Override
          public IFigure exec(final XtextResource resource) throws Exception {
            return createFigure(resource);
          }
        });
View Full Code Here

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

    final XtextEditor xtextEditor = EditorUtils.getActiveXtextEditor(event);
    if (xtextEditor == null) {
      return null;
    }
    final IXtextDocument document = xtextEditor.getDocument();
    document.modify(new IUnitOfWork.Void<XtextResource>() {
      @Override
      public void process(XtextResource state) throws Exception {
        doExecute(xtextEditor, state);
      }
View Full Code Here

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

    Query query = queryParser.parse(currentModelToParse);
    if (query == null) {
      return new ICompletionProposal[0];
    }
    final XtextResource xtextResource = (XtextResource) query.eResource();
    final IXtextDocument xtextDocument = getDocument(xtextResource,
        currentModelToParse);

    XtextSourceViewerConfiguration configuration = configurationProvider
        .get();
    ISourceViewer sourceViewer = getSourceViewer(xtextDocument,
        configuration);
    IContentAssistant contentAssistant = configuration
        .getContentAssistant(sourceViewer);
    String contentType;
    try {
      contentType = xtextDocument.getContentType(cursorPosition);
    } catch (BadLocationException e) {
      return new ICompletionProposal[0];
    }
    IContentAssistProcessor processor = contentAssistant
        .getContentAssistProcessor(contentType);
View Full Code Here

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

    return null;
  }

  public <R> R readOnly(final URI targetURI, final IUnitOfWork<R, ResourceSet> work) {
    R result = null;
    IXtextDocument document = getOpenDocument(targetURI.trimFragment());
    if(document != null) {
      result = document.readOnly(new IUnitOfWork<R, XtextResource>() {
        public R exec(XtextResource state) throws Exception {
          ResourceSet localContext = state.getResourceSet();
          if(localContext != null)
            return work.exec(localContext);
          return null;
View Full Code Here

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

    Object editor = ctx.getVariable("activeEditor");
    if(editor == null || !(editor instanceof XtextEditor)) {
      return new Status(IStatus.ERROR, pluginid, "Handler invoked on wrong type of editor: XtextEditor");
    }
    XtextEditor xtextEditor = (XtextEditor) editor;
    IXtextDocument xtextDocument = XtextDocumentUtil.get(xtextEditor);
    if(xtextDocument == null) {
      return new Status(IStatus.ERROR, pluginid, "No document found in current editor");
    }
    IStatus result = xtextDocument.readOnly(new IUnitOfWork<IStatus, XtextResource>() {
      @Override
      public IStatus exec(XtextResource state) throws Exception {
        try {
          resourceScope.enter(state);
          return doDebug(state);
View Full Code Here

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

public class ContentFormatterFactory implements IContentFormatterFactory {

  public class ContentFormatter implements IContentFormatter {
    public void format(IDocument document, IRegion region) {
      IXtextDocument doc = (IXtextDocument) document;
      doc.modify(new FormattingUnitOfWork(doc, region));
    }
View Full Code Here

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

    this.suffix = suffix;
  }

  @Override
  public void apply(IModificationContext context) throws BadLocationException {
    IXtextDocument xtextDocument = context.getXtextDocument();
    String tmp = text + xtextDocument.get(offset, length) + suffix;
    xtextDocument.replace(offset, length, tmp);
  }
View Full Code Here

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

    this.handleQuotes = handleQuotes;
  }

  @Override
  public void apply(IModificationContext context) throws BadLocationException {
    IXtextDocument xtextDocument = context.getXtextDocument();
    int o = offset;
    int l = length;
    if(handleQuotes) {
      String s = xtextDocument.get(offset, length);
      char c = s.charAt(0);
      if(s.charAt(s.length() - 1) == c && (c == '\'' || c == '"')) {
        o++;
        l -= 2;
      }
    }
    xtextDocument.replace(o, l, text);
  }
View Full Code Here

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

  @Fix(IPPDiagnostics.ISSUE_UNWANTED_ML_COMMENT)
  public void changeMLCommentToSLComment(final Issue issue, final IssueResolutionAcceptor acceptor) {
    final IModificationContext modificationContext = getModificationContextFactory().createModificationContext(
      issue);
    final IXtextDocument xtextDocument = modificationContext.getXtextDocument();
    xtextDocument.readOnly(new IUnitOfWork.Void<XtextResource>() {
      @Override
      public void process(XtextResource state) throws Exception {
        resourceScope.enter(state);
        try {

          String issueString = xtextDocument.get(issue.getOffset(), issue.getLength());
          final boolean endsWithBreak = issue.getData() != null && issue.getData().length == 1 &&
              "true".equals(issue.getData()[0]);
          CommentProcessor commentProcessor = new CommentProcessor();
          JavaLikeMLCommentContainer mlContainer = new ICommentContainerInformation.JavaLikeMLCommentContainer();
          HashSLCommentContainer hashContainer = new ICommentContainerInformation.HashSLCommentContainer();
          int offsetOfNode = issue.getOffset();

          int posOnLine = offsetOfNode -
              Math.max(0, 1 + CharSequences.lastIndexOf(
                xtextDocument.get(0, xtextDocument.getLength()), "\n", offsetOfNode - 1));

          CommentText commentText = commentProcessor.separateCommentFromContainer(
            issueString, mlContainer.create(posOnLine), "\n");
          TextFlow result = commentProcessor.formatComment(
            commentText, hashContainer.create(posOnLine), new CommentFormattingOptions(
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.