1 33 34 package edu.rice.cs.drjava.model.definitions.indent; 35 36 import javax.swing.text.*; 37 import edu.rice.cs.util.UnexpectedException; 38 39 import edu.rice.cs.drjava.model.AbstractDJDocument; 40 import static edu.rice.cs.drjava.model.AbstractDJDocument.ERROR_INDEX; 41 42 46 public class QuestionPrevLineStartsJavaDocWithText extends IndentRuleQuestion { 47 48 52 public QuestionPrevLineStartsJavaDocWithText(IndentRule yesRule, IndentRule noRule) { super(yesRule, noRule); } 53 54 58 boolean applyRule(AbstractDJDocument doc, int reason) { 59 60 try { 61 int here = doc.getCurrentLocation(); 63 int startLine = doc.getLineStartPos(here); 64 65 if (startLine <= AbstractDJDocument.DOCSTART) return false; 67 int endPrevLine = startLine - 1; 69 int startPrevLine = doc.getLineStartPos(endPrevLine); 70 int firstChar = doc.getLineFirstCharPos(startPrevLine); 71 72 String actualPrefix = doc.getText(firstChar, 3); 74 if (! actualPrefix.equals("/**")) return false; 75 int nextNonWSChar = doc.getFirstNonWSCharPos(firstChar + 3, true); 76 return nextNonWSChar != ERROR_INDEX && nextNonWSChar <= endPrevLine; 77 } 78 catch (BadLocationException e) { 79 throw new UnexpectedException(e); 81 } 82 } 83 } 84 | Popular Tags |