1 33 34 package edu.rice.cs.drjava.model.definitions.indent; 35 36 import javax.swing.text.BadLocationException ; 37 38 import edu.rice.cs.util.UnexpectedException; 39 import edu.rice.cs.drjava.model.AbstractDJDocument; 40 41 42 45 public class QuestionCurrLineIsWingComment extends IndentRuleQuestion { 46 47 50 public QuestionCurrLineIsWingComment(IndentRule yesRule, IndentRule noRule) { super(yesRule, noRule); } 51 52 58 boolean applyRule(AbstractDJDocument doc, int reason) { 59 try { 60 62 int currentPos = doc.getCurrentLocation(); 63 int startPos = doc.getLineStartPos(currentPos); 64 int maxPos = doc.getLength(); 65 int diff = maxPos - startPos; 66 67 if (diff < 2) return false; 68 69 String text = doc.getText(startPos, 2); 70 71 return text.equals("//"); 72 } 73 catch (BadLocationException e) { throw new UnexpectedException(); 74 } 75 } 76 77 } | Popular Tags |