1 33 34 package edu.rice.cs.drjava.model.definitions.indent; 35 36 import edu.rice.cs.util.UnexpectedException; 37 38 import edu.rice.cs.drjava.model.AbstractDJDocument; 39 import edu.rice.cs.drjava.model.definitions.reducedmodel.*; 40 41 import javax.swing.text.BadLocationException ; 42 43 49 public class ActionStartStmtOfBracePlus extends IndentRuleAction { 50 private String _suffix; 51 52 56 public ActionStartStmtOfBracePlus(String suffix) { 57 super(); 58 _suffix = suffix; 59 } 60 61 69 public boolean indentLine(AbstractDJDocument doc, int reason) { 70 boolean supResult = super.indentLine(doc, reason); 71 int pos = doc.getCurrentLocation(); 72 73 IndentInfo info = doc.getIndentInformation(); 75 int distToBrace = info.distToBrace; 76 77 if (distToBrace == -1) { 79 doc.setTab(_suffix, pos); 80 return supResult; 81 } 82 83 int bracePos = pos - distToBrace; 85 86 String indent = ""; 87 try { 88 indent = doc.getIndentOfCurrStmt(bracePos); 89 } catch (BadLocationException e) { 90 throw new UnexpectedException(e); 92 } 93 indent = indent + _suffix; 94 95 doc.setTab(indent, pos); 96 97 return supResult; 98 } 99 100 } 101 | Popular Tags |