1 11 package org.eclipse.pde.internal.ui.editor.contentassist.display; 12 13 14 import org.eclipse.jdt.core.IBuffer; 15 import org.eclipse.jdt.core.formatter.IndentManipulation; 16 17 21 public class JavaDocCommentReader extends SingleCharReader { 22 23 private IBuffer fBuffer; 24 25 private int fCurrPos; 26 private int fStartPos; 27 private int fEndPos; 28 29 private boolean fWasNewLine; 30 31 public JavaDocCommentReader(IBuffer buf, int start, int end) { 32 fBuffer= buf; 33 fStartPos= start + 3; 34 fEndPos= end - 2; 35 36 reset(); 37 } 38 39 42 public int read() { 43 if (fCurrPos < fEndPos) { 44 char ch; 45 if (fWasNewLine) { 46 do { 47 ch= fBuffer.getChar(fCurrPos++); 48 } while (fCurrPos < fEndPos && Character.isWhitespace(ch)); 49 if (ch == '*') { 50 if (fCurrPos < fEndPos) { 51 do { 52 ch= fBuffer.getChar(fCurrPos++); 53 } while (ch == '*'); 54 } else { 55 return -1; 56 } 57 } 58 } else { 59 ch= fBuffer.getChar(fCurrPos++); 60 } 61 fWasNewLine= IndentManipulation.isLineDelimiterChar(ch); 62 63 return ch; 64 } 65 return -1; 66 } 67 68 71 public void close() { 72 fBuffer= null; 73 } 74 75 78 public void reset() { 79 fCurrPos= fStartPos; 80 fWasNewLine= true; 81 } 82 83 84 87 public int getOffset() { 88 return fCurrPos; 89 } 90 91 92 } 93 | Popular Tags |