Preconditions: sc.currentPos points to a character after '+' or '-'. The test for pos reaching 0 should be redundant, and is in only for safety measures. Limitation: this code will give the incorrect answer for code like a = b+++/ptn/... Putting a space between the '++' post-inc operator and the '+' binary op fixes this, and is highly recommended for readability anyway.
| 51 | // Putting a space between the '++' post-inc operator and the '+' binary op |
| 52 | // fixes this, and is highly recommended for readability anyway. |
| 53 | static bool FollowsPostfixOperator(StyleContext &sc, Accessor &styler) { |
| 54 | int pos = (int) sc.currentPos; |
| 55 | while (--pos > 0) { |
| 56 | char ch = styler[pos]; |
| 57 | if (ch == '+' || ch == '-') { |
| 58 | return styler[pos - 1] == ch; |
| 59 | } |
| 60 | } |
| 61 | return false; |
| 62 | } |
| 63 | |
| 64 | static bool followsReturnKeyword(StyleContext &sc, Accessor &styler) { |
| 65 | // Don't look at styles, so no need to flush. |
no outgoing calls
no test coverage detected