edu.rice.cs.drjava.model.definitions.indent |
Provides a decision tree used to correctly indent the current line.
The tree is composed of {@link edu.rice.cs.drjava.model.definitions.indent.IndentRule}s, and asks a series of yes or no
questions about the current position before determining the appropriate
action. All nodes use helper methods from {@link edu.rice.cs.drjava.model.definitions.DefinitionsDocument} and
the {@link edu.rice.cs.drjava.model.definitions.reducedmodel Reduced Model} package for context.
The tree itself is built in the {@link edu.rice.cs.drjava.model.definitions.indent.Indenter} class, where a singleton
instance is made available to DefinitionsDocument for using on a single line.
An outline of the tree is given below.
- 1. QuestionInsideComment
- 2. Yes: QuestionPrevLineStartsComment
- 3. Yes: QuestionCurrLineEmptyOrEnterPress
Starting first line of a mutli-line comment
- 4. Yes (no auto-close): ActionStartPrevLinePlus(" * ")
Without auto-close comments, we always do the same thing.
- 42. Yes (auto-close): QuestionFollowedByStar
- 4. Yes: ActionStartPrevLinePlus(" * ")
We are already inside a comment - no need to close it.
- 41. No: ActionStartPrevLinePlusMultiline
(new String[] { " * \n", " */" }, 0, 3)
We are starting a new block comment - close it.
- 5. No: ActionStartPrevLinePlus(" ")
Revisiting first line of a mutli-line comment
- 6. No: QuestionPrevLineStartsWith("*")
- 7. Yes: QuestionCurrLineStartsWith("*")
- 8. Yes: ActionStartPrevLinePlus("") (Goto 12)
Revisiting middle line of a mutli-line comment (with star)
- 9. No: QuestionCurrLineEmptyOrEnterPress
- 10. Yes: ActionStartPrevLinePlus("* ")
Starting middle line of a mutli-line comment
- 11. No: ActionStartPrevLinePlus("") (Goto 12)
Revisiting middle line of a mutli-line comment (without star)
- 12. No: ActionStartPrevLinePlus("")
Following a line with no start in a mutli-line comment
- 13. No: QuestionBraceIsParenOrBracket
- 14. Yes: QuestionNewParenPhrase
- 15. Yes: ActionBracePlus(" ")
- 16. No: ActionBracePlus(" " + 1 level)
- 17. No: QuestionBraceIsCurly
- 18. Yes: QuestionCurrLineStartsWithSkipComments("}")
- 19. Yes: ActionStartStmtOfBracePlus("")
- 20. No: QuestionStartAfterOpenBrace
- 21. Yes: ActionStartStmtOfBracePlus(1 level) (Goto 36)
- 22. No: QuestionHasCharPrecedingOpenBrace
- 23. Yes: ActionStartStmtOfBracePlus(1 level) (Goto 36)
- 24. No: Goto 25.
- 25. No: QuestionStartingNewStmt
- 26. Yes: QuestionLineContains(":")
- 27. Yes: QuestionExistsCharInStmt("?", ":")
- 28. Yes: ActionStartPrevStmtPlus("", false) (Goto 30)
- 29. No: ActionStartStmtOfBracePlus(1 level) (Goto 36)
- 30. No: ActionStartPrevStmtPlus("", true)
- 31. No: QuestionCurrLineStartsWithSkipComments("{")
- 32. Yes: ActionStartCurrStmtPlus("")
- 33. No: QuestionLineContains(":")
- 34. Yes: QuestionExistsCharInStmt("?", ":")
- 35. Yes: ActionStartCurrStmtPlus(1 level) (Goto 37)
- 36. No: ActionStartStmtOfBracePlus(1 level)
- 37. No: ActionStartCurrStmtPlus(1 level)
@see edu.rice.cs.drjava.model.definitions
@see edu.rice.cs.drjava.model.definitions.reducedmodel
|
Java Source File Name | Type | Comment |
ActionBracePlus.java | Class | Aligns indentation of the current line to the character that opened the enclosing block or expression list. |
ActionBracePlusTest.java | Class | Test class according to the JUnit protocol. |
ActionDoNothing.java | Class | Indents the current line in the document to the indent level of the
start of the contract or statement of the brace enclosing the current
position, plus the given suffix. |
ActionDoNothingTest.java | Class | Tests the action rule which does nothing to the given text. |
ActionStartCurrStmtPlus.java | Class | Indents the current line in the document to the indent level of the start of the statement that the cursor is
currently on, plus the given suffix string. |
ActionStartPrevLinePlus.java | Class | Indents the current line in the document to the indent level of the
start of the previous line, plus the given suffix. |
ActionStartPrevLinePlusBackup.java | Class | Indents the current line in the document to the indent level of the
start of the previous line, plus the given suffix, then backs up to a
specific cursor position. |
ActionStartPrevLinePlusBackupTest.java | Class | Test class for an indent rule with a really long name. |
ActionStartPrevLinePlusMultiline.java | Class | Indents the current line in the document to the indent level of the
start of the previous line, adds several lines of text at that indent level,
and moves the cursor to a particular line and position. |
ActionStartPrevLinePlusMultilinePreserve.java | Class | Indents the current line in the document to the indent level of the
start of the previous line, preserving any text on the current line,
and adds several lines of text at that indent level,
and moves the cursor to a particular line and position. |
ActionStartPrevLinePlusMultilinePreserveTest.java | Class | Tests ActionStartPrevLinePlusMultilinePreserve(String,int,int,int,int). |
ActionStartPrevLinePlusMultilineTest.java | Class | Test class for an indent rule with a really long name. |
ActionStartPrevLinePlusTest.java | Class | |
ActionStartPrevStmtPlus.java | Class | Indents the current line in the document to the indent level of the
start of the statement previous to the one the cursor is currently on,
plus the given suffix string. |
ActionStartPrevStmtPlusTest.java | Class | Test the action rules for code in the indentation decision tree. |
ActionStartStmtOfBracePlus.java | Class | Indents the current line in the document to the indent level of the
start of the contract or statement of the brace enclosing the start of the
current line, plus the given suffix. |
ActionStartStmtOfBracePlusTest.java | Class | Test the action rules for code in the indentation decision tree. |
Indenter.java | Class | Singleton class to construct and use the indentation decision tree. |
IndentRule.java | Interface | A node in the decision tree used for the indentation system. |
IndentRuleAction.java | Class | A leaf node in the decision tree for the indentation system. |
IndentRuleQuestion.java | Class | 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. |
IndentRulesTestCase.java | Class | Superclass for all test classes for the indentation decision tree. |
IndentRuleWithTrace.java | Class | This class does almost all the work for keeping an indent tree trace. |
IndentRuleWithTraceTest.java | Class | This class does almost all the work for keeping an indent tree trace. |
QuestionBraceIsCurly.java | Class | Determines whether or not the last block or expression list opened previous to the start of the current line was
opened by the character '{'. |
QuestionBraceIsCurlyTest.java | Class | Test class according to the JUnit protocol. |
QuestionBraceIsParenOrBracket.java | Class | Determines whether or not the last block or expression list opened previous to the start of the current line was opened
by one of the characters '(' or '['. |
QuestionBraceIsParenOrBracketTest.java | Class | Test class according to the JUnit protocol. |
QuestionCurrLineEmpty.java | Class | |
QuestionCurrLineEmptyOrEnterPress.java | Class | |
QuestionCurrLineEmptyOrEnterPressTest.java | Class | Tests whether the current line is empty. |
QuestionCurrLineIsWingComment.java | Class | |
QuestionCurrLineIsWingCommentTest.java | Class | Tests visitor class that determines whether the current line is a wing comment. |
QuestionCurrLineStartsWith.java | Class | Question rule in the indentation decision tree. |
QuestionCurrLineStartsWithSkipComments.java | Class | Determines whether or not the current line in the document starts with a specific character sequence,
skipping over any comments on that line. |
QuestionCurrLineStartsWithSkipCommentsTest.java | Class | Test class according to the JUnit protocol. |
QuestionCurrLineStartsWithTest.java | Class | Tests the indention rule which detects whether the current line
starts with a particular string. |
QuestionExistsCharInPrevStmt.java | Class | |
QuestionExistsCharInStmt.java | Class | 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. |
QuestionExistsCharInStmtTest.java | Class | Tests the question rule which determines if the given findChar
is found between the start of the statement and the endChar,
which must exist on the current line. |
QuestionFollowedByStar.java | Class | Question rule in the indentation decision tree. |
QuestionHasCharPrecedingOpenBrace.java | Class | Determines whether or not the last '{' was immediately preceded
by _prefix So when _prefix='=', effectivily, we are looking for "={"
This questions corresponds to rule 22 in our decision tree. |
QuestionHasCharPrecedingOpenBraceTest.java | Class | Test class according to the JUnit protocol. |
QuestionInsideComment.java | Class | Asks whether the beginning of the current line is inside a C-style comment. |
QuestionInsideCommentTest.java | Class | Tests whether start of line is within a multiline comment. |
QuestionLineContains.java | Class | Question rule in the indentation decision tree. |
QuestionLineContainsTest.java | Class | Tests the question rule which determines if the current line
in the document contains the given character. |
QuestionNewParenPhrase.java | Class | Question rule in the indentation decision tree. |
QuestionNewParenPhraseTest.java | Class | Tests the indention rule which detects whether the current line starts
a new parenthesized phrase. |
QuestionPrevLineStartsComment.java | Class | Given the start of the current line is inside a block comment, asks
whether the comment begins on the "previous line," ignoring white space. |
QuestionPrevLineStartsCommentTest.java | Class | Tests whether the previous line starts the comment containing the cursor. |
QuestionPrevLineStartsJavaDocWithText.java | Class | Question rule in the indentation decision tree. |
QuestionPrevLineStartsWith.java | Class | Question rule in the indentation decision tree. |
QuestionPrevLineStartsWithTest.java | Class | Tests the indention rule which detects whether the immediately previous line
starts with a particular string. |
QuestionStartAfterOpenBrace.java | Class | Determines whether or not the closest non-whitespace character previous to the start of the current line (excluding
any characters inside comments or strings) is an open brace. |
QuestionStartAfterOpenBraceTest.java | Class | Test class according to the JUnit protocol. |
QuestionStartingNewStmt.java | Class | Determines if the current line is starting a new statement by
searching backwards to see if the previous line was the end
of a statement. |
QuestionStartingNewStmtTest.java | Class | Tests the question rule which determines if the current line
is starting a new statement. |