| 450 | // Function folding OScript code. |
| 451 | |
| 452 | static void FoldOScriptDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, |
| 453 | WordList *[], Accessor &styler) { |
| 454 | bool foldComment = styler.GetPropertyInt("fold.comment") != 0; |
| 455 | bool foldPreprocessor = styler.GetPropertyInt("fold.preprocessor") != 0; |
| 456 | bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; |
| 457 | Sci_Position endPos = startPos + length; |
| 458 | int visibleChars = 0; |
| 459 | Sci_Position lineCurrent = styler.GetLine(startPos); |
| 460 | int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; |
| 461 | int levelCurrent = levelPrev; |
| 462 | char chNext = styler[startPos]; |
| 463 | int styleNext = styler.StyleAt(startPos); |
| 464 | int style = initStyle; |
| 465 | Sci_Position lastStart = 0; |
| 466 | |
| 467 | for (Sci_Position i = startPos; i < endPos; i++) { |
| 468 | char ch = chNext; |
| 469 | chNext = styler.SafeGetCharAt(i + 1); |
| 470 | int stylePrev = style; |
| 471 | style = styleNext; |
| 472 | styleNext = styler.StyleAt(i + 1); |
| 473 | bool atLineEnd = (ch == '\r' && chNext != '\n') || (ch == '\n'); |
| 474 | |
| 475 | if (foldComment && IsBlockComment(style)) { |
| 476 | if (!IsBlockComment(stylePrev)) { |
| 477 | levelCurrent++; |
| 478 | } else if (!IsBlockComment(styleNext) && !atLineEnd) { |
| 479 | // Comments do not end at end of line and the next character |
| 480 | // may not be styled. |
| 481 | levelCurrent--; |
| 482 | } |
| 483 | } |
| 484 | if (foldComment && atLineEnd && IsLineComment(lineCurrent, styler)) { |
| 485 | if (!IsLineComment(lineCurrent - 1, styler) && |
| 486 | IsLineComment(lineCurrent + 1, styler)) |
| 487 | levelCurrent++; |
| 488 | else if (IsLineComment(lineCurrent - 1, styler) && |
| 489 | !IsLineComment(lineCurrent+1, styler)) |
| 490 | levelCurrent--; |
| 491 | } |
| 492 | if (foldPreprocessor) { |
| 493 | if (ch == '#' && IsPreprocessor(style)) { |
| 494 | UpdatePreprocessorFoldLevel(levelCurrent, i + 1, styler); |
| 495 | } |
| 496 | } |
| 497 | |
| 498 | if (stylePrev != SCE_OSCRIPT_KEYWORD && style == SCE_OSCRIPT_KEYWORD) { |
| 499 | lastStart = i; |
| 500 | } |
| 501 | if (stylePrev == SCE_OSCRIPT_KEYWORD) { |
| 502 | if(IsIdentifierChar(ch) && !IsIdentifierChar(chNext)) { |
| 503 | UpdateKeywordFoldLevel(levelCurrent, lastStart, i, styler); |
| 504 | } |
| 505 | } |
| 506 | |
| 507 | if (!IsASpace(ch)) |
| 508 | visibleChars++; |
| 509 |
nothing calls this directly
no test coverage detected