Examples of MultiTextEdit


Examples of org.eclipse.text.edits.MultiTextEdit

        document.set(text);

        List<Change> changes = new ArrayList<Change>();

        int offset = 0;   // TODO in forms use "\" + varName + "\"
        MultiTextEdit multiEdit = new MultiTextEdit();
        int len = variableName.length();
        while (offset > -1) {
            offset = document.search(offset, variableName, true, true, true);
            if (offset == -1) {
                break;
            }
            ReplaceEdit replaceEdit = new ReplaceEdit(offset, len, replacement);
            multiEdit.addChild(replaceEdit);
            offset += len; // to avoid overlapping
        }

        if (multiEdit.getChildrenSize() > 0) {
            TextFileChange fileChange = new TextFileChange(file.getName(), file) {
                @Override
                public Object getAdapter(Class adapter) {
                    if (adapter == TextEditChangeNode.class) {
                        return new GPDChangeNode(this, null, label);
View Full Code Here

Examples of org.eclipse.text.edits.MultiTextEdit

    public List<Change> getChanges() throws Exception {
        List<Change> changes = new ArrayList<Change>();
        document.set(delegable.getDelegationConfiguration());

        int offset = 0;
        MultiTextEdit multiEdit = new MultiTextEdit();
        int len = variableName.length();
        while (offset > -1) {
            if (offset >= document.getLength()) {
                break;
            }
            offset = document.search(offset, variableName, true, true, true);
            if (offset == -1) {
                break;
            }
            ReplaceEdit replaceEdit = new ReplaceEdit(offset, len, replacement);
            multiEdit.addChild(replaceEdit);
            offset += len; // to avoid overlapping
        }
       
        if (multiEdit.getChildrenSize() > 0) {
            DocumentChange change = new DocumentChangeExt(name, document);
            change.setEdit(multiEdit);
            changes.add(change);
        }
        return changes;
View Full Code Here

Examples of org.eclipse.text.edits.MultiTextEdit

          final TextChange textChange = getTextChange(file);
          if (textChange != null) {
            return false;
          }
          change = new TextFileChange(file.getName(), file);
          change.setEdit(new MultiTextEdit());
          changes.put(file, change);
        }
        final ReplaceEdit edit = new ReplaceEdit(matchAccess.getMatchOffset(), matchAccess.getMatchLength(), replacement);
        change.addEdit(edit);
        change.addTextEditGroup(new TextEditGroup("Update " + QWickieActivator.WICKET_ID, edit));
View Full Code Here

Examples of org.eclipse.text.edits.MultiTextEdit

          final TextChange textChange = getTextChange(file);
          if (textChange != null) {
            return false;
          }
          change = new TextFileChange(file.getName(), file);
          change.setEdit(new MultiTextEdit());
          changes.put(file, change);
        }
        final ReplaceEdit edit = new ReplaceEdit(matchAccess.getMatchOffset(), matchAccess.getMatchLength(), replacement);
        change.addEdit(edit);
        change.addTextEditGroup(new TextEditGroup("Update " + QWickieActivator.WICKET_ID, edit));
View Full Code Here

Examples of org.eclipse.text.edits.MultiTextEdit

            // create a change object for the file that contains the property
            // which the user has selected to rename
            IFile file = currentProject.getFile(pack).getRealFile();
            TextFileChange filechange = new TextFileChange( file.getName(), file );
            // a file change contains a tree of edits, first add the root of them
            MultiTextEdit fileChangeRootEdit = new MultiTextEdit();
            filechange.setEdit( fileChangeRootEdit );
            compositeChange.add(filechange);
           
            for (Pair pair : targets.get(pack))
            {
                // edit object for the text replacement in the file, this is the only child
                ReplaceEdit rEdit = new ReplaceEdit(
                        (int) pair.first,
                        (int) pair.second,
                        "");
                InsertEdit iEdit = new InsertEdit(
                        (int) pair.first,
                        newName);
                fileChangeRootEdit.addChild(rEdit);
                fileChangeRootEdit.addChild(iEdit);
            }
        }
    }
View Full Code Here

Examples of org.eclipse.text.edits.MultiTextEdit

          }
          else if (lastRegion.getType() == DOMRegionContext.XML_EMPTY_TAG_CLOSE) {
            index = index - 2;
            lastRegion = startStructuredDocumentRegion.getRegionAtCharacterOffset(index - 1);
          }
          MultiTextEdit multiTextEdit = new MultiTextEdit();
          try {
            for (int i = insertAttrs.size() - 1; i >= 0; i--) {
              CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) insertAttrs.get(i);
              String requiredAttributeName = attrDecl.getAttrName();
              String defaultValue = attrDecl.getDefaultValue();
              if (defaultValue == null)
                defaultValue = ""; //$NON-NLS-1$
              String nameAndDefaultValue = " "; //$NON-NLS-1$
              if (i == 0 && lastRegion.getLength() > lastRegion.getTextLength())
                nameAndDefaultValue = ""; //$NON-NLS-1$
              nameAndDefaultValue += requiredAttributeName + "=\"" + defaultValue + "\""; //$NON-NLS-1$ //$NON-NLS-2$
              multiTextEdit.addChild(new InsertEdit(index, nameAndDefaultValue));
              // BUG3381: MultiTextEdit applies all child
              // TextEdit's basing on offsets
              // in the document before the first TextEdit, not
              // after each
              // child TextEdit. Therefore, do not need to
              // advance the index.
              // index += nameAndDefaultValue.length();
            }
            multiTextEdit.apply(newNode.getStructuredDocument());
          }
          catch (BadLocationException e) {
            // log or now, unless we find reason not to
            Logger.log(Logger.INFO, e.getMessage());
          }
View Full Code Here

Examples of org.eclipse.text.edits.MultiTextEdit

   * @return
   */
  private TextEdit createMultiTextEdit(TextEdit[] edits) {

    if (edits.length == 0)
      return new MultiTextEdit();

    /* should not specify a limited region because other edits outside
     * these original edits might be added later.
     */
    MultiTextEdit multiEdit = new MultiTextEdit();
    for (int i = 0; i < edits.length; i++) {
      addToMultiEdit(edits[i], multiEdit);
    }
    return multiEdit;
  }
View Full Code Here

Examples of org.eclipse.text.edits.MultiTextEdit

    int javaOffset = textEdit.getOffset();
    int jspOffset = getTranslation().getJspOffset(textEdit.getOffset());
    int length = textEdit.getLength();

    if (textEdit instanceof MultiTextEdit) {
      translatedTextEdit = new MultiTextEdit();
      TextEdit[] children = ((MultiTextEdit) textEdit).getChildren();
      for (int i = 0; i < children.length; i++) {
        TextEdit translatedChildTextEdit = translateTextEdit(children[i]);
        if (translatedChildTextEdit != null)
          ((MultiTextEdit) translatedTextEdit).addChild(translatedChildTextEdit);
View Full Code Here

Examples of org.eclipse.text.edits.MultiTextEdit

          }
          else if (lastRegion.getType() == DOMRegionContext.XML_EMPTY_TAG_CLOSE) {
            index = index - 2;
            lastRegion = startStructuredDocumentRegion.getRegionAtCharacterOffset(index - 1);
          }
          MultiTextEdit multiTextEdit = new MultiTextEdit();
          try {
            for (int i = insertAttrs.size() - 1; i >= 0; i--) {
              CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) insertAttrs.get(i);
              String requiredAttributeName = attrDecl.getAttrName();
              String defaultValue = attrDecl.getDefaultValue();
              if (defaultValue == null)
                defaultValue = ""; //$NON-NLS-1$
              String nameAndDefaultValue = " "; //$NON-NLS-1$
              if (i == 0 && lastRegion.getLength() > lastRegion.getTextLength())
                nameAndDefaultValue = ""; //$NON-NLS-1$
              nameAndDefaultValue += requiredAttributeName + "=\"" + defaultValue + "\""; //$NON-NLS-1$ //$NON-NLS-2$
              multiTextEdit.addChild(new InsertEdit(index, nameAndDefaultValue));
              // BUG3381: MultiTextEdit applies all child
              // TextEdit's basing on offsets
              // in the document before the first TextEdit, not
              // after each
              // child TextEdit. Therefore, do not need to
              // advance the index.
              // index += nameAndDefaultValue.length();
            }
            multiTextEdit.apply(newNode.getStructuredDocument());
          }
          catch (BadLocationException e) {
            // log or now, unless we find reason not to
            Logger.log(Logger.INFO, e.getMessage());
          }
View Full Code Here

Examples of org.eclipse.text.edits.MultiTextEdit

   * @param edit
   * @param description
   */
  public JSPRenameChange(IFile jspFile, IDocument jspDoc, TextEdit edit, String description) {
    super(JSPUIMessages.BasicRefactorSearchRequestor_6, jspDoc);
    MultiTextEdit parentEdit = new MultiTextEdit();
    parentEdit.addChild(edit);
    super.setEdit(parentEdit);
    this.fJSPFile = jspFile;
    this.fDescription = description;
  }
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.