1 33 34 package edu.rice.cs.drjava.model.definitions.indent; 35 36 import javax.swing.text.BadLocationException ; 37 38 import edu.rice.cs.drjava.model.AbstractDJDocument; 39 40 44 public class QuestionExistsCharInPrevStmt extends IndentRuleQuestion { 45 46 private char _lookFor; 47 48 public QuestionExistsCharInPrevStmt(char lookFor, IndentRule yesRule, IndentRule noRule) { 49 super(yesRule, noRule); 50 _lookFor = lookFor; 51 } 52 53 57 boolean applyRule(AbstractDJDocument doc, int reason) { 58 int endPreviousStatement; 60 try { 61 endPreviousStatement = 62 doc.findPrevDelimiter(doc.getCurrentLocation(), new char[] {';','}','{'}); 63 } catch (BadLocationException ble) { 64 return false; 66 } 67 68 if (endPreviousStatement == AbstractDJDocument.ERROR_INDEX) { 70 return false; 71 } 72 73 return doc.findCharInStmtBeforePos(_lookFor, endPreviousStatement); 75 } 76 } | Popular Tags |