Package org.eclipse.text.edits

Examples of org.eclipse.text.edits.ReplaceEdit


                    resultingStatus.addError(Messages.format(
                            SearchMessages.ReplaceRefactoring_error_match_content_changed, file.getName()));
                    continue;
                }

                ReplaceEdit replaceEdit = new ReplaceEdit(offset, length, replacementString);
                change.addEdit(replaceEdit);
                TextEditChangeGroup textEditChangeGroup = new TextEditChangeGroup(change, new TextEditGroup(
                        SearchMessages.ReplaceRefactoring_group_label_match_replace, replaceEdit));
                change.addTextEditChangeGroup(textEditChangeGroup);
                matchGroups.add(new MatchGroup(textEditChangeGroup, match));
View Full Code Here


            if (attributeName.equals(attributeNameStart + argumentName)
                || attributeName.equals(attributeNameStart + argumentName + optionalAttributeNameEnd)) {
              List<IType> types = BeansEditorUtils.getClassNamesOfBean(file, node);
              if (element.getParent() != null && element.getParent() instanceof IMethod && types.contains(((IMethod) element.getParent()).getDeclaringType())) {
                int offset = attribute.getNameRegionStartOffset() + attributeNameStart.length();
                result.add(new ReplaceEdit(offset, argumentName.length(), newName));
              }
            }
          }
        }
      }
View Full Code Here

              List<IType> types = BeansEditorUtils.getClassNamesOfBean(file, node);
              if (types.contains(((IMethod) element).getDeclaringType())) {
                AttrImpl attr = (AttrImpl) child.getAttributes().getNamedItem("name");
                int offset = attr.getValueRegionStartOffset() + 1;
                if (offset >= 0) {
                  result.add(new ReplaceEdit(offset, propertyName.length(), newName));
                }
              }
            }
          }
        }
       
        // p-namespace references to the properties that belong to the changed method
        if (node.hasAttributes()) {
          String attributeNameStart = "p:";
          String optionalAttributeNameEnd = "-ref";
         
          NamedNodeMap attributes = node.getAttributes();
          int attributeCount = attributes.getLength();
         
          for (int i = 0; i < attributeCount; i++) {
            AttrImpl attribute = (AttrImpl) attributes.item(i);
            String attributeName = attribute.getNodeName();
            if (attributeName != null && attributeName.startsWith(attributeNameStart)) {
              if (attributeName.equals(attributeNameStart + methodName)
                  || attributeName.equals(attributeNameStart + methodName + optionalAttributeNameEnd)) {
                List<IType> types = BeansEditorUtils.getClassNamesOfBean(file, node);
                if (types.contains(((IMethod) element).getDeclaringType())) {
                  int offset = attribute.getNameRegionStartOffset() + attributeNameStart.length();
                  result.add(new ReplaceEdit(offset, methodName.length(), newName));
                }
              }
            }
          }
        }
View Full Code Here

        List<IType> types = BeansEditorUtils.getClassNamesOfBean(file, node);
        if (types.contains(((IMethod) element).getDeclaringType())) {
          AttrImpl attr = (AttrImpl) node.getAttributes().getNamedItem(attrName);
          int offset = attr.getValueRegionStartOffset() + 1;
          if (offset >= 0) {
            return new ReplaceEdit(offset, attrMethodName.length(), newName);
          }
        }
      }
    }
    return null;
View Full Code Here

    String id = BeansEditorUtils.getAttribute(node, "id");
    if (oldBeanId.equals(id)) {
      AttrImpl attr = (AttrImpl) node.getAttributes().getNamedItem("id");
      int offset = attr.getValueRegionStartOffset() + 1;
      if (offset >= 0) {
        return new ReplaceEdit(offset, oldBeanId.length(), newBeanId);
      }
    }
    return null;
  }
View Full Code Here

            && attributeName.endsWith(attributeNameEnd)) {
        String beanRef = attribute.getNodeValue();
        if (beanRef != null && beanRef.equals(oldBeanId)) {
          int offset = ((AttrImpl) attribute).getValueRegionStartOffset() + 1;
          if (offset >= 0) {
            multiEdit.addChild(new ReplaceEdit(offset, beanRef.length(), newBeanId));
          }
        }
      }
    }
  }
View Full Code Here

      String beanRef = BeansEditorUtils.getAttribute(node, attributeName);
      if (beanRef != null && beanRef.equals(oldBeanId)) {
        AttrImpl attr = (AttrImpl) node.getAttributes().getNamedItem(attributeName);
        int offset = attr.getValueRegionStartOffset() + 1;
        if (offset >= 0) {
          multiEdit.addChild(new ReplaceEdit(offset, beanRef.length(), newBeanId));
        }
      }
    }
  }
View Full Code Here

        String attribute = attributes.item(i).getNodeValue();
        if (oldName.equals(attribute) || isGoodMatch(attribute, oldName, element instanceof IPackageFragment)) {
          AttrImpl attr = (AttrImpl) attributes.getNamedItem(attributes.item(i).getNodeName());
          int offset = attr.getValueRegionStartOffset() + 1;
          if (offset >= 0) {
            multiEdit.addChild(new ReplaceEdit(offset, oldName.length(), newName));
          }
        }
      }
    }
   
    // creating replace edits for value strings
    if (node instanceof TextImpl) {
      String value = node.getNodeValue();
      if (value != null) {
        if (oldName.equals(value) || isGoodMatch(value, oldName, element instanceof IPackageFragment)) {
          int offset = ((TextImpl)node).getStartOffset();
          if (offset >= 0) {
            multiEdit.addChild(new ReplaceEdit(offset, oldName.length(), newName));
          }
        }
      }
    }
  }
View Full Code Here

          toBeRemoved.add(position);
        }
      }
      refactoredPositions.removeAll(toBeRemoved);

      multiEdit.addChild(new ReplaceEdit(offset + changeCount * diff, oldLength, newName));
    }

    if (multiEdit.getChildrenSize() > 0) {
      TextFileChange change = new TextFileChange("", file);
      change.setEdit(multiEdit);
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(), RefactoringUtil.getNewFullyQualifiedName(
              renamedElement, getArguments().getNewName() ) );
          change.addEdit( edit );
          change.addTextEditGroup( new TextEditGroup( "Update type reference", edit ) ); //$NON-NLS-1$
          return true;
        }
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.