* get the next formatted line. * * @return formatted line. */
| 413 | * @return formatted line. |
| 414 | */ |
| 415 | string ASFormatter::nextLine() |
| 416 | { |
| 417 | const string* newHeader; |
| 418 | bool isInVirginLine = isVirgin; |
| 419 | isCharImmediatelyPostComment = false; |
| 420 | isPreviousCharPostComment = false; |
| 421 | isCharImmediatelyPostLineComment = false; |
| 422 | isCharImmediatelyPostOpenBlock = false; |
| 423 | isCharImmediatelyPostCloseBlock = false; |
| 424 | isCharImmediatelyPostTemplate = false; |
| 425 | traceLineNumber++; |
| 426 | |
| 427 | while (!isLineReady) |
| 428 | { |
| 429 | if (shouldReparseCurrentChar) |
| 430 | shouldReparseCurrentChar = false; |
| 431 | else if (!getNextChar()) |
| 432 | { |
| 433 | breakLine(); |
| 434 | continue; |
| 435 | } |
| 436 | else // stuff to do when reading a new character... |
| 437 | { |
| 438 | // make sure that a virgin '{' at the beginning of the file will be treated as a block... |
| 439 | if (isInVirginLine && currentChar == '{' |
| 440 | && currentLineBeginsWithBracket |
| 441 | && previousCommandChar == ' ') |
| 442 | previousCommandChar = '{'; |
| 443 | if (isInHorstmannRunIn) |
| 444 | isInLineBreak = false; |
| 445 | if (!isWhiteSpace(currentChar)) |
| 446 | isInHorstmannRunIn = false; |
| 447 | isPreviousCharPostComment = isCharImmediatelyPostComment; |
| 448 | isCharImmediatelyPostComment = false; |
| 449 | isCharImmediatelyPostTemplate = false; |
| 450 | isCharImmediatelyPostReturn = false; |
| 451 | isCharImmediatelyPostThrow = false; |
| 452 | isCharImmediatelyPostOperator = false; |
| 453 | isCharImmediatelyPostPointerOrReference = false; |
| 454 | isCharImmediatelyPostOpenBlock = false; |
| 455 | isCharImmediatelyPostCloseBlock = false; |
| 456 | } |
| 457 | |
| 458 | if (shouldBreakLineAtNextChar) |
| 459 | { |
| 460 | if (isWhiteSpace(currentChar) && !lineIsEmpty) |
| 461 | continue; |
| 462 | isInLineBreak = true; |
| 463 | shouldBreakLineAtNextChar = false; |
| 464 | } |
| 465 | |
| 466 | if (isInExecSQL && !passedSemicolon) |
| 467 | { |
| 468 | if (currentChar == ';') |
| 469 | passedSemicolon = true; |
| 470 | appendCurrentChar(); |
| 471 | continue; |
| 472 | } |