Package org.eclipse.text.edits

Examples of org.eclipse.text.edits.ReplaceEdit


      FindReplaceDocumentAdapter find = new FindReplaceDocumentAdapter(doc);
      IRegion resultStart = find.find(0, "location\\s*=\\s*\"", true, true, false, true);
      IRegion resultStop = find.find(resultStart.getOffset() + resultStart.getLength(), "\"", true, true, false, false);
 
      String linkTarget = WGADesignStructureHelper.computeDirLinkTarget(info.getFile().getParent(), computeNewLinkTarget(info));
      TextEdit edit = new ReplaceEdit(resultStart.getLength() + resultStart.getOffset(), resultStop.getOffset() - (resultStart.getLength() + resultStart.getOffset()), linkTarget);
     
      change.setEdit(edit);
      return change;
      }else if (info.getArguments() instanceof DeleteArguments) {
        // check if resource to delete will still exists after parent deletion is performed - otherwise we can skip any change here
View Full Code Here


      if(errors.isEmpty()) {
       
     
      ByteArrayOutputStream configContent = new ByteArrayOutputStream();   
      WGAConfiguration.write(config, configContent);
      change.setEdit(new ReplaceEdit(0, change.getCurrentDocument((new NullProgressMonitor())).getLength(), configContent.toString()))
      return change;
      } else {
        for(ValidationError current : errors){
          WGADesignerPlugin.getDefault().logError(current.getMessage());
        }
View Full Code Here

      edit = new MultiTextEdit(this.textRegionStart, this.textRegionEnd - this.textRegionStart + 1);
    }
    for (int i= 0, max = this.editsIndex; i < max; i++) {
      OptimizedReplaceEdit currentEdit = edits[i];
      if (isValidEdit(currentEdit)) {
        edit.addChild(new ReplaceEdit(currentEdit.offset, currentEdit.length, currentEdit.replacement));
      }
    }
    this.edits = null;
    return edit;
  }
View Full Code Here

 
     
  private static TextEdit shifEdit(TextEdit oldEdit, int diff) {
    TextEdit newEdit;
    if (oldEdit instanceof ReplaceEdit) {
      ReplaceEdit edit= (ReplaceEdit) oldEdit;
      newEdit= new ReplaceEdit(edit.getOffset() - diff, edit.getLength(), edit.getText());
    } else if (oldEdit instanceof InsertEdit) {
      InsertEdit edit= (InsertEdit) oldEdit;
      newEdit= new InsertEdit(edit.getOffset() - diff,  edit.getText());
    } else if (oldEdit instanceof DeleteEdit) {
      DeleteEdit edit= (DeleteEdit) oldEdit;
      newEdit= new DeleteEdit(edit.getOffset() - diff,  edit.getLength());
    } else if (oldEdit instanceof MultiTextEdit) {
      newEdit= new MultiTextEdit();     
    } else {
      return null; // not supported
    }
View Full Code Here

        IRegion region= tracker.getLineInformation(i);
        int offset= region.getOffset();
        String line= source.substring(offset, offset + region.getLength());
        int length= indexOfIndent(line, indentUnitsToRemove, tabWidth, indentWidth);
        if (length >= 0) {
          result.add(new ReplaceEdit(offset, length, newIndentString));
        } else {
          length= measureIndentUnits(line, tabWidth, indentWidth);
          result.add(new ReplaceEdit(offset, length, "")); //$NON-NLS-1$
        }
      }
    } catch (BadLocationException cannotHappen) {
      // can not happen
    }
View Full Code Here

        for (int i = 0, max = positions.length; i < max; i++) {
          int currentPosition = positions[i];
          if (currentPosition > originalSourceLength) {
            currentPosition = originalSourceLength;
          }
          ReplaceEdit currentEdit = (ReplaceEdit) edits[editsIndex];
          while (currentEdit.getOffset() <= currentPosition) {
            delta += currentEdit.getText().length() - currentEdit.getLength();
            editsIndex++;
            if (editsIndex < textEditSize) {
              currentEdit = (ReplaceEdit) edits[editsIndex];
            } else {
              break;
View Full Code Here

                    /* match end boundary */"(" + grammarSeparator + "|" + Pattern.quote(".*") + "|" + Pattern.quote("\\") + "|$)");

                    /* find all matches to replace and add them to the root edit */
                    Matcher matcher = pattern.matcher(bndFileText);
                    while (matcher.find()) {
                        rootEdit.addChild(new ReplaceEdit(matcher.start(2), matcher.group(2).length(), newName));
                    }

                    pattern = Pattern.compile(
                    /* match start boundary */"(^|" + grammarSeparator + ")" +
                    /* match bundle activator */"(Bundle-Activator\\s*:\\s*)" +
                    /* match itself / package name */"(" + Pattern.quote(oldName) + ")" +
                    /* match class name */"(\\.[^\\.]+)" +
                    /* match end boundary */"(" + grammarSeparator + "|" + Pattern.quote("\\") + "|$)");

                    /* find all matches to replace and add them to the root edit */
                    matcher = pattern.matcher(bndFileText);
                    while (matcher.find()) {
                        rootEdit.addChild(new ReplaceEdit(matcher.start(3), matcher.group(3).length(), newName));
                    }
                }

                /*
                 * only store the changes when no changes were stored before for this file and when there are actually
View Full Code Here

          }
          change= new TextFileChange(file.getName(), file);
          change.setEdit(new MultiTextEdit());
          changes.put(file, change);
        }
        ReplaceEdit edit= new ReplaceEdit(matchAccess.getMatchOffset(), matchAccess.getMatchLength(), newName);
        change.addEdit(edit);
        change.addTextEditGroup(new TextEditGroup("Update type reference", edit)); //$NON-NLS-1$
        return true;
      }
    };
View Full Code Here

        return find(s);
      }

      @Override
      protected ReplaceEdit createReplaceEdit(ASTNode astNode) {
        return new ReplaceEdit(astNode.sourceStart(), getCurrentElementName().length(), getNewElementName());
      }
    };
  }
View Full Code Here

                            try {
                              addTextEdit(
                                changeManager.get(module),
                                getProcessorName(),
                                new ReplaceEdit(offset, getCurrentElementName().length(), getNewElementName())
                              );
                            } catch (MalformedTreeException e) {
                              // conflicting update -> omit text match
                            }
                          }
View Full Code Here

TOP

Related Classes of org.eclipse.text.edits.ReplaceEdit

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.