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

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.QuestionPrevLineStartsComment
All Implemented Interfaces:
IndentRule

 class QuestionPrevLineStartsComment
extends IndentRuleQuestion

Given the start of the current line is inside a block comment, asks whether the comment begins on the "previous line," ignoring white space.

Version:
$Id: QuestionPrevLineStartsComment.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
QuestionPrevLineStartsComment(IndentRule yesRule, IndentRule noRule)
           
 
Method Summary
(package private)  boolean applyRule(AbstractDJDocument doc, Indenter.IndentReason reason)
          Determines if the previous line in the document starts a block comment.
 
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

QuestionPrevLineStartsComment

QuestionPrevLineStartsComment(IndentRule yesRule,
                              IndentRule noRule)
Method Detail

applyRule

boolean applyRule(AbstractDJDocument doc,
                  Indenter.IndentReason reason)
Determines if the previous line in the document starts a block comment. Assumes that read lock and reduced lock are already held. We know that the current line is in a block comment. Therefore, if the start of the previous line is not inside of a block comment, then the previous line must have started the comment.

There is an exception to this; however, it is handled adequately. Consider the case when the previous line contains the following code: */ bar(); /*

Our approach will say that since the beginning of the previous line is inside of a comment, the previous line did not start the comment. This is acceptable because we think of the previous line as a continuation of a larger commented out region.

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.