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

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

public class QuestionExistsCharInStmt
extends IndentRuleQuestion

Determines if the given search character is found between the start of the current statement and the end character. Accomplishes this by searching backwards from the end character, for the search character until one of the following characters is found: '}', '{', ';', 0. The given end character must exist on the current line and not be part of a quote or comment. If there is more than end character on the given line, then the first end character is used.

This question is useful for determining if, when a colon is found on a line, it is part of a ternary operator or not (construct this question with '?' for search character and ':' for end character).

It can also be used to determine if a statement contains a particular character by constructing it with the desired character as a search character and the end character as ';'.

Note that characters in comments and quotes are disregarded.

Version:
$Id: QuestionExistsCharInStmt.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
QuestionExistsCharInStmt(char findChar, char endChar, IndentRule yesRule, IndentRule noRule)
          Constructs a rule to determine if findChar exists between the start of the current statement and endChar.
 
Method Summary
 
Methods inherited from class edu.rice.cs.drjava.model.definitions.indent.IndentRuleQuestion
indentLine, testIndentLine
 
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

QuestionExistsCharInStmt

public QuestionExistsCharInStmt(char findChar,
                                char endChar,
                                IndentRule yesRule,
                                IndentRule noRule)
Constructs a rule to determine if findChar exists between the start of the current statement and endChar.

Parameters:
findChar - Character to search for from the start of the statement to endChar
endChar - Character that marks the end of the search space. Must exist on the current line and not be in quotes or comments.
yesRule - Rule to use if this rule holds
noRule - Rule to use if this rule does not hold