コード例 #1
1
  private String trim(final StringBuffer buffer, final TextPresentation presentation) {

    int length = buffer.length();

    int end = length - 1;
    while (end >= 0 && Character.isWhitespace(buffer.charAt(end))) {
      --end;
    }

    if (end == -1) {
      return ""; //$NON-NLS-1$
    }

    if (end < length - 1) {
      buffer.delete(end + 1, length);
    } else {
      end = length;
    }

    int start = 0;
    while (start < end && Character.isWhitespace(buffer.charAt(start))) {
      ++start;
    }

    buffer.delete(0, start);
    presentation.setResultWindow(new Region(start, buffer.length()));
    return buffer.toString();
  }
コード例 #2
0
 /*
  * @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.presentation.ISourcePresentationCreator#getPresentation(org.eclipse.jface.text.IRegion, org.eclipse.jface.text.IDocument)
  */
 public TextPresentation getPresentation(IRegion region, IDocument document) {
   assert fViewer != null;
   if (fViewer == null) {
     return null;
   }
   if (fPresentation == null) {
     setDocumentToDamagers(document);
     setDocumentToRepairers(document);
     int docLength = document.getLength();
     if (docLength <= 128 * 1024) {
       IRegion all = new Region(0, docLength);
       fPresentation = createPresentation(all, document);
     } else {
       return createPresentation(region, document);
     }
   }
   fPresentation.setResultWindow(region);
   return fPresentation;
 }