Examples of ReplaceEdit


Examples of org.eclipse.text.edits.ReplaceEdit

        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

Examples of org.eclipse.text.edits.ReplaceEdit

                    /* 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

Examples of org.eclipse.text.edits.ReplaceEdit

          }
          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

Examples of org.eclipse.text.edits.ReplaceEdit

        return find(s);
      }

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

Examples of org.eclipse.text.edits.ReplaceEdit

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

Examples of org.eclipse.text.edits.ReplaceEdit

        return find(s);
      }

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

Examples of org.eclipse.text.edits.ReplaceEdit

                    try {
                      addTextEdit(
                        changeManager.get(module),
                        getProcessorName(),
                        new ReplaceEdit(offset, method.getElementName().length(), getNewElementName())
                      );
                    } catch (MalformedTreeException e) {
                      // conflicting update -> omit text match
                    }
                  }
                } else {
                  IModelElement sourceElement = PDTModelUtils.getSourceElement(module, expression.getCallName().sourceStart(), expression.getCallName().matchLength());
                  if (sourceElement != null && sourceElement.getElementType() == IModelElement.METHOD) {
                    IType declaringType = ((IMethod) sourceElement).getDeclaringType();
                    if (declaringType != null && new PHPType(declaringType).isInstanceOf(method.getDeclaringType())) {
                      try {
                        addTextEdit(
                          changeManager.get(module),
                          getProcessorName(),
                          new ReplaceEdit(expression.getCallName().sourceStart(), method.getElementName().length(), getNewElementName())
                        );
                      } catch (MalformedTreeException e) {
                        // conflicting update -> omit text match
                      }
                    }
View Full Code Here

Examples of org.eclipse.text.edits.ReplaceEdit

        return find(s);
      }

      @Override
      protected ReplaceEdit createReplaceEdit(ASTNode astNode) {
        return new ReplaceEdit(astNode.sourceStart(), getCurrentElementName().length() - 1, getNewElementName().replace("$", "")); //$NON-NLS-1$ //$NON-NLS-2$
      }
    };
  }
View Full Code Here

Examples of org.eclipse.text.edits.ReplaceEdit

                  moduleDeclaration.traverse(referenceFinder);
                } catch (Exception e) {
                  throw new CoreException(new Status(IStatus.ERROR, PEXUIPlugin.PLUGIN_ID, e.getMessage(), e));
                }

                ReplaceEdit replaceEdit = referenceFinder.getReplaceEdit();
                if (replaceEdit != null) {
                  try {
                    addTextEdit(changeManager.get(module), getProcessorName(), replaceEdit);
                  } catch (MalformedTreeException e) {
                    // conflicting update -> omit text match
View Full Code Here

Examples of org.eclipse.text.edits.ReplaceEdit

    ISourceRange sourceRange = null;
    if (modelElement instanceof IMember) {
      sourceRange = ((IMember) modelElement).getNameRange();
    }
    if (sourceRange != null) {
      addTextEdit(changeManager.get(sourceModule), getProcessorName(), new ReplaceEdit(sourceRange.getOffset(), modelElement.getElementName().length(), getNewElementName()));
    }

    return new RefactoringStatus();
  }
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.