Package org.eclipse.core.filebuffers.manipulation

Examples of org.eclipse.core.filebuffers.manipulation.MultiTextEditWithProgress


          .beginTask(
              PHPUIMessages.RemoveTrailingWhitespaceOperation_task_generatingChanges,
              lineCount);
      try {

        MultiTextEditWithProgress multiEdit = new MultiTextEditWithProgress(
            PHPUIMessages.RemoveTrailingWhitespaceOperation_task_applyingChanges);

        for (int i = 0; i < lineCount; i++) {
          if (progressMonitor.isCanceled()) {
            throw new OperationCanceledException();
          }
          IRegion region = document.getLineInformation(i);
          if (region.getLength() == 0) {
            continue;
          }
          int lineStart = region.getOffset();
          int lineExclusiveEnd = lineStart + region.getLength();
          int j = lineExclusiveEnd - 1;
          while (j >= lineStart
              && Character.isWhitespace(document.getChar(j))) {
            --j;
          }
          ++j;
          // A flag for skipping empty lines, if required
          if (fIgnoreEmptyLines && j == lineStart) {
            continue;
          }
          if (j < lineExclusiveEnd) {
            multiEdit.addChild(new DeleteEdit(j, lineExclusiveEnd
                - j));
          }
          progressMonitor.worked(1);
        }

        return multiEdit.getChildrenSize() <= 0 ? null : multiEdit;

      } catch (BadLocationException x) {
        throw new CoreException(new Status(IStatus.ERROR,
            PHPUiPlugin.ID,
            IFileBufferStatusCodes.CONTENT_CHANGE_FAILED, "", x)); //$NON-NLS-1$
View Full Code Here

TOP

Related Classes of org.eclipse.core.filebuffers.manipulation.MultiTextEditWithProgress

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.