Examples of IXtextDocument


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

public class TargetPlatformQuickfixProvider extends DefaultQuickfixProvider {
  @Fix(TargetPlatformValidator.DEPRECATE__STRINGS_ON_IU_VERSION)
  public void removeQuotes(final Issue issue, final IssueResolutionAcceptor acceptor) {
    final IModification _function = new IModification() {
      public void apply(final IModificationContext context) throws Exception {
        final IXtextDocument xtextDocument = context.getXtextDocument();
        Integer _offset = issue.getOffset();
        Integer _length = issue.getLength();
        int _plus = ((_offset).intValue() + (_length).intValue());
        int _minus = (_plus - 1);
        xtextDocument.replace(_minus, 1, "");
        Integer _offset_1 = issue.getOffset();
        xtextDocument.replace((_offset_1).intValue(), 1, "");
      }
    };
    acceptor.accept(issue, "Remove quotes.", "Remove quotes.", null, _function);
  }
View Full Code Here

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

 
  @Fix(TargetPlatformValidator.CHECK__VERSION_KEYWORDS)
  public void removeVersionKeywords(final Issue issue, final IssueResolutionAcceptor acceptor) {
    final IModification _function = new IModification() {
      public void apply(final IModificationContext context) throws Exception {
        final IXtextDocument xtextDocument = context.getXtextDocument();
        Integer _offset = issue.getOffset();
        Integer _length = issue.getLength();
        xtextDocument.replace((_offset).intValue(), (_length).intValue(), "");
      }
    };
    acceptor.accept(issue, "Remove deprecated keywords.", "Remove deprecated keywords.", null, _function);
  }
View Full Code Here

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

 
  @Fix(TargetPlatformValidator.CHECK__ESCAPE_CHAR_IU_ID)
  public void removeEscapeCharInIUID(final Issue issue, final IssueResolutionAcceptor acceptor) {
    final IModification _function = new IModification() {
      public void apply(final IModificationContext context) throws Exception {
        final IXtextDocument xtextDocument = context.getXtextDocument();
        Integer _offset = issue.getOffset();
        Integer _length = issue.getLength();
        final String fullId = xtextDocument.get((_offset).intValue(), (_length).intValue());
        final String replaceID = fullId.replaceAll("\\^", "");
        Integer _offset_1 = issue.getOffset();
        Integer _length_1 = issue.getLength();
        xtextDocument.replace((_offset_1).intValue(), (_length_1).intValue(), replaceID);
      }
    };
    acceptor.accept(issue, "Remove deprecated escape character.", "Remove deprecated escape character.", null, _function);
  }
View Full Code Here

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

    }
    validate(xtextEditor);
  }

  private static void validate(XtextEditor editor) {
    final IXtextDocument document = editor.getDocument();
    if (!(document instanceof XtextDocument)) {
      return;
    }
    document.readOnly(new IUnitOfWork.Void<XtextResource>() {
      @Override public void process(XtextResource resource) {
        EObject root = rootOf(resource);
        if (root == null) {
          return;
        }
View Full Code Here

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

  @Inject private Imports imports;
  @Inject private Provider<ImportHyperlink> importHyperlinkProvider;

  @Override public IHyperlink[] detectHyperlinks(ITextViewer textViewer, final IRegion region,
      final boolean canShowMultipleHyperlinks) {
    IXtextDocument document = (IXtextDocument)textViewer.getDocument();
    IHyperlink[] importHyperlinks = importHyperlinks(document, region);
    if (importHyperlinks != NO_HYPERLINKS) {
      return importHyperlinks;
    }
    return document.readOnly(new IUnitOfWork<IHyperlink[], XtextResource>() {
      @Override public IHyperlink[] exec(XtextResource resource) {
        return getHelper().createHyperlinksByOffset(resource, region.getOffset(), canShowMultipleHyperlinks);
      }
    });
  }
View Full Code Here

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

    refreshHighlighting(editor);
  }

  private void insertContent(final XtextEditor editor, final StyledTextAccess styledTextAccess) {
    final AtomicBoolean shouldInsertSemicolon = new AtomicBoolean(true);
    final IXtextDocument document = editor.getDocument();
    final List<Pair<EObject, Long>> commentsToUpdate = Lists.newLinkedList();

    document.readOnly(NULL_UNIT_OF_WORK); // wait for reconciler to finish its work.
    try {
      /*
       * Textual and semantic updates cannot be done in the same IUnitOfWork (throws an
       * IllegalStateException), so index updates (semantic) are done first and tracked in the
       * commentsToUpdate list, then a 2nd IUnitOfWork processes the comment updates (textual).
       */
      document.modify(new IUnitOfWork.Void<XtextResource>() {
        @Override public void process(XtextResource resource) {
          Protobuf root = resources.rootOf(resource);
          if (!protobufs.isProto2(root) /*|| !resource.getErrors().isEmpty()*/) {
            return;
          }
          int offset = styledTextAccess.caretOffset();
          ContentAssistContext[] context = contextFactory.create(editor.getInternalSourceViewer(), offset, resource);
          for (ContentAssistContext c : context) {
            if (nodes.isCommentOrString(c.getCurrentNode())) {
              continue;
            }
            EObject model = modelFrom(c);
            if (model instanceof FieldOption) {
              FieldOption option = (FieldOption) model;
              model = option.eContainer();
            }
            if (model instanceof Literal) {
              Literal literal = (Literal) model;
              if (shouldCalculateIndex(literal, LITERAL__INDEX)) {
                long index = literals.calculateNewIndexOf(literal);
                literal.setIndex(index);
                commentsToUpdate.add(Tuples.create(model, index));
                shouldInsertSemicolon.set(false);
              }
            }
            if (model instanceof MessageField) {
              MessageField field = (MessageField) model;
              if (shouldCalculateIndex(field)) {
                long index = indexedElements.calculateNewIndexFor(field);
                field.setIndex(index);
                commentsToUpdate.add(Tuples.create(model, index));
                shouldInsertSemicolon.set(false);
              }
            }
          }
        }
      });

      if (!commentsToUpdate.isEmpty()) {
        document.modify(new IUnitOfWork.Void<XtextResource>() {
          @Override public void process(XtextResource resource) {
            for (Pair<EObject, Long> updateInfo : commentsToUpdate) {
              updateIndexInCommentOfParent(updateInfo.getFirst(), updateInfo.getSecond(), document);
            }
          }
View Full Code Here

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

    return element(issue, EObject.class);
  }

  private <T extends EObject> T element(final Issue issue, final Class<T> type) {
    IModificationContext modificationContext = getModificationContextFactory().createModificationContext(issue);
    IXtextDocument xtextDocument = modificationContext.getXtextDocument();
    return xtextDocument.readOnly(new IUnitOfWork<T, XtextResource>() {
      @Override public T exec(XtextResource state) throws Exception {
        EObject e = state.getEObject(issue.getUriToProblem().fragment());
        return (type.isInstance(e)) ? type.cast(e) : null;
      }
    });
View Full Code Here

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

    return _xblockexpression;
  }
 
  public void caretMoved(final CaretEvent event) {
    try {
      IXtextDocument _document = this.currentTortoiseEditor.getDocument();
      final int stopAtLine = _document.getLineOfOffset(event.caretOffset);
      this.view.show(this.currentTortoiseEditor, stopAtLine);
    } catch (Throwable _e) {
      throw Exceptions.sneakyThrow(_e);
    }
  }
View Full Code Here

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

        public void run() {
          TortoiseView.this.reset();
        }
      };
      DisplayRunHelper.runSyncInDisplayThread(_function);
      IXtextDocument _document = tortoiseEditor.getDocument();
      final IUnitOfWork<Boolean, XtextResource> _function_1 = new IUnitOfWork<Boolean, XtextResource>() {
        public Boolean exec(final XtextResource it) throws Exception {
          boolean _xifexpression = false;
          boolean _and = false;
          boolean _notEquals = (!Objects.equal(it, null));
          if (!_notEquals) {
            _and = false;
          } else {
            boolean _hasError = TortoiseView.this.hasError(tortoiseEditor);
            boolean _not = (!_hasError);
            _and = _not;
          }
          if (_and) {
            boolean _xblockexpression = false;
            {
              final Tortoise tortoise = new Tortoise();
              tortoise.addListener(TortoiseView.this);
              IResourceServiceProvider _resourceServiceProvider = it.getResourceServiceProvider();
              final ITortoiseInterpreter interpreter = _resourceServiceProvider.<ITortoiseInterpreter>get(ITortoiseInterpreter.class);
              boolean _and_1 = false;
              boolean _notEquals_1 = (!Objects.equal(interpreter, null));
              if (!_notEquals_1) {
                _and_1 = false;
              } else {
                EList<EObject> _contents = it.getContents();
                boolean _isEmpty = _contents.isEmpty();
                boolean _not_1 = (!_isEmpty);
                _and_1 = _not_1;
              }
              if (_and_1) {
                try {
                  EList<EObject> _contents_1 = it.getContents();
                  EObject _get = _contents_1.get(0);
                  interpreter.run(tortoise, _get, stopAtLine);
                } catch (final Throwable _t) {
                  if (_t instanceof Exception) {
                    final Exception e = (Exception)_t;
                    IWorkbenchPartSite _site = TortoiseView.this.getSite();
                    Shell _shell = _site.getShell();
                    StringConcatenation _builder = new StringConcatenation();
                    _builder.append("Error during execution:");
                    _builder.newLine();
                    _builder.append("  ");
                    String _message = e.getMessage();
                    _builder.append(_message, "  ");
                    _builder.newLineIfNotEmpty();
                    _builder.append("See log for details");
                    MessageDialog.openError(_shell, "Error during Execution", _builder.toString());
                    TortoiseView.LOGGER.error("Error executing TortoiseScript", e);
                  } else {
                    throw Exceptions.sneakyThrow(_t);
                  }
                }
              }
              _xblockexpression = tortoise.removeListener(TortoiseView.this);
            }
            _xifexpression = _xblockexpression;
          }
          return Boolean.valueOf(_xifexpression);
        }
      };
      _xblockexpression = _document.<Boolean>readOnly(_function_1);
    }
    return _xblockexpression;
  }
View Full Code Here

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

      if ((_editorInput instanceof IFileEditorInput)) {
        IEditorInput _editorInput_1 = xbaseEditor.getEditorInput();
        IFile _file = ((IFileEditorInput) _editorInput_1).getFile();
        IProject _project = _file.getProject();
        final String project = _project.getName();
        IXtextDocument _document = xbaseEditor.getDocument();
        final IUnitOfWork<LaunchConfigurationInfo, XtextResource> _function = new IUnitOfWork<LaunchConfigurationInfo, XtextResource>() {
          public LaunchConfigurationInfo exec(final XtextResource it) throws Exception {
            LaunchConfigurationInfo _xblockexpression = null;
            {
              EList<EObject> _contents = it.getContents();
              Iterable<JvmDeclaredType> _filter = Iterables.<JvmDeclaredType>filter(_contents, JvmDeclaredType.class);
              final JvmDeclaredType file = IterableExtensions.<JvmDeclaredType>head(_filter);
              String _identifier = null;
              if (file!=null) {
                _identifier=file.getIdentifier();
              }
              String _findTask = BuildDSLLaunchShortcut.this.findTask(it, offset);
              _xblockexpression = new LaunchConfigurationInfo(project, _identifier, _findTask);
            }
            return _xblockexpression;
          }
        };
        final LaunchConfigurationInfo info = _document.<LaunchConfigurationInfo>readOnly(_function);
        this.launch(mode, info);
        return;
      }
    }
    MessageDialog.openError(null, "Wrong editor kind.", "");
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.