edu.rice.cs.drjava.model.definitions.indent
Class QuestionStartingNewStmt

java.lang.Object
  extended by edu.rice.cs.drjava.model.definitions.indent.IndentRuleWithTrace
      extended by edu.rice.cs.drjava.model.definitions.indent.IndentRuleQuestion
          extended by edu.rice.cs.drjava.model.definitions.indent.QuestionStartingNewStmt
All Implemented Interfaces:
IndentRule

public class QuestionStartingNewStmt
extends IndentRuleQuestion

Determines if the current line is starting a new statement by searching backwards to see if the previous line was the end of a statement. Specifically, checks if the previous non-whitespace character not on this line is one of the following: ';', '{', '}', or 0.

Note that characters in comments and quotes are disregarded.

Version:
$Id: QuestionStartingNewStmt.java 5175 2010-01-20 08:46:32Z mgricken $

Field Summary
 
Fields inherited from class edu.rice.cs.drjava.model.definitions.indent.IndentRuleWithTrace
NO, TERMINUS_RULE, YES
 
Constructor Summary
QuestionStartingNewStmt(IndentRule yesRule, IndentRule noRule)
          Constructs a new rule to determine if the current line is the start of a new statement.
 
Method Summary
(package private)  boolean applyRule(AbstractDJDocument doc, Indenter.IndentReason reason)
          Determines if the previous non-whitespace character not on this line was one of the following: ';', '{', '}' or nothing.
 
Methods inherited from class edu.rice.cs.drjava.model.definitions.indent.IndentRuleQuestion
applyRule, indentLine, testApplyRule, testApplyRule, testIndentLine
 
Methods inherited from class edu.rice.cs.drjava.model.definitions.indent.IndentRuleWithTrace
_addToIndentTrace, getRuleName, getTrace, indentLine, printLastIndentTrace, setRuleTraceEnabled, testIndentLine
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QuestionStartingNewStmt

public QuestionStartingNewStmt(IndentRule yesRule,
                               IndentRule noRule)
Constructs a new rule to determine if the current line is the start of a new statement.

Parameters:
yesRule - Rule to use if this rule holds
noRule - Rule to use if this rule does not hold
Method Detail

applyRule

boolean applyRule(AbstractDJDocument doc,
                  Indenter.IndentReason reason)
Determines if the previous non-whitespace character not on this line was one of the following: ';', '{', '}' or nothing. Ignores characters in quotes and comments.

Specified by:
applyRule in class IndentRuleQuestion
Parameters:
doc - AbstractDJDocument containing the line to be indented.
reason - The reason that indentation was initiated, specified in Indenter
Returns:
true if this node's rule holds.