MCPcopy Create free account
hub / github.com/ProgerXP/Notepad2e / FoldMySQLDoc

Function FoldMySQLDoc

scintilla/lexers/LexMySQL.cxx:353–563  ·  view source on GitHub ↗

Store both the current line's fold level and the next lines in the level store to make it easy to pick up with each increment.

Source from the content-addressed store, hash-verified

351// Store both the current line's fold level and the next lines in the
352// level store to make it easy to pick up with each increment.
353static void FoldMySQLDoc(unsigned int startPos, int length, int initStyle, WordList *[], Accessor &styler)
354{
355 bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
356 bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
357 bool foldOnlyBegin = styler.GetPropertyInt("fold.sql.only.begin", 0) != 0;
358
359 int visibleChars = 0;
360 int lineCurrent = styler.GetLine(startPos);
361 int levelCurrent = SC_FOLDLEVELBASE;
362 if (lineCurrent > 0)
363 levelCurrent = styler.LevelAt(lineCurrent - 1) >> 16;
364 int levelNext = levelCurrent;
365
366 int styleNext = styler.StyleAt(startPos);
367 int style = initStyle;
368 int activeState = (style == SCE_MYSQL_HIDDENCOMMAND) ? HIDDENCOMMAND_STATE : style & HIDDENCOMMAND_STATE;
369
370 bool endPending = false;
371 bool whenPending = false;
372 bool elseIfPending = false;
373
374 char nextChar = styler.SafeGetCharAt(startPos);
375 for (unsigned int i = startPos; length > 0; i++, length--)
376 {
377 int stylePrev = style;
378 int lastActiveState = activeState;
379 style = styleNext;
380 styleNext = styler.StyleAt(i + 1);
381 activeState = (style == SCE_MYSQL_HIDDENCOMMAND) ? HIDDENCOMMAND_STATE : style & HIDDENCOMMAND_STATE;
382
383 char currentChar = nextChar;
384 nextChar = styler.SafeGetCharAt(i + 1);
385 bool atEOL = (currentChar == '\r' && nextChar != '\n') || (currentChar == '\n');
386
387 switch (MASKACTIVE(style))
388 {
389 case SCE_MYSQL_COMMENT:
390 if (foldComment)
391 {
392 // Multiline comment style /* .. */ just started or is still in progress.
393 if (IsStreamCommentStyle(style) && !IsStreamCommentStyle(stylePrev))
394 levelNext++;
395 }
396 break;
397 case SCE_MYSQL_COMMENTLINE:
398 if (foldComment)
399 {
400 // Not really a standard, but we add support for single line comments
401 // with special curly braces syntax as foldable comments too.
402 // MySQL needs -- comments to be followed by space or control char
403 if (styler.Match(i, "--"))
404 {
405 char chNext2 = styler.SafeGetCharAt(i + 2);
406 char chNext3 = styler.SafeGetCharAt(i + 3);
407 if (chNext2 == '{' || chNext3 == '{')
408 levelNext++;
409 else
410 if (chNext2 == '}' || chNext3 == '}')

Callers

nothing calls this directly

Calls 10

MatchIgnoreCaseFunction · 0.85
isspacecharFunction · 0.85
GetPropertyIntMethod · 0.80
GetLineMethod · 0.80
LevelAtMethod · 0.80
SafeGetCharAtMethod · 0.80
IsStreamCommentStyleFunction · 0.70
StyleAtMethod · 0.45
MatchMethod · 0.45
SetLevelMethod · 0.45

Tested by

no test coverage detected