1 11 package org.eclipse.jdt.internal.corext.javadoc; 12 13 import org.eclipse.jface.internal.text.html.SingleCharReader; 14 15 import org.eclipse.jdt.core.IBuffer; 16 import org.eclipse.jdt.core.formatter.IndentManipulation; 17 18 19 23 public class JavaDocCommentReader extends SingleCharReader { 24 25 private IBuffer fBuffer; 26 27 private int fCurrPos; 28 private int fStartPos; 29 private int fEndPos; 30 31 private boolean fWasNewLine; 32 33 public JavaDocCommentReader(IBuffer buf, int start, int end) { 34 fBuffer= buf; 35 fStartPos= start + 3; 36 fEndPos= end - 2; 37 38 reset(); 39 } 40 41 44 public int read() { 45 if (fCurrPos < fEndPos) { 46 char ch; 47 if (fWasNewLine) { 48 do { 49 ch= fBuffer.getChar(fCurrPos++); 50 } while (fCurrPos < fEndPos && Character.isWhitespace(ch)); 51 if (ch == '*') { 52 if (fCurrPos < fEndPos) { 53 do { 54 ch= fBuffer.getChar(fCurrPos++); 55 } while (ch == '*'); 56 } else { 57 return -1; 58 } 59 } 60 } else { 61 ch= fBuffer.getChar(fCurrPos++); 62 } 63 fWasNewLine= IndentManipulation.isLineDelimiterChar(ch); 64 65 return ch; 66 } 67 return -1; 68 } 69 70 73 public void close() { 74 fBuffer= null; 75 } 76 77 80 public void reset() { 81 fCurrPos= fStartPos; 82 fWasNewLine= true; 83 } 84 85 86 89 public int getOffset() { 90 return fCurrPos; 91 } 92 93 94 } 95 | Popular Tags |