* register an in-statement indent. */
| 1103 | * register an in-statement indent. |
| 1104 | */ |
| 1105 | void ASBeautifier::registerInStatementIndent(const string &line, int i, int spaceTabCount_, |
| 1106 | int tabIncrementIn, int minIndent, bool updateParenStack) |
| 1107 | { |
| 1108 | int inStatementIndent; |
| 1109 | int remainingCharNum = line.length() - i; |
| 1110 | int nextNonWSChar = getNextProgramCharDistance(line, i); |
| 1111 | |
| 1112 | // if indent is around the last char in the line, indent instead one indent from the previous indent |
| 1113 | if (nextNonWSChar == remainingCharNum) |
| 1114 | { |
| 1115 | int previousIndent = spaceTabCount_; |
| 1116 | if (!inStatementIndentStack->empty()) |
| 1117 | previousIndent = inStatementIndentStack->back(); |
| 1118 | int currIndent = /*2*/ indentLength + previousIndent; |
| 1119 | if (currIndent > maxInStatementIndent |
| 1120 | && line[i] != '{') |
| 1121 | currIndent = indentLength * 2 + spaceTabCount_; |
| 1122 | inStatementIndentStack->push_back(currIndent); |
| 1123 | if (updateParenStack) |
| 1124 | parenIndentStack->push_back(previousIndent); |
| 1125 | return; |
| 1126 | } |
| 1127 | |
| 1128 | if (updateParenStack) |
| 1129 | parenIndentStack->push_back(i + spaceTabCount_ - horstmannIndentInStatement); |
| 1130 | |
| 1131 | int tabIncrement = tabIncrementIn; |
| 1132 | |
| 1133 | // check for following tabs |
| 1134 | for (int j = i + 1; j < (i + nextNonWSChar); j++) |
| 1135 | { |
| 1136 | if (line[j] == '\t') |
| 1137 | tabIncrement += convertTabToSpaces(j, tabIncrement); |
| 1138 | } |
| 1139 | |
| 1140 | inStatementIndent = i + nextNonWSChar + spaceTabCount_ + tabIncrement; |
| 1141 | |
| 1142 | // check for run-in statement |
| 1143 | if (i > 0 && line[0] == '{') |
| 1144 | inStatementIndent -= indentLength; |
| 1145 | |
| 1146 | if (inStatementIndent < minIndent) |
| 1147 | inStatementIndent = minIndent + spaceTabCount_; |
| 1148 | |
| 1149 | // this is not done for an in-statement array |
| 1150 | if (inStatementIndent > maxInStatementIndent |
| 1151 | && !(prevNonLegalCh == '=' && currentNonLegalCh == '{')) |
| 1152 | inStatementIndent = indentLength * 2 + spaceTabCount_; |
| 1153 | |
| 1154 | if (!inStatementIndentStack->empty() && |
| 1155 | inStatementIndent < inStatementIndentStack->back()) |
| 1156 | inStatementIndent = inStatementIndentStack->back(); |
| 1157 | |
| 1158 | // the block opener is not indented for a NonInStatementArray |
| 1159 | if (isNonInStatementArray && !isInEnum && !bracketBlockStateStack->empty() && bracketBlockStateStack->back()) |
| 1160 | inStatementIndent = 0; |
| 1161 | |
| 1162 | inStatementIndentStack->push_back(inStatementIndent); |
nothing calls this directly
no outgoing calls
no test coverage detected