Package org.eclipse.jdt.core.dom.rewrite.TargetSourceRangeComputer

Examples of org.eclipse.jdt.core.dom.rewrite.TargetSourceRangeComputer.SourceRange


         
          // 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);
          return nodeOffset + nodeLen;
        }
      }
View Full Code Here


          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);
          doTextInsert(offset, (ASTNode) event.getNewValue(), getIndent(startPos), true, editGroup);
          try {
            return getScanner().getTokenEndOffset(TerminalTokens.TokenNameDOT, offset + length);
View Full Code Here

    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);
      addEditGroup(editGroup, edit);
      addEdit(edit);
      this.currentEdit= edit;
    }
View Full Code Here

          pos= endPos;
          break;
        }
        case RewriteEvent.REPLACED: {
          ASTNode superClass= (ASTNode) superClassEvent.getOriginalValue();
          SourceRange range= getExtendedRange(superClass);
          int offset= range.getStartPosition();
          int length= range.getLength();
          doTextRemoveAndVisit(offset, length, superClass, getEditGroup(superClassEvent));
          doTextInsert(offset, (ASTNode) superClassEvent.getNewValue(), 0, false, getEditGroup(superClassEvent));
          pos= offset + length;
          break;
        }
View Full Code Here

      ArrayType replacingType= (ArrayType) typeEvent.getNewValue();
      editGroup= getEditGroup(typeEvent);
      Type newType= replacingType.getElementType();
      Type oldType= getElementType(arrayType);
      if (!newType.equals(oldType)) {
        SourceRange range= getExtendedRange(oldType);
        int offset= range.getStartPosition();
        int length= range.getLength();
        doTextRemove(offset, length, editGroup);
        doTextInsert(offset, newType, 0, false, editGroup);
      }
      nNewBrackets= replacingType.getDimensions(); // is replaced type
    }
    voidVisit(arrayType);


    try {
      int offset= getScanner().getTokenStartOffset(TerminalTokens.TokenNameLBRACKET, arrayType.getStartPosition());
      // dimension node with expressions
      RewriteEvent dimEvent= getEvent(node, ArrayCreation.DIMENSIONS_PROPERTY);
      boolean hasDimensionChanges= (dimEvent != null && dimEvent.getChangeKind() != RewriteEvent.UNCHANGED);
      if (hasDimensionChanges) {
        RewriteEvent[] events= dimEvent.getChildren();
        // offset on first opening brace
        for (int i= 0; i < events.length; i++) {
          RewriteEvent event= events[i];
          int changeKind= event.getChangeKind();
          if (changeKind == RewriteEvent.INSERTED) { // insert new dimension
            editGroup= getEditGroup(event);
            doTextInsert(offset, "[", editGroup); //$NON-NLS-1$
            doTextInsert(offset, (ASTNode) event.getNewValue(), 0, false, editGroup);
            doTextInsert(offset, "]", editGroup); //$NON-NLS-1$
            nNewBrackets--;
          } else {
            ASTNode elem= (ASTNode) event.getOriginalValue();
            int elemEnd= elem.getStartPosition() + elem.getLength();
            int endPos= getScanner().getTokenEndOffset(TerminalTokens.TokenNameRBRACKET, elemEnd);
            if (changeKind == RewriteEvent.REMOVED) {
              editGroup= getEditGroup(event);
              doTextRemoveAndVisit(offset, endPos - offset, elem, editGroup);
            } else if (changeKind == RewriteEvent.REPLACED) {
              editGroup= getEditGroup(event);
              SourceRange range= getExtendedRange(elem);
              int elemOffset= range.getStartPosition();
              int elemLength= range.getLength();
              doTextRemoveAndVisit(elemOffset, elemLength, elem, editGroup);
              doTextInsert(elemOffset, (ASTNode) event.getNewValue(), 0, false, editGroup);
              nNewBrackets--;
            } else {
              voidVisit(elem);
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.dom.rewrite.TargetSourceRangeComputer.SourceRange

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.