Package org.eclipse.text.edits

Examples of org.eclipse.text.edits.TextEditGroup


      }catch (MalformedTreeException e) {
        Logger.logException("MalformedTreeException while adding edit " + //$NON-NLS-1$
            edit + " to existing change " + change, e); //$NON-NLS-1$
      }
     
      TextEditGroup group = new TextEditGroup(description, edit);
      existingChange.addTextEditGroup(group);
    } else {
      change = new JSPRenameChange(searchDoc.getFile(), doc, edit, searchDoc.getFile().getName());
      TextEditGroup group = new TextEditGroup(description, edit);
      change.addTextEditGroup(group);
    }
   
    return change;
  }
View Full Code Here


   */
  public final ITrackedNodePosition track(ASTNode node) {
    if (node == null) {
      throw new IllegalArgumentException();
    }
    TextEditGroup group= this.eventStore.getTrackedNodeData(node);
    if (group == null) {
      group= new TextEditGroup("internal"); //$NON-NLS-1$
      this.eventStore.setTrackedNodeData(node, group);
    }
    return new TrackedNodePosition(group, node);
  }
View Full Code Here

  private int rewriteRequiredNode(ASTNode parent, StructuralPropertyDescriptor property) {
    RewriteEvent event= getEvent(parent, property);
    if (event != null && event.getChangeKind() == RewriteEvent.REPLACED) {
      ASTNode node= (ASTNode) event.getOriginalValue();
      TextEditGroup editGroup= getEditGroup(event);
      SourceRange range= getExtendedRange(node);
      int offset= range.getStartPosition();
      int length= range.getLength();
      doTextRemoveAndVisit(offset, length, node, editGroup);
      doTextInsert(offset, (ASTNode) event.getNewValue(), getIndent(offset), true, editGroup);
View Full Code Here

    RewriteEvent event= getEvent(parent, property);
    if (event != null) {
      switch (event.getChangeKind()) {
        case RewriteEvent.INSERTED: {
          ASTNode node= (ASTNode) event.getNewValue();
          TextEditGroup editGroup= getEditGroup(event);
          int indent= getIndent(offset);
          doTextInsert(offset, prefix.getPrefix(indent), editGroup);
          doTextInsert(offset, node, indent, true, editGroup);
          return offset;
        }
        case RewriteEvent.REMOVED: {
          ASTNode node= (ASTNode) event.getOriginalValue();
          TextEditGroup editGroup= getEditGroup(event);
         
          // if there is a prefix, remove the prefix as well
          int nodeEnd;
          int len;
          if (offset == 0) {
            SourceRange range= getExtendedRange(node);
            offset= range.getStartPosition();
            len= range.getLength();
            nodeEnd= offset+len;
          } else {
            nodeEnd= getExtendedEnd(node);
            len= nodeEnd-offset;
          }
          doTextRemoveAndVisit(offset, len, node, editGroup);
          return nodeEnd;
        }
        case RewriteEvent.REPLACED: {
          ASTNode node= (ASTNode) event.getOriginalValue();
          TextEditGroup editGroup= getEditGroup(event);
          SourceRange range= getExtendedRange(node);
          int nodeOffset= range.getStartPosition();
          int nodeLen= range.getLength();
          doTextRemoveAndVisit(nodeOffset, nodeLen, node, editGroup);
          doTextInsert(nodeOffset, (ASTNode) event.getNewValue(), getIndent(offset), true, editGroup);
View Full Code Here

    RewriteEvent event= getEvent(parent, property);
    if (event != null) {
      switch (event.getChangeKind()) {
        case RewriteEvent.INSERTED: {
          ASTNode node= (ASTNode) event.getNewValue();
          TextEditGroup editGroup= getEditGroup(event);

          String[] strings= context.getPrefixAndSuffix(indent, node, this.eventStore);

          doTextInsert(offset, strings[0], editGroup);
          doTextInsert(offset, node, indent, true, editGroup);
          doTextInsert(offset, strings[1], editGroup);
          return offset;
        }
        case RewriteEvent.REMOVED: {
          ASTNode node= (ASTNode) event.getOriginalValue();
          if (endPos == -1) {
            endPos= getExtendedEnd(node);
          }

          TextEditGroup editGroup= getEditGroup(event);
          // if there is a prefix, remove the prefix as well
          int len= endPos - offset;
          doTextRemoveAndVisit(offset, len, node, editGroup);
          return endPos;
        }
        case RewriteEvent.REPLACED: {
          ASTNode node= (ASTNode) event.getOriginalValue();
          boolean insertNewLine = false;
          if (endPos == -1) {
            int previousEnd = node.getStartPosition() + node.getLength();
            endPos= getExtendedEnd(node);
            if (endPos != previousEnd) {
              // check if the end is a comment
              int token = TokenScanner.END_OF_FILE;
              try {
                token = getScanner().readNext(previousEnd, false);
              } catch(CoreException e) {
                // ignore
              }
              if (token == TerminalTokens.TokenNameCOMMENT_LINE) {
                insertNewLine = true;
              }
            }
          }
          TextEditGroup editGroup= getEditGroup(event);
          int nodeLen= endPos - offset;

          ASTNode replacingNode= (ASTNode) event.getNewValue();
          String[] strings= context.getPrefixAndSuffix(indent, replacingNode, this.eventStore);
          doTextRemoveAndVisit(offset, nodeLen, node, editGroup);
View Full Code Here

    RewriteEvent event= getEvent(parent, property);
    if (event != null) {
      switch (event.getChangeKind()) {
        case RewriteEvent.INSERTED: {
          ASTNode node= (ASTNode) event.getNewValue();
          TextEditGroup editGroup= getEditGroup(event);
          doTextInsert(startPos, node, getIndent(startPos), true, editGroup);
          doTextInsert(startPos, ".", editGroup); //$NON-NLS-1$
          return startPos;
        }
        case RewriteEvent.REMOVED: {
          try {
            ASTNode node= (ASTNode) event.getOriginalValue();
            TextEditGroup editGroup= getEditGroup(event);
            int dotEnd= getScanner().getTokenEndOffset(TerminalTokens.TokenNameDOT, node.getStartPosition() + node.getLength());
            doTextRemoveAndVisit(startPos, dotEnd - startPos, node, editGroup);
            return dotEnd;
          } catch (CoreException e) {
            handleException(e);
          }
          break;
        }
        case RewriteEvent.REPLACED: {
          ASTNode node= (ASTNode) event.getOriginalValue();
          TextEditGroup editGroup= getEditGroup(event);
          SourceRange range= getExtendedRange(node);
          int offset= range.getStartPosition();
          int length= range.getLength();

          doTextRemoveAndVisit(offset, length, node, editGroup);
View Full Code Here

    RewriteEvent event= getEvent(parent, MethodDeclaration.BODY_PROPERTY);
    if (event != null) {
      switch (event.getChangeKind()) {
        case RewriteEvent.INSERTED: {
          int endPos= parent.getStartPosition() + parent.getLength();
          TextEditGroup editGroup= getEditGroup(event);
          ASTNode body= (ASTNode) event.getNewValue();
          doTextRemove(startPos, endPos - startPos, editGroup);
          int indent= getIndent(parent.getStartPosition());
          String prefix= this.formatter.METHOD_BODY.getPrefix(indent);
          doTextInsert(startPos, prefix, editGroup);
          doTextInsert(startPos, body, indent, true, editGroup);
          return;
        }
        case RewriteEvent.REMOVED: {
          TextEditGroup editGroup= getEditGroup(event);
          ASTNode body= (ASTNode) event.getOriginalValue();
          int endPos= parent.getStartPosition() + parent.getLength();
          doTextRemoveAndVisit(startPos, endPos - startPos, body, editGroup);
          doTextInsert(startPos, ";", editGroup); //$NON-NLS-1$
          return;
        }
        case RewriteEvent.REPLACED: {
          TextEditGroup editGroup= getEditGroup(event);
          ASTNode body= (ASTNode) event.getOriginalValue();
          doTextRemoveAndVisit(body.getStartPosition(), body.getLength(), body, editGroup);
          doTextInsert(body.getStartPosition(), (ASTNode) event.getNewValue(), getIndent(body.getStartPosition()), true, editGroup);
          return;
        }
View Full Code Here

    }
    int oldDim= ((Integer) event.getOriginalValue()).intValue();
    int newDim= ((Integer) event.getNewValue()).intValue();

    if (oldDim != newDim) {
      TextEditGroup editGroup= getEditGroup(event);
      rewriteExtraDimensions(oldDim, newDim, pos, editGroup);
    }
    return oldDim;
  }
View Full Code Here

      return;
    }
    try {
      int oldModifiers= ((Integer) event.getOriginalValue()).intValue();
      int newModifiers= ((Integer) event.getNewValue()).intValue();
      TextEditGroup editGroup= getEditGroup(event);

      TokenScanner scanner= getScanner();

      int tok= scanner.readNext(offset, false);
      int startPos= scanner.getCurrentStartOffset();
View Full Code Here

  private void rewriteOperation(ASTNode parent, StructuralPropertyDescriptor property, int posBeforeOperation) {
    RewriteEvent event= getEvent(parent, property);
    if (event != null && event.getChangeKind() != RewriteEvent.UNCHANGED) {
      try {
        String newOperation= event.getNewValue().toString();
        TextEditGroup editGroup= getEditGroup(event);
        getScanner().readNext(posBeforeOperation, true);
        doTextReplace(getScanner().getCurrentStartOffset(), getScanner().getCurrentLength(), newOperation, editGroup);
      } catch (CoreException e) {
        handleException(e);
      }
View Full Code Here

TOP

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

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.