Esempio n. 1
0
 protected Operation getInverse() {
   Operation inverse = new Operation();
   inverse.startIndex = startIndex;
   inverse.length = lengthNewString;
   inverse.newString = originalString;
   inverse.lengthNewString = length;
   inverse.tokenType = tokenType;
   return inverse;
 }
Esempio n. 2
0
 private void replace(int startIndex, int length, String replace, TokenHook.TokenType tokenType)
     throws InvalidOperationException {
   if (!this.inUse) {
     throw new RuntimeException("Closed editor");
   }
   if (startIndex > this.lastEditedIndex) {
     Operation operation = new Operation();
     operation.startIndex = startIndex + this.deltaIndexes;
     operation.length = length;
     if (replace == null) {
       operation.lengthNewString = length;
     } else {
       operation.newString = replace;
       operation.lengthNewString = replace.length();
     }
     operation.tokenType = tokenType;
     this.changeLog.add(operation);
     this.lastEditedIndex = startIndex + length - 1;
     this.deltaIndexes += (operation.lengthNewString - operation.length);
   } else {
     throw new InvalidOperationException(startIndex, this.lastEditedIndex);
   }
 }