edu.rice.cs.drjava.model.definitions.indent
Class QuestionExistsCharInStmt
java.lang.Object
|
+--edu.rice.cs.drjava.model.definitions.indent.IndentRuleQuestion
|
+--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: '}', '{', ';', DOCSTART.
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,v 1.5 2002/04/02 07:11:37 csreis Exp $
Field Summary |
private char |
_endChar
The character which marks the end of the search
space. |
private char |
_findChar
The character to search for |
Method Summary |
(package private) boolean |
applyRule(DefinitionsDocument doc)
Searches backwards from endChar to the start of the statement
looking for findChar. |
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
_findChar
private char _findChar
- The character to search for
_endChar
private char _endChar
- The character which marks the end of the search
space. i.e. search from the start of the statment
to the end char.
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 endCharendChar
- 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 holdsnoRule
- Rule to use if this rule does not hold
applyRule
boolean applyRule(DefinitionsDocument doc)
- Searches backwards from endChar to the start of the statement
looking for findChar. Ignores characters in comments and quotes.
Start of the statement is the point right after when one of the
following characters is found: ';', '{', '}', DOCSTART.
- Overrides:
applyRule
in class IndentRuleQuestion
- Parameters:
doc
- DefinitionsDocument containing the line to be indented.- Returns:
- true if this node's rule holds.