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

Method findObjCColonAlignment

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

Find the colon alignment for Objective-C method definitions and method calls.

Source from the content-addressed store, hash-verified

7950
7951// Find the colon alignment for Objective-C method definitions and method calls.
7952int ASFormatter::findObjCColonAlignment() const
7953{
7954 assert(currentChar == '+' || currentChar == '-' || currentChar == '[');
7955 assert(getAlignMethodColon());
7956
7957 bool isFirstLine = true;
7958 bool haveFirstColon = false;
7959 bool foundMethodColon = false;
7960 bool isInComment_ = false;
7961 bool isInQuote_ = false;
7962 bool haveTernary = false;
7963 char quoteChar_ = ' ';
7964 int sqBracketCount = 0;
7965 int colonAdjust = 0;
7966 int colonAlign = 0;
7967 string nextLine_ = currentLine;
7968 ASPeekStream stream(sourceIterator);
7969
7970 // peek next line
7971 while (sourceIterator->hasMoreLines() || isFirstLine)
7972 {
7973 if (!isFirstLine)
7974 nextLine_ = stream.peekNextLine();
7975 // parse the line
7976 haveFirstColon = false;
7977 nextLine_ = ASBeautifier::trim(nextLine_);
7978 for (size_t i = 0; i < nextLine_.length(); i++)
7979 {
7980 if (isWhiteSpace(nextLine_[i]))
7981 continue;
7982 if (nextLine_.compare(i, 2, "/*") == 0)
7983 isInComment_ = true;
7984 if (isInComment_)
7985 {
7986 if (nextLine_.compare(i, 2, "*/") == 0)
7987 {
7988 isInComment_ = false;
7989 ++i;
7990 }
7991 continue;
7992 }
7993 if (nextLine_[i] == '\\')
7994 {
7995 ++i;
7996 continue;
7997 }
7998 if (isInQuote_)
7999 {
8000 if (nextLine_[i] == quoteChar_)
8001 isInQuote_ = false;
8002 continue;
8003 }
8004
8005 if (nextLine_[i] == '"'
8006 || (nextLine_[i] == '\'' && !isDigitSeparator(nextLine_, i)))
8007 {
8008 isInQuote_ = true;
8009 quoteChar_ = nextLine_[i];

Callers

nothing calls this directly

Calls 4

hasMoreLinesMethod · 0.45
peekNextLineMethod · 0.45
lengthMethod · 0.45
compareMethod · 0.45

Tested by

no test coverage detected