| 6188 | } |
| 6189 | |
| 6190 | size_t ASFormatter::findFormattedLineSplitPoint() const |
| 6191 | { |
| 6192 | assert(maxCodeLength != string::npos); |
| 6193 | // determine where to split |
| 6194 | size_t minCodeLength = 10; |
| 6195 | size_t splitPoint = 0; |
| 6196 | splitPoint = maxSemi; |
| 6197 | if (maxAndOr >= minCodeLength) |
| 6198 | splitPoint = maxAndOr; |
| 6199 | if (splitPoint < minCodeLength) |
| 6200 | { |
| 6201 | splitPoint = maxWhiteSpace; |
| 6202 | // use maxParen instead if it is long enough |
| 6203 | if (maxParen > splitPoint |
| 6204 | || maxParen >= maxCodeLength * .7) |
| 6205 | splitPoint = maxParen; |
| 6206 | // use maxComma instead if it is long enough |
| 6207 | // increasing the multiplier causes more splits at whitespace |
| 6208 | if (maxComma > splitPoint |
| 6209 | || maxComma >= maxCodeLength * .3) |
| 6210 | splitPoint = maxComma; |
| 6211 | } |
| 6212 | // replace split point with first available break point |
| 6213 | if (splitPoint < minCodeLength) |
| 6214 | { |
| 6215 | splitPoint = string::npos; |
| 6216 | if (maxSemiPending > 0 && maxSemiPending < splitPoint) |
| 6217 | splitPoint = maxSemiPending; |
| 6218 | if (maxAndOrPending > 0 && maxAndOrPending < splitPoint) |
| 6219 | splitPoint = maxAndOrPending; |
| 6220 | if (maxCommaPending > 0 && maxCommaPending < splitPoint) |
| 6221 | splitPoint = maxCommaPending; |
| 6222 | if (maxParenPending > 0 && maxParenPending < splitPoint) |
| 6223 | splitPoint = maxParenPending; |
| 6224 | if (maxWhiteSpacePending > 0 && maxWhiteSpacePending < splitPoint) |
| 6225 | splitPoint = maxWhiteSpacePending; |
| 6226 | if (splitPoint == string::npos) |
| 6227 | splitPoint = 0; |
| 6228 | } |
| 6229 | // if remaining line after split is too long |
| 6230 | else if (formattedLine.length() - splitPoint > maxCodeLength) |
| 6231 | { |
| 6232 | // if end of the currentLine, find a new split point |
| 6233 | size_t newCharNum; |
| 6234 | if (isCharPotentialHeader(currentLine, charNum)) |
| 6235 | newCharNum = getCurrentWord(currentLine, charNum).length() + charNum; |
| 6236 | else |
| 6237 | newCharNum = charNum + 2; |
| 6238 | if (newCharNum + 1 > currentLine.length()) |
| 6239 | { |
| 6240 | // don't move splitPoint from before a conditional to after |
| 6241 | if (maxWhiteSpace > splitPoint + 3) |
| 6242 | splitPoint = maxWhiteSpace; |
| 6243 | if (maxParen > splitPoint) |
| 6244 | splitPoint = maxParen; |
| 6245 | } |
| 6246 | } |
| 6247 |
nothing calls this directly
no outgoing calls
no test coverage detected