|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.rice.cs.drjava.model.definitions.indent.IndentRuleWithTrace
edu.rice.cs.drjava.model.definitions.indent.IndentRuleQuestion
edu.rice.cs.drjava.model.definitions.indent.QuestionExistsCharInStmt
public class QuestionExistsCharInStmt
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.
| Field Summary | |
|---|---|
private char |
_endChar
The character which marks the end of the search space. |
private char |
_findChar
The character to search for |
| 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 | |
|---|---|
(package private) boolean |
applyRule(AbstractDJDocument doc,
Indenter.IndentReason reason)
Searches backwards from endChar to the start of the statement looking for findChar. |
| 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 |
| Field Detail |
|---|
private char _findChar
private char _endChar
| Constructor Detail |
|---|
public QuestionExistsCharInStmt(char findChar,
char endChar,
IndentRule yesRule,
IndentRule noRule)
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| Method Detail |
|---|
boolean applyRule(AbstractDJDocument doc,
Indenter.IndentReason reason)
applyRule in class IndentRuleQuestiondoc - AbstractDJDocument containing the line to be indented.reason - The reason that indentation was initiated, specified in Indenter
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||