Package org.eclipse.text.edits

Examples of org.eclipse.text.edits.TextEditGroup


  /* (non-Javadoc)
   * @see org.eclipse.jdt.core.dom.ASTVisitor#postVisit(ASTNode)
   */
  public void postVisit(ASTNode node) {
    TextEditGroup editGroup= this.eventStore.getTrackedNodeData(node);
    if (editGroup != null) {
      this.currentEdit= this.currentEdit.getParent();
    }
    // remove copy source edits
    doCopySourcePostVisit(node, this.sourceCopyEndNodes);
View Full Code Here


    // copies, then range marker

    CopySourceInfo[] infos= this.eventStore.getNodeCopySources(node);
    doCopySourcePreVisit(infos, this.sourceCopyEndNodes);

    TextEditGroup editGroup= this.eventStore.getTrackedNodeData(node);
    if (editGroup != null) {
      SourceRange range= getExtendedRange(node);
      int offset= range.getStartPosition();
      int length= range.getLength();
      TextEdit edit= new RangeMarker(offset, length);
View Full Code Here

    ASTNode newReturnType= (ASTNode) getNewValue(node, property);
    if (isConstructorChange || !returnTypeExists && newReturnType != originalReturnType) {
      // use the start offset of the method name to insert
      ASTNode originalMethodName= (ASTNode) getOriginalValue(node, MethodDeclaration.NAME_PROPERTY);
      int nextStart= originalMethodName.getStartPosition(); // see bug 84049: can't use extended offset
      TextEditGroup editGroup= getEditGroup(node, property);
      if (isConstructor || !returnTypeExists) { // insert
        doTextInsert(nextStart, newReturnType, getIndent(nextStart), true, editGroup);
        doTextInsert(nextStart, " ", editGroup); //$NON-NLS-1$
      } else { // remove up to the method name
        int offset= getExtendedOffset(originalReturnType);
View Full Code Here

    if (qualEvent != null) {
      newQual = (ASTNode) qualEvent.getNewValue();
      oldQual = (ASTNode) qualEvent.getOriginalValue();
    }

    TextEditGroup editGroup= getEditGroup(event);
    if (event != null && event.getChangeKind() != RewriteEvent.UNCHANGED) {
      int changeKind= event.getChangeKind();
      if (changeKind == RewriteEvent.INSERTED) {
         doTextInsert(offset, (ASTNode) event.getNewValue(), 0, false, editGroup);
        doTextInsert(offset, " ", editGroup); //$NON-NLS-1$
        if (newQual != null ) {
          doTextInsert(offset, newQual, 0, false, getEditGroup(qualEvent));
          doTextInsert(offset, ".", editGroup); //$NON-NLS-1$
        }
        doTextInsert(offset, "this", editGroup); //$NON-NLS-1$
        if (newParamCount > 0) {
          doTextInsert(offset, ", ", editGroup); //$NON-NLS-1$
        }
      } else {
        ASTNode elem= (ASTNode) event.getOriginalValue();
        SourceRange range= getExtendedRange(elem);
        int elemOffset= range.getStartPosition();
        int elemLength= range.getLength();
        int elemEnd= elemOffset + elemLength;
        if (changeKind == RewriteEvent.REMOVED) {
          editGroup= getEditGroup(event);
          int endPos;
          if (oldParamCount == 0) {
            endPos= getScanner().getTokenStartOffset(TerminalTokens.TokenNameRPAREN, elemEnd);
          } else {
            endPos= getScanner().getTokenEndOffset(TerminalTokens.TokenNameCOMMA, elemEnd);
          }
          doTextRemoveAndVisit(offset, endPos - offset, elem, editGroup);
          return endPos;
        } else if (changeKind == RewriteEvent.REPLACED) {
          editGroup= getEditGroup(event);
          doTextRemoveAndVisit(elemOffset, elemLength, elem, editGroup);
          doTextInsert(elemOffset, (ASTNode) event.getNewValue(), 0, false, editGroup);
          rewriteQualifier = true;
        }
      }
    } else {
      rewriteRequiredNode(method, MethodDeclaration.RECEIVER_TYPE_PROPERTY);
      if (method.getReceiverType() != null) {
        rewriteQualifier = true;
      }
    }
    if (rewriteQualifier) {
      if (qualEvent != null) {
        int qualChangeKind = qualEvent.getChangeKind();
        TextEditGroup qualGroup = getEditGroup(qualEvent);
        if (qualChangeKind == RewriteEvent.INSERTED) {
          int pos= getScanner().getTokenStartOffset(TerminalTokens.TokenNamethis, offset);
          doTextInsert(pos, (ASTNode) qualEvent.getNewValue(), 0, false, qualGroup);
          doTextInsert(pos, ".", qualGroup); //$NON-NLS-1$
        } else if (qualChangeKind == RewriteEvent.REMOVED) {
View Full Code Here

    ArrayType replacingType= arrayType;
    int nOldBrackets= getDimensions(arrayType); // number of total brackets
    boolean astLevelGTE8 = node.getAST().apiLevel() >= AST.JLS8;
    boolean typeReplaced = false;

    TextEditGroup editGroup= null;
    RewriteEvent typeEvent= getEvent(node, ArrayCreation.TYPE_PROPERTY);
    if (typeEvent != null && typeEvent.getChangeKind() == RewriteEvent.REPLACED) { // changed arraytype can have different dimension or type name
      typeReplaced = true;
      replacingType= (ArrayType) typeEvent.getNewValue();
      editGroup= getEditGroup(typeEvent);
View Full Code Here

    if (!hasChildrenChanges(node)) {
      return doVisitUnchangedChildren(node);
    }

    Boolean newLiteral= (Boolean) getNewValue(node, BooleanLiteral.BOOLEAN_VALUE_PROPERTY);
    TextEditGroup group = getEditGroup(node, BooleanLiteral.BOOLEAN_VALUE_PROPERTY);
    doTextReplace(node.getStartPosition(), node.getLength(), newLiteral.toString(), group);
    return false;
  }
View Full Code Here

    if (!hasChildrenChanges(node)) {
      return doVisitUnchangedChildren(node);
    }

    String escapedSeq= (String) getNewValue(node, CharacterLiteral.ESCAPED_VALUE_PROPERTY);
    TextEditGroup group = getEditGroup(node, CharacterLiteral.ESCAPED_VALUE_PROPERTY);
    doTextReplace(node.getStartPosition(), node.getLength(), escapedSeq, group);
    return false;
  }
View Full Code Here

   
    if (removeLeft) {
      Expression left= node.getLeftOperand();
      int leftStart= getExtendedOffset(left);
      pos= getExtendedOffset(right);
      TextEditGroup editGroup= getEditGroup(leftEvent);
      doTextRemoveAndVisit(leftStart, pos - leftStart, left, editGroup);
    } else {
      pos = rewriteRequiredNode(node, InfixExpression.LEFT_OPERAND_PROPERTY);
    }

    boolean needsNewOperation= isChanged(node, InfixExpression.OPERATOR_PROPERTY);
    String operation= getNewValue(node, InfixExpression.OPERATOR_PROPERTY).toString();
    if (needsNewOperation && !removeLeft && !removeRight) {
      replaceOperation(pos, operation, getEditGroup(node, InfixExpression.OPERATOR_PROPERTY));
    }

    if (removeRight) {
      int end;
      if (removeLeft && node.extendedOperands().size() > 0) {
        end= getExtendedOffset((Expression) node.extendedOperands().get(0));
      } else {
        end= getExtendedEnd(right);
      }
      TextEditGroup editGroup= getEditGroup(rightEvent);
      doTextRemoveAndVisit(pos, end - pos, right, editGroup);
      pos= end;
    } else {
      pos= rewriteRequiredNode(node, InfixExpression.RIGHT_OPERAND_PROPERTY);
    }

    RewriteEvent event= getEvent(node, InfixExpression.EXTENDED_OPERANDS_PROPERTY);
    String prefixString= ' ' + operation + ' ';

    if (needsNewOperation) {
      int startPos= pos;
      TextEditGroup editGroup= getEditGroup(node, InfixExpression.OPERATOR_PROPERTY);

      if (event != null && event.getChangeKind() != RewriteEvent.UNCHANGED) {
        RewriteEvent[] extendedOperands= event.getChildren();
        for (int i= 0; i < extendedOperands.length; i++) {
          RewriteEvent curr= extendedOperands[i];
View Full Code Here

      hasParentheses = !(parameters.size() == 1 && parameters.get(0) instanceof VariableDeclarationFragment);
    }

    boolean deleteParentheses = false;
    boolean insertParentheses = false;
    TextEditGroup editGroup = null;

    boolean oldHasParentheses = getOriginalValue(node, LambdaExpression.PARENTHESES_PROPERTY).equals(Boolean.TRUE);
    RewriteEvent event = getEvent(node, LambdaExpression.PARENTHESES_PROPERTY);
    if (event != null) {
      editGroup = getEditGroup(event);
View Full Code Here

  public boolean visit(NumberLiteral node) {
    if (!hasChildrenChanges(node)) {
      return doVisitUnchangedChildren(node);
    }
    String newLiteral= (String) getNewValue(node, NumberLiteral.TOKEN_PROPERTY);
    TextEditGroup group = getEditGroup(node, NumberLiteral.TOKEN_PROPERTY);
    doTextReplace(node.getStartPosition(), node.getLength(), newLiteral, group);
    return false;
  }
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.