MCPcopy Create free account
hub / github.com/KDE/kdevelop / isOneLineBlockReached

Method isOneLineBlockReached

plugins/astyle/3rdparty/libastyle/ASFormatter.cpp:3585–3671  ·  view source on GitHub ↗

* check if a one-line block has been reached, * i.e. if the currently reached '{' character is closed * with a complimentary '}' elsewhere on the current line, *. * @return 0 = one-line block has not been reached. * 1 = one-line block has been reached. * 2 = one-line block has been reached and is followed by a comma. * 3 = one-line block has been reac

Source from the content-addressed store, hash-verified

3583 * 3 = one-line block has been reached and is an empty block.
3584 */
3585int ASFormatter::isOneLineBlockReached(const string& line, int startChar) const
3586{
3587 assert(line[startChar] == '{');
3588
3589 bool isInComment_ = false;
3590 bool isInQuote_ = false;
3591 bool hasText = false;
3592 int braceCount = 0;
3593 int lineLength = line.length();
3594 char quoteChar_ = ' ';
3595 char ch = ' ';
3596 char prevCh = ' ';
3597
3598 for (int i = startChar; i < lineLength; ++i)
3599 {
3600 ch = line[i];
3601
3602 if (isInComment_)
3603 {
3604 if (line.compare(i, 2, "*/") == 0)
3605 {
3606 isInComment_ = false;
3607 ++i;
3608 }
3609 continue;
3610 }
3611
3612 if (isInQuote_)
3613 {
3614 if (ch == '\\')
3615 ++i;
3616 else if (ch == quoteChar_)
3617 isInQuote_ = false;
3618 continue;
3619 }
3620
3621 if (ch == '"'
3622 || (ch == '\'' && !isDigitSeparator(line, i)))
3623 {
3624 isInQuote_ = true;
3625 quoteChar_ = ch;
3626 continue;
3627 }
3628
3629 if (line.compare(i, 2, "//") == 0)
3630 break;
3631
3632 if (line.compare(i, 2, "/*") == 0)
3633 {
3634 isInComment_ = true;
3635 ++i;
3636 continue;
3637 }
3638
3639 if (ch == '{')
3640 {
3641 ++braceCount;
3642 continue;

Callers

nothing calls this directly

Calls 3

lengthMethod · 0.45
compareMethod · 0.45
backMethod · 0.45

Tested by

no test coverage detected