* get the next formatted line. * * @return formatted line. */
| 367 | * @return formatted line. |
| 368 | */ |
| 369 | string ASFormatter::nextLine() |
| 370 | { |
| 371 | const string* newHeader; |
| 372 | bool isInVirginLine = isVirgin; |
| 373 | isCharImmediatelyPostComment = false; |
| 374 | isPreviousCharPostComment = false; |
| 375 | isCharImmediatelyPostLineComment = false; |
| 376 | isCharImmediatelyPostOpenBlock = false; |
| 377 | isCharImmediatelyPostCloseBlock = false; |
| 378 | isCharImmediatelyPostTemplate = false; |
| 379 | traceLineNumber++; |
| 380 | |
| 381 | while (!isLineReady) |
| 382 | { |
| 383 | if (shouldReparseCurrentChar) |
| 384 | shouldReparseCurrentChar = false; |
| 385 | else if (!getNextChar()) |
| 386 | { |
| 387 | breakLine(); |
| 388 | continue; |
| 389 | } |
| 390 | else // stuff to do when reading a new character... |
| 391 | { |
| 392 | // make sure that a virgin '{' at the begining of the file will be treated as a block... |
| 393 | if (isInVirginLine && currentChar == '{' |
| 394 | && currentLineBeginsWithBracket // lineBeginsWith('{') |
| 395 | && previousCommandChar == ' ') |
| 396 | previousCommandChar = '{'; |
| 397 | if (isInHorstmannRunIn) |
| 398 | isInLineBreak = false; |
| 399 | if (!isWhiteSpace(currentChar)) |
| 400 | isInHorstmannRunIn = false; |
| 401 | isPreviousCharPostComment = isCharImmediatelyPostComment; |
| 402 | isCharImmediatelyPostComment = false; |
| 403 | isCharImmediatelyPostTemplate = false; |
| 404 | isCharImmediatelyPostReturn = false; |
| 405 | isCharImmediatelyPostOperator = false; |
| 406 | isCharImmediatelyPostPointerOrReference = false; |
| 407 | isCharImmediatelyPostOpenBlock = false; |
| 408 | isCharImmediatelyPostCloseBlock = false; |
| 409 | } |
| 410 | |
| 411 | // if (inLineNumber >= 7) |
| 412 | // int x = 1; |
| 413 | |
| 414 | if (shouldBreakLineAtNextChar && !isWhiteSpace(currentChar)) |
| 415 | { |
| 416 | isInLineBreak = true; |
| 417 | shouldBreakLineAtNextChar = false; |
| 418 | } |
| 419 | |
| 420 | if (isInExecSQL && !passedSemicolon) |
| 421 | { |
| 422 | if (currentChar == ';') |
| 423 | passedSemicolon = true; |
| 424 | appendCurrentChar(); |
| 425 | continue; |
| 426 | } |