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

java.lang.Object
  extended by edu.rice.cs.drjava.model.definitions.indent.IndentRuleWithTrace
      extended by edu.rice.cs.drjava.model.definitions.indent.IndentRuleQuestion
All Implemented Interfaces:
IndentRule
Direct Known Subclasses:
QuestionBraceIsCurly, QuestionBraceIsParenOrBracket, QuestionCurrLineIsWingComment, QuestionCurrLineStartsWith, QuestionCurrLineStartsWithSkipComments, QuestionExistsCharInPrevStmt, QuestionExistsCharInStmt, QuestionFollowedByStar, QuestionHasCharPrecedingOpenBrace, QuestionLineContains, QuestionNewParenPhrase, QuestionPrevLineStartsJavaDocWithText, QuestionPrevLineStartsWith, QuestionStartAfterOpenBrace, QuestionStartingNewStmt

public abstract class IndentRuleQuestion
extends IndentRuleWithTrace

A question node in the decision tree for the indentation system. Calls to indentLine on an IndentRuleQuestion will make a decision based on context and call the same method on one of its children. The leaves of the tree are represented by IndentRuleAction objects.

Version:
$Id: IndentRuleQuestion.java 4653 2008-08-26 14:46:35Z rcartwright $

Field Summary
 
Fields inherited from class edu.rice.cs.drjava.model.definitions.indent.IndentRuleWithTrace
NO, TERMINUS_RULE, YES
 
Constructor Summary
IndentRuleQuestion(IndentRule yesRule, IndentRule noRule)
          Constructs a new Question indent rule using the two given children.
 
Method Summary
 boolean indentLine(AbstractDJDocument doc, Indenter.IndentReason reason)
          Determines if the given rule holds in this context and calls the same method on one of its child nodes.
 boolean testIndentLine(AbstractDJDocument doc, Indenter.IndentReason reason)
          Convenience method that wraps calls on indentLine in a write lock.
 
Methods inherited from class edu.rice.cs.drjava.model.definitions.indent.IndentRuleWithTrace
_addToIndentTrace, getRuleName, indentLine, printLastIndentTrace, setRuleTraceEnabled, testIndentLine
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IndentRuleQuestion

public IndentRuleQuestion(IndentRule yesRule,
                          IndentRule noRule)
Constructs a new Question indent rule using the two given children.

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

indentLine

public boolean indentLine(AbstractDJDocument doc,
                          Indenter.IndentReason reason)
Determines if the given rule holds in this context and calls the same method on one of its child nodes.

Specified by:
indentLine in interface IndentRule
Overrides:
indentLine in class IndentRuleWithTrace
Parameters:
doc - AbstractDJDocument containing the line to be indented.
reason - The reason that indentation was initiated, specified in Indenter
Returns:
true if the caller should update the current location itself, false if the indenter has already handled this

testIndentLine

public boolean testIndentLine(AbstractDJDocument doc,
                              Indenter.IndentReason reason)
Convenience method that wraps calls on indentLine in a write lock. Only used in testing.

Overrides:
testIndentLine in class IndentRuleWithTrace