| 516 | } |
| 517 | |
| 518 | static void FoldPascalDoc(unsigned int startPos, int length, int initStyle, WordList *[], |
| 519 | Accessor &styler) { |
| 520 | bool foldComment = styler.GetPropertyInt("fold.comment") != 0; |
| 521 | bool foldPreprocessor = styler.GetPropertyInt("fold.preprocessor") != 0; |
| 522 | bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; |
| 523 | unsigned int endPos = startPos + length; |
| 524 | int visibleChars = 0; |
| 525 | int lineCurrent = styler.GetLine(startPos); |
| 526 | int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; |
| 527 | int levelCurrent = levelPrev; |
| 528 | int lineFoldStateCurrent = lineCurrent > 0 ? styler.GetLineState(lineCurrent - 1) & stateFoldMaskAll : 0; |
| 529 | char chNext = styler[startPos]; |
| 530 | int styleNext = styler.StyleAt(startPos); |
| 531 | int style = initStyle; |
| 532 | |
| 533 | int lastStart = 0; |
| 534 | CharacterSet setWord(CharacterSet::setAlphaNum, "_", 0x80, true); |
| 535 | |
| 536 | for (unsigned int i = startPos; i < endPos; i++) { |
| 537 | char ch = chNext; |
| 538 | chNext = styler.SafeGetCharAt(i + 1); |
| 539 | int stylePrev = style; |
| 540 | style = styleNext; |
| 541 | styleNext = styler.StyleAt(i + 1); |
| 542 | bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); |
| 543 | |
| 544 | if (foldComment && IsStreamCommentStyle(style)) { |
| 545 | if (!IsStreamCommentStyle(stylePrev)) { |
| 546 | levelCurrent++; |
| 547 | } else if (!IsStreamCommentStyle(styleNext) && !atEOL) { |
| 548 | // Comments don't end at end of line and the next character may be unstyled. |
| 549 | levelCurrent--; |
| 550 | } |
| 551 | } |
| 552 | if (foldComment && atEOL && IsCommentLine(lineCurrent, styler)) |
| 553 | { |
| 554 | if (!IsCommentLine(lineCurrent - 1, styler) |
| 555 | && IsCommentLine(lineCurrent + 1, styler)) |
| 556 | levelCurrent++; |
| 557 | else if (IsCommentLine(lineCurrent - 1, styler) |
| 558 | && !IsCommentLine(lineCurrent+1, styler)) |
| 559 | levelCurrent--; |
| 560 | } |
| 561 | if (foldPreprocessor) { |
| 562 | if (style == SCE_PAS_PREPROCESSOR && ch == '{' && chNext == '$') { |
| 563 | ClassifyPascalPreprocessorFoldPoint(levelCurrent, lineFoldStateCurrent, i + 2, styler); |
| 564 | } else if (style == SCE_PAS_PREPROCESSOR2 && ch == '(' && chNext == '*' |
| 565 | && styler.SafeGetCharAt(i + 2) == '$') { |
| 566 | ClassifyPascalPreprocessorFoldPoint(levelCurrent, lineFoldStateCurrent, i + 3, styler); |
| 567 | } |
| 568 | } |
| 569 | |
| 570 | if (stylePrev != SCE_PAS_WORD && style == SCE_PAS_WORD) |
| 571 | { |
| 572 | // Store last word start point. |
| 573 | lastStart = i; |
| 574 | } |
| 575 | if (stylePrev == SCE_PAS_WORD && !(lineFoldStateCurrent & stateFoldInPreprocessor)) { |
nothing calls this directly
no test coverage detected