MCPcopy Create free account
hub / github.com/dirkvranckaert/AndroidDecompiler / updateFormattedLineSplitPoints

Method updateFormattedLineSplitPoints

astyle/src/ASFormatter.cpp:5856–5958  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5854}
5855
5856void ASFormatter::updateFormattedLineSplitPoints(char appendedChar)
5857{
5858 assert(maxCodeLength != string::npos);
5859 assert(formattedLine.length() > 0);
5860
5861 if (!isOkToSplitFormattedLine())
5862 return;
5863
5864 char nextChar = peekNextChar();
5865
5866 // don't split before an end of line comment
5867 if (nextChar == '/')
5868 return;
5869
5870 // don't split before or after a bracket
5871 if (appendedChar == '{' || appendedChar == '}'
5872 || previousNonWSChar == '{' || previousNonWSChar == '}'
5873 || nextChar == '{' || nextChar == '}'
5874 || currentChar == '{' || currentChar == '}') // currentChar tests for an appended bracket
5875 return;
5876
5877 // don't split before or after a block paren
5878 if (appendedChar == '[' || appendedChar == ']'
5879 || previousNonWSChar == '['
5880 || nextChar == '[' || nextChar == ']')
5881 return;
5882
5883 if (isWhiteSpace(appendedChar))
5884 {
5885 if (nextChar != ')' // space before a closing paren
5886 && nextChar != '(' // space before an opening paren
5887 && nextChar != '/' // space before a comment
5888 && nextChar != ':' // space before a colon
5889 && currentChar != ')' // appended space before and after a closing paren
5890 && currentChar != '(' // appended space before and after a opening paren
5891 && previousNonWSChar != '(' // decided at the '('
5892 // don't break before a pointer or reference aligned to type
5893 && !(nextChar == '*'
5894 && !isCharPotentialOperator(previousNonWSChar)
5895 && pointerAlignment == PTR_ALIGN_TYPE)
5896 && !(nextChar == '&'
5897 && !isCharPotentialOperator(previousNonWSChar)
5898 && (referenceAlignment == REF_ALIGN_TYPE
5899 || (referenceAlignment == REF_SAME_AS_PTR && pointerAlignment == PTR_ALIGN_TYPE)))
5900 )
5901 {
5902 if (formattedLine.length() - 1 <= maxCodeLength)
5903 maxWhiteSpace = formattedLine.length() - 1;
5904 else
5905 maxWhiteSpacePending = formattedLine.length() - 1;
5906 }
5907 }
5908 // unpadded closing parens may split after the paren (counts as whitespace)
5909 else if (appendedChar == ')')
5910 {
5911 if (nextChar != ')'
5912 && nextChar != ' '
5913 && nextChar != ';'

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected