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

Function ClassifyPascalWordFoldPoint

scintilla/lexers/LexPascal.cxx:420–516  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

418}
419
420static void ClassifyPascalWordFoldPoint(int &levelCurrent, int &lineFoldStateCurrent,
421 int startPos, unsigned int endPos,
422 unsigned int lastStart, unsigned int currentPos, Accessor &styler) {
423 char s[100];
424 GetRangeLowered(lastStart, currentPos, styler, s, sizeof(s));
425
426 if (strcmp(s, "record") == 0) {
427 lineFoldStateCurrent |= stateFoldInRecord;
428 levelCurrent++;
429 } else if (strcmp(s, "begin") == 0 ||
430 strcmp(s, "asm") == 0 ||
431 strcmp(s, "try") == 0 ||
432 (strcmp(s, "case") == 0 && !(lineFoldStateCurrent & stateFoldInRecord))) {
433 levelCurrent++;
434 } else if (strcmp(s, "class") == 0 || strcmp(s, "object") == 0) {
435 // "class" & "object" keywords require special handling...
436 bool ignoreKeyword = false;
437 unsigned int j = SkipWhiteSpace(currentPos, endPos, styler);
438 if (j < endPos) {
439 CharacterSet setWordStart(CharacterSet::setAlpha, "_");
440 CharacterSet setWord(CharacterSet::setAlphaNum, "_");
441
442 if (styler.SafeGetCharAt(j) == ';') {
443 // Handle forward class declarations ("type TMyClass = class;")
444 // and object method declarations ("TNotifyEvent = procedure(Sender: TObject) of object;")
445 ignoreKeyword = true;
446 } else if (strcmp(s, "class") == 0) {
447 // "class" keyword has a few more special cases...
448 if (styler.SafeGetCharAt(j) == '(') {
449 // Handle simplified complete class declarations ("type TMyClass = class(TObject);")
450 j = SkipWhiteSpace(j, endPos, styler, true);
451 if (j < endPos && styler.SafeGetCharAt(j) == ')') {
452 j = SkipWhiteSpace(j, endPos, styler);
453 if (j < endPos && styler.SafeGetCharAt(j) == ';') {
454 ignoreKeyword = true;
455 }
456 }
457 } else if (setWordStart.Contains(styler.SafeGetCharAt(j))) {
458 char s2[11]; // Size of the longest possible keyword + one additional character + null
459 GetForwardRangeLowered(j, setWord, styler, s2, sizeof(s2));
460
461 if (strcmp(s2, "procedure") == 0 ||
462 strcmp(s2, "function") == 0 ||
463 strcmp(s2, "of") == 0 ||
464 strcmp(s2, "var") == 0 ||
465 strcmp(s2, "property") == 0 ||
466 strcmp(s2, "operator") == 0) {
467 ignoreKeyword = true;
468 }
469 }
470 }
471 }
472 if (!ignoreKeyword) {
473 levelCurrent++;
474 }
475 } else if (strcmp(s, "interface") == 0) {
476 // "interface" keyword requires special handling...
477 bool ignoreKeyword = true;

Callers 1

FoldPascalDocFunction · 0.85

Calls 8

SkipWhiteSpaceFunction · 0.85
GetForwardRangeLoweredFunction · 0.85
IsASpaceOrTabFunction · 0.85
SafeGetCharAtMethod · 0.80
GetRangeLoweredFunction · 0.70
IsStreamCommentStyleFunction · 0.70
ContainsMethod · 0.45
StyleAtMethod · 0.45

Tested by

no test coverage detected